'How to configure Nginx so the proxy_pass also aply to in-site requests?

So let me introduce you to my context: I have a several containers deployed and I'd like to use nginx as reverse proxy so I can target my other containers (which are API's) through something like this: https://example.mysite.com/services/whatever_the_api.

I managed to get to a point where the proxy_pass works like a charm but now I have a problem: when my API admin page loads, it tries to find the assets like this : https://example.mysite.com/assets/... ditching the /services/api/ part.

Here is my /etc/nginx/config.d/sample.conf file :

server {
    listen myhost:80;
    server_name  myhost;
    location ^~ /services/apiName/ {
        proxy_pass http://myapp:1338/;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

If anyone knows what is the configuration material I'm missing, I'll be grateful to hear about it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source