Last active
June 7, 2018 15:33
-
-
Save fujiwara/1b52106db2a149dffa06ee5d8fb50e4d to your computer and use it in GitHub Desktop.
nginx dynamic mirror
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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