Created
April 4, 2023 04:12
-
-
Save RazinTeqB/b449ce4613fcead01f8698caab11cc9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nginx revers proxy for nuxt front-end and fuelphp backend backup | |
events { } | |
http { | |
server { | |
#http redirect to ssl | |
listen 80 default_server; | |
server_name _; | |
return 301 https://$host$request_uri; | |
} | |
include 'nuxt-routes.conf'; | |
server { | |
include 'mobile.conf'; | |
set $nuxt_ready $http_nuxt_ready; | |
listen 443 ssl http2; | |
ssl_certificate /var/www/ssl/certificate.crt; | |
ssl_certificate_key /var/www/ssl/private_key.key; | |
server_name _; | |
# Redirect /foobar/ to /foobar | |
rewrite ^(.+)/$ $1 permanent; | |
access_log /var/log/nginx/access.log combined; | |
error_log /var/log/nginx/error.log warn; | |
set $nuxt_rewrite $nuxt_route; | |
# Create code to see whether we rewrite or not | |
if ($mobile_rewrite = perform) { | |
set $nuxt_rewrite "${nuxt_rewrite}PM"; # Platform Mobile | |
} | |
if ($mobile_rewrite != perform) { | |
set $nuxt_rewrite "${nuxt_rewrite}PD"; # Platform Desktop | |
} | |
if ($nuxt_rewrite ~ DPD|MPM|APM|APD) { | |
rewrite ^(.*)$ /nuxt/$1; # force nuxt unless is nuxt_ready | |
} | |
# Force PHP because Header is used to go to php "api" | |
if ($nuxt_ready = 1) { | |
rewrite ^/nuxt/(.*)$ $1; # force php | |
} | |
if ($host = 'dev-www.florachic.com') { | |
rewrite ^/nuxt/(.*)$ $1; # force php # TODO for production it would be www.florachic.com | |
} | |
gzip on; | |
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | |
# Proxy pass | |
location /nuxt/ { | |
rewrite ^/nuxt/(.*)$ $1 break; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_read_timeout 20d; | |
proxy_buffering off; | |
proxy_ssl_verify off; | |
proxy_pass https://nuxt:3000/; # TODO for production it would be localhost | |
} | |
# Proxy pass for hmr folder | |
location /nuxt/_nuxt/hmr { | |
rewrite ^/nuxt/(.*)$ $1 break; | |
proxy_pass https://localhost:24678; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_read_timeout 20d; | |
proxy_buffering off; | |
proxy_ssl_verify off; | |
proxy_pass https://php7/; #TODO for production it would be localhost | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment