-
-
Save KirinHuang/bc4e0faab096913ebf134960738bafe7 to your computer and use it in GitHub Desktop.
spa nginx config | 单页应用 nginx 配置
This file contains 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 backend { | |
server 127.0.0.1:3000; | |
} | |
server { | |
listen 80; | |
server_name your.hostname.com; | |
proxy_set_header Host $http_host; | |
access_log /tmp/test-access.log debug; | |
rewrite_log on; | |
root /home/work/project/path/public; | |
location / { | |
try_files $uri /index.html; | |
index index.html index.htm; | |
} | |
location /index.html { | |
add_header Cache-Control "no-cache, no-store, must-revalidate"; | |
} | |
location ^~ /assets/ { | |
add_header Cache-Control "public,max-age=31536000"; | |
# Allow cross origin access | |
add_header Access-Control-Expose-Headers "Access-Control-Allow-Origin"; | |
add_header Access-Control-Allow-Origin "*"; | |
} | |
location /api { | |
proxy_pass http://backend; | |
} | |
# server sent event | |
location ~ /sent-events/(.*) { | |
proxy_pass http://backend/$1; | |
proxy_set_header Host $host; | |
proxy_http_version 1.1; | |
proxy_set_header Connection ''; | |
proxy_buffering off; | |
proxy_cache off; | |
chunked_transfer_encoding off; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment