nginx setup with conditional reverse proxy for some routes
Solution 1:
The problem is location ^~ /
directive. This makes the prefix match explicit and prevents nginx from looking at regular expression matches.
Try the following:
location ~*^/[ab] {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
proxy_pass https://10.0.1.44;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}