Last active
May 20, 2019 07:54
-
-
Save HarshadRanganathan/f2dc4494fcd9300e4abe8af8f4f801c8 to your computer and use it in GitHub Desktop.
HTTPS Reverse Proxy Configuration in Nginx
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 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