Last active
January 3, 2019 21:20
-
-
Save drewgates/ebae984125d11c9c2823f2938c0c63e0 to your computer and use it in GitHub Desktop.
sample nginx config for reverse proxy
This file contains 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
# replace all instances of example.com with your domain name. | |
# request the appropriate Letsencrypt SSL Cert and fix the cert paths appropriately. | |
# paste this in /etc/nginx/sites-available/ as "example.com.conf" (replace with your domain) and then symlink to /etc/nginx/sites-enabled/ | |
# nginx -t and systemctl nginx reload. | |
# Replace target.example.com with the appropriate IP or target domain in the proxy_pass line. | |
# Good luck! | |
server { | |
server_name example.com; | |
location / { | |
proxy_pass http://target.example.com; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
listen 443 ssl; # managed by Certbot | |
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 | |
# include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name example.com; | |
return 301 https://example.com$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment