Created
August 21, 2020 10:57
-
-
Save banjin/9f7148edf49d8b3e9666290f0cb76134 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
upstream back_server{ | |
ip_hash; | |
server 127.0.0.1:8000; | |
} | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
upstream websocket { | |
server 127.0.0.1:8001; | |
} | |
server { | |
listen 8888 default_server; | |
#listen [::]:8690 default_server ipv6only=on; | |
#root /usr/share/nginx/html; | |
#index index.html index.htm; | |
# Make site accessible from http://localhost/ | |
server_name localhost; | |
location /ws { | |
proxy_pass http://websocket; | |
proxy_http_version 1.1; | |
proxy_set_header Host $http_host; | |
# proxy_connect_timeout 300s; | |
# proxy_read_timeout 300s; | |
# proxy_send_timeout 300s; | |
proxy_set_header X-Nginx-Proxy true; | |
proxy_set_header 'Access-Control-Allow-Origin' '*'; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
location / { | |
root "/usr/local/project/dist"; | |
#index index.html | |
try_files $uri $uri/ /index.html /index.htm; | |
} | |
location /api { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
# Uncomment to enable naxsi on this location | |
# include /etc/nginx/naxsi.rules | |
proxy_set_header 'Access-Control-Allow-Origin' "*"; | |
proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_pass http://back_server ; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment