I
I
Igor S2016-02-04 21:42:07
Nginx
Igor S, 2016-02-04 21:42:07

How to make a redirect in NGINX without changing the URI?

Salute comrades!
we have a simple configuration:

server {
        listen 443 ssl;
        server_name hostname.lan;
        proxy_set_header Host hostname.lan;

        location / {
                proxy_pass http://172.16.18.50/;
        }
        location /a/ {
                proxy_pass http://172.16.18.50/mwiki/;
                #proxy_redirect http://172.16.18.50/mwiki/ /a/;
                #proxy_redirect default;
                proxy_set_header   Host             $host;
                proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_redirect off;
        }

It is necessary that when accessing https://hostname.lan/a/, the request is transparently sent to 172.16.18.50/mwiki . But when I make a request, in the address bar of the browser the request changes to https://hostname.lan/mwiki

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question