Skip to content

Instantly share code, notes, and snippets.

@HarshadRanganathan
Last active May 20, 2019 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HarshadRanganathan/f2dc4494fcd9300e4abe8af8f4f801c8 to your computer and use it in GitHub Desktop.
Save HarshadRanganathan/f2dc4494fcd9300e4abe8af8f4f801c8 to your computer and use it in GitHub Desktop.
HTTPS Reverse Proxy Configuration in Nginx
upstream backend-server {
server backend.com:443;
}
server {
root /home/ec2-user/app/public;
index index.html;
server_name app.com;
location /app-proxy/ {
rewrite ^/app-proxy/(.*)$ /$1 break;
proxy_pass https://backend-server;
proxy_ssl_session_reuse on;
}
location ~ /\. {
deny all;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/app.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = app.com) {
return 301 https://$host$request_uri;
}
listen 80;
server_name app.com;
return 404;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment