Created
July 14, 2016 13:06
-
-
Save devinivy/968f75636d800b80741e75ca4c466aaf to your computer and use it in GitHub Desktop.
Nginx reverse-proxy config for many apps
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
include /etc/nginx/conf.d/real-scheme.block; | |
upstream <app> { | |
server 127.0.0.1:<port>; | |
keepalive 16; | |
} | |
server { | |
listen 80; | |
server_name <server>; | |
access_log /var/log/<app>_access.log; | |
location / { | |
include /etc/nginx/conf.d/reverse-proxy.block; | |
proxy_pass http://<app>; | |
} | |
} |
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
# Determine actual scheme (http/https) if available. | |
# This deals with load-balancer termination of SSL. | |
map $http_x_forwarded_proto $real_scheme { | |
default $http_x_forwarded_proto; | |
'' $scheme; | |
} |
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
# Note, $real_scheme relies on ./real-scheme.block | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $real_scheme; | |
proxy_set_header Host $http_host; | |
proxy_set_header Connection ""; # For keepalive | |
proxy_http_version 1.1; # For keepalive | |
proxy_intercept_errors on; | |
proxy_redirect off; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment