Score:0

Preserve base URL for a proxied NGINX location

cn flag

I've got an NGINX config as follows:

server {
    listen       80;
    server_name  _;
    location = / {
        proxy_pass https://server-2.alice.com/;
        proxy_redirect  off;
        proxy_ssl_server_name on;
        proxy_ssl_session_reuse off;
    }
    location /app {
        proxy_pass http://server-6.alice.com:3000$request_uri;
        proxy_redirect  off;
        proxy_ssl_server_name on;
        proxy_ssl_session_reuse off;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

This config serves https://myhost.com

The problem here is that if I visit https://myhost.com/app, all the proxied requests are going back rooted to the main path... i.e. going to https://myhost.com/app will try to load some /static/chunk.js file. However, it ends up going to https://myhost.com/static/chunk.js instead of loading https://myhost.com/app/static/chunk.js

How do I set some sort of rule such that anything that is initially routed https://myhost.com/app/* maintains the baseURL as https://myhost.com/app?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.