Skip to content

Instantly share code, notes, and snippets.

@rubenmromero
Last active December 2, 2017 09:22
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 rubenmromero/058bbc37a7dac980337883bcb1510469 to your computer and use it in GitHub Desktop.
Save rubenmromero/058bbc37a7dac980337883bcb1510469 to your computer and use it in GitHub Desktop.
Nginx :: Redirect requests to another environment based on received header values
####################################################################################################
### 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