My nginx server is currently setup to serve all requests via uwsgi_pass
:
location / {
uwsgi_pass unix:///tmp/uwsgi-zerocater.sock;
include uwsgi_params;
uwsgi_read_timeout 7200;
client_max_body_size 20M;
}
In my application code, I've set a cookie called new_fe
whose value is either "True" or "False".
When the value is "True", I want to instead proxy_pass
to another external server, but only for specific routes. Something like the following pseudo code:
location ~ "^/my/complicated/regex$" {
if ($cookie_new_fe = "True") {
# pass the request to my other server
# at something like http://other.server.com
} else {
# do the usual uwsgi stuff
}
}
How can I do this? I'm still a bit new to nginx
, so please pardon the question if it's something simple I'm missing.
As a temporary solution this should work:
I looked into maps a bit more and came up with this solution, which seems to work (uses both @womble's and @alexey-ten's suggestions):
This way I have minimal duplication across the many routes that I'll need to add here in the interim, until this migration is complete.