Skip to content

Instantly share code, notes, and snippets.

@devinivy
Created July 14, 2016 13:06
Show Gist options
  • Save devinivy/968f75636d800b80741e75ca4c466aaf to your computer and use it in GitHub Desktop.
Save devinivy/968f75636d800b80741e75ca4c466aaf to your computer and use it in GitHub Desktop.
Nginx reverse-proxy config for many apps
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>;
}
}
# 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;
}
# 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