Last active
October 1, 2018 21:38
-
-
Save jsanta/1cabd83f6cc82cfaf9735b799b8ecf4e to your computer and use it in GitHub Desktop.
Sample sites_available configuration for nginx where port 8123 redirects to another server (eg a NodeJS Express app) running on port 3218. This configuration considers WebSocket and CORs support.
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
| server { | |
| listen 8123 default_server; | |
| listen [::]:8123 default_server; | |
| server_name your_server; | |
| add_header Strict-Transport-Security "max-age=31536000"; | |
| access_log /var/log/nginx/some_app.access.log; | |
| error_log /var/log/nginx/some_app.error.log; | |
| location / { | |
| include /etc/nginx/mime.types; | |
| if ($request_method = OPTIONS) { | |
| add_header Access-Control-Allow-Origin $http_origin; | |
| add_header Access-Control-Allow-Methods "GET, POST, DELETE, PUT, OPTIONS"; | |
| add_header Access-Control-Allow-Headers "Authorization, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Allow-Origin, x-uuid, X-JWT-Token, X-JWT-RefreshToken"; | |
| add_header Access-Control-Allow-Credentials "true"; | |
| add_header Content-Length 0; | |
| add_header Content-Type text/plain; | |
| return 200; | |
| } | |
| proxy_pass http://127.0.0.1:3218; | |
| proxy_buffering on; | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection "upgrade"; | |
| proxy_set_header Host $host; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Configuration included in article posted at https://medium.com/@JSantaCL/nginx-nodejs-and-spas-cc50c376b131