V
V
Vladimir Zhurkin2019-12-17 02:59:03
Nginx
Vladimir Zhurkin, 2019-12-17 02:59:03

How to change the context using nginx?

There is a backend (upstream) , in which, alas, you cannot change how to give the context.
It is necessary that by location / id / work proxy_pass to this server.
those

location /id/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass server/am/uth/;

The problem is that when we go to another link after opening , we get a 502 error
like url like /am/uth/resources/7 changes to id/resources/7 , those uth are gone.
No reverse address translation.
proxy_redirect doesn't work because the backend doesn't return Location in headers that weren't delivered.
What we managed to come up with is sub_filter /am/uth on /id and then everything works, but then there is /id/admin where, of course, everything breaks down.
If you specify the correct path to the image or other static file, then everything opens, there is no replacement for the url from the backend
. In general, are there any solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sundukov, 2019-12-17
@alekciy

You can try to extract uth / admin / other through map into a variable and use it for sub_filter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question