Last active
March 10, 2017 03:40
-
-
Save zhaocnus/fc81a78fc03c4bc294836dd01233d63c to your computer and use it in GitHub Desktop.
Nginx config
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
| # Serve static SPA | |
| server { | |
| listen 80; | |
| root /home/young/src/www.example.com/; | |
| index index.html; | |
| server_name www.example.com; | |
| location / { | |
| try_files $uri /index.html =404; | |
| sendfile off; | |
| expires 0; | |
| } | |
| } | |
| # Serve nodejs app | |
| server { | |
| listen 80; | |
| root /home/young/src/www.example.com/; | |
| index index.html; | |
| server_name www.example.com; | |
| location / { | |
| proxy_pass http://localhost:8080; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| # set body size | |
| client_max_body_size 2M; | |
| # WebSocket support (nginx 1.4) | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection "upgrade"; | |
| } | |
| # serve static file from another dir using alias | |
| # http://stackoverflow.com/a/10647080 | |
| location /static/ { | |
| autoindex off; | |
| alias /home/young/static/; | |
| } | |
| # serve static file from another dir using root | |
| # http://stackoverflow.com/a/10647080 | |
| location /static2/ { | |
| autoindex off; | |
| root /home/young/; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment