Last active
December 2, 2017 09:22
-
-
Save rubenmromero/058bbc37a7dac980337883bcb1510469 to your computer and use it in GitHub Desktop.
Nginx :: Redirect requests to another environment based on received header values
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
#################################################################################################### | |
### Virtual Host for api.<env1_domain> subdomain | |
#################################################################################################### | |
# Block to redirect requests from the new versions of the mobile apps to the second environment, which also has the new version of backend services | |
map $http_X_app_version $is_new_version { | |
default "0"; | |
ANDROID_30 "1"; | |
IOS_30 "1"; | |
} | |
server { | |
. . . | |
. . . | |
location / { | |
# Block to redirect requests from the new versions of the mobile apps to the second environment, which also has the new version of backend services | |
if ($is_new_version) { | |
proxy_pass https://api.<env2_domain>; | |
break; | |
} | |
# Rest of lines that applies to location / in the api.<env1_domain> VHost configuration | |
index app.php; | |
. . . | |
. . . | |
} | |
. . . | |
. . . | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment