Skip to content

Instantly share code, notes, and snippets.

@fujiwara
Last active June 7, 2018 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujiwara/1b52106db2a149dffa06ee5d8fb50e4d to your computer and use it in GitHub Desktop.
Save fujiwara/1b52106db2a149dffa06ee5d8fb50e4d to your computer and use it in GitHub Desktop.
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