What I'm trying to do is that all incoming requests shall be handled by my Angular application. But one directory is for a REST-api that have to be excluded.
My current nginx config locks like this:
location /rest {
try_files $uri $uri/ /rest/index.php$is_args$args;
}
location ~ / {
proxy_pass http://127.0.0.1:4000;
}
The above config always responds with the http://127.0.0.1:4000
. The REST api itself seems to work, because when I disable the location ~ /
the REST is called and returns content. So what I would like to achieve is:
https://SERVER -> http://127.0.0.1:4000
https://SERVER/xyz -> http://127.0.0.1:4000
...
https://SERVER/rest -> http://127.0.0.1/rest
How can do a proxy forward off all requests but not if a specific directory is given?
What I would first try is to modify the first rule as:
According to the info here: https://www.digitalocean.com/community/tutorials/understanding-nginx-server-and-location-block-selection-algorithms
This should ensure that the sercond block is not encoutered if the first matches: