Skip to content

Instantly share code, notes, and snippets.

@fujiwara

fujiwara/nginx.conf

Last active Jun 7, 2018
Embed
What would you like to do?
nginx dynamic mirror
$ curl -H"X-Mirror1: 127.0.0.1:5000" -H"X-Mirror2: 127.0.0.1:5001" -H"X-Mirror3: 127.0.0.1:5002" localhost:8000
server {
listen 8000;
mirror_request_body on;
# log_subrequest on;
root /tmp;
location / {
mirror /mirror1;
mirror /mirror2;
mirror /mirror3;
}
location /mirror1 {
internal;
if ($http_x_mirror1 != "") {
proxy_pass http://$http_x_mirror1$request_uri;
}
}
location /mirror2 {
internal;
if ($http_x_mirror2 != "") {
proxy_pass http://$http_x_mirror2$request_uri;
}
}
location /mirror3 {
internal;
if ($http_x_mirror3 != "") {
proxy_pass http://$http_x_mirror3$request_uri;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment