A
A
Andrey Barbolin2017-05-24 01:02:33
Nginx
Andrey Barbolin, 2017-05-24 01:02:33

How does Nginx proxy rewrite response?

Comrades, Connoisseurs!
There is nginx in proxy mode, proxying is configured. Can't publish second resource under office.
Example situation:
When accessing the example.com domain , proxying goes to 10.100.0.70 and everything works fine. When I access example.com/office backend forwards me to example.com/welcome/, and I need to example.com/office/welcome/.
I assume that it is necessary to rewrite backend responses. But how?

location / {
  
 proxy_pass_header Authorization;
 proxy_pass http://10.100.0.70;
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 add_header Front-End-Https on;
 proxy_http_version 1.1;
 proxy_set_header Connection "";
 proxy_buffering off;
 client_max_body_size 0;
 proxy_read_timeout 36000s;
 proxy_redirect off;

           }

        location /office/ {
     
               if ($request_uri ~* "/office/(.*)") {
                       proxy_pass  http://10.11.10.22/$1;
               }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2017-05-24
@dronmaxman

location /office/ {
proxy_pass http://10.11.10.22/;
}

update: if you need to change in the opposite direction, then nginx.org/en/docs/http/ngx_http_proxy_module.html#...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question