Created
February 7, 2018 03:54
-
-
Save crookm/b0d959a9ab69e8559745b88152929783 to your computer and use it in GitHub Desktop.
NGINX config file for node.js applications with websocket support and ssl
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 80; | |
server_name example.com www.example.com; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_pass http://127.0.0.1:<PROJECT PORT>; | |
proxy_redirect off; | |
# socket.io support | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
} | |
} | |
server { | |
listen 443 ssl; | |
server_name example.com www.example.com; | |
# ssl certs and keys | |
ssl_certificate /etc/ssl/certs/<YOUR CERTIFICATE>.crt; | |
ssl_certificate_key /etc/ssl/private/<YOUR SECRET KEY>.key; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_ciphers 'AES128+EECDH:AES128+EDH'; | |
ssl_prefer_server_ciphers on; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_pass http://127.0.0.1:<PROJECT PORT>; | |
proxy_redirect off; | |
# socket.io support | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment