Created
May 20, 2019 18:03
-
-
Save Jamp/77aaee698854c8b86bbad841d2e6e744 to your computer and use it in GitHub Desktop.
Nginx Proxy Reverse for NodeJS App with SSL Letsencrypt
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
upstream nodejs-app { | |
server 127.0.0.1:3000; | |
keepalive 64; | |
} | |
# Server on port 80 | |
server { | |
listen 80; | |
server_name app.nodejs.com; | |
root /app; | |
location / { | |
# Proxy_pass configuration | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_max_temp_file_size 0; | |
proxy_pass http://nodejs-app/; | |
proxy_redirect off; | |
proxy_read_timeout 240s; | |
} | |
listen 443 ssl; | |
ssl_certificate /etc/letsencrypt/live/app.nodejs.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/app.nodejs.com/privkey.pem; | |
include /etc/letsencrypt/options-ssl-nginx.conf; | |
if ($scheme != "https") { | |
return 301 https://app.nodejs.com$request_uri; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment