Skip to content

Instantly share code, notes, and snippets.

@tolleiv
Created March 16, 2013 12:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tolleiv/5176269 to your computer and use it in GitHub Desktop.
Save tolleiv/5176269 to your computer and use it in GitHub Desktop.
Sample config to have a Nginx as reverse proxy with a fallback host included
upstream tracker {
server localhost:81;
server localhost:82 backup;
}
# HTTP server
server {
listen 80 default;
location / {
proxy_pass http://tracker;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header HTTPS "";
proxy_hide_header Via;
}
}
# HTTPS server
server {
listen 443;
ssl on;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://tracker;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header HTTPS "on";
proxy_hide_header Via;
}
}
# Backup host
server {
listen 127.0.0.1:82;
root /usr/share/nginx/www;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment