Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
"ssl_certificate": {"$file": "/nginx/files/foobar"},
"user": ["nobody", "nogroup"],
"events": {
"worker_connections": 1024,
"accept_mutex": "on"
},
"http": {
"gzip_disable": "\"MSIE [1-6]\\.\"",
"upstream": {
"testservers": {
"server": [
"example1.com",
"foobar.com:8080"
]
},
"appservers": {
"zone": {"$value": "/nginx/foo/bar"},
"server": {
"appserv1.example.com": null,
"appserv2.example.com:8080": {
"weight": "5"
},
"192.0.2.1": {
"max_fails": 3
},
"reserve1.example.com:8080": {
"backup": true
},
"reserve2.example.com:8080": {
"backup": true
}
}
}
},
"server": [
{
"server_name": "foobar.com",
"location": {
"@app": [
["proxy_set_header", "X-Forwarded-For $proxy_add_x_forwarded_for"],
["proxy_set_header", "X-Forwarded-Proto $scheme"]
],
"= /500.html": {
"root": "/path/to/app/current/public"
}
}
},
{
"server_name": "_",
"try_files": ["$uri/index.html", "$uri.html", "$uri", "@app"],
"location": [
["@app", [
["proxy_set_header", "Host $http_host"],
["proxy_set_header", "X-Forwarded-For $proxy_add_x_forwarded_for"]
]],
["= /500.html", {
"proxy_set_header": {
"X-Forwarded-For": "$proxy_add_x_forwarded_for",
"X-Forwarded-Proto": "$scheme"
},
"root": "/path/to/app/current/public"
}]
]
}
]
}
}
ssl_certificate /path/to/file;
user nobody nogroup;
events {
worker_connections 1024;
accept_mutex on;
}
http {
gzip_disable "MSIE [1-6]\.";
upstream testservers {
server example1.com;
server foobar.com:8080;
}
upstream appservers {
zone VALUE:/nginx/foo/bar;
server appserv1.example.com;
server appserv2.example.com:8080 weight=5;
server 192.0.2.1 max_fails=3;
server reserve1.example.com:8080 backup;
server reserve2.example.com:8080 backup;
}
server {
server_name foobar.com;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /500.html {
root /path/to/app/current/public;
}
}
server {
server_name _;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location = /500.html {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
root /path/to/app/current/public;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment