Skip to content

Instantly share code, notes, and snippets.

@magician11
Last active January 19, 2018 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magician11/6f44793920e8973cf687d43ca1e6a774 to your computer and use it in GitHub Desktop.
Save magician11/6f44793920e8973cf687d43ca1e6a774 to your computer and use it in GitHub Desktop.
Reverse proxy with Nginx to Node.js server with HTTP to HTTPS redirect
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name my-server.com www.my-server.com;
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl_certificate /etc/letsencrypt/live/my-server.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-server.com/privkey.pem;
# redirect root of domain to special-page
location ~ ^/$ {
return 301 https://anotherpage.com/pages/special-page;
}
# other URLs to this domain name goto our Node.js server
location / {
proxy_set_header X-Forwarded-Proto https;
proxy_pass https://localhost:5060;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment