Created
March 29, 2018 22:37
-
-
Save wesleybliss/d68e965830945c2d9b4a224a7d5d7313 to your computer and use it in GitHub Desktop.
Example NGINX config for giving Node processes their own 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
~ cat /etc/nginx/sites-available/example.com | |
# HTTP - redirect all requests to HTTPS: | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name example.com www.example.com; | |
# listen [::]:80 ipv6only=on; | |
return 301 https://$server_name$request_uri; | |
} | |
# HTTPS - proxy requests on to local Node.js app: | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name example.com www.example.com; | |
error_log /var/log/nginx/example.com.error.log; | |
access_log /var/log/nginx/example.com.access.log; | |
ssl on; | |
underscores_in_headers on; | |
# Use certificate and key provided by Let's Encrypt: | |
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot | |
# See https://gist.github.com/wesleybliss/01ceeda5a3b59cc1542b915a901e1600 | |
include snippets/ssl-params.conf; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_pass http://127.0.0.1:1234; # Any port you want here | |
proxy_http_version 1.1; | |
proxy_ssl_session_reuse off; | |
proxy_cache_bypass $http_upgrade; | |
proxy_redirect off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment