0
votes

I am currently configured on nginx like given below upstream backend {

least_conn;

server 172.17.0.4 max_fails=2 fail_timeout=30s;

server 172.17.0.2 max_fails=2 fail_timeout=30s weight=2;

}

server {

listen       80;

server_name example.com;



location / {

proxy_pass http://backend;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $host;

}

}

I am looking for url rewrites like

eg: if someone comes on example.com/sample. we want to redirect to proxy_pass backend/new/1/sample

but when i am doing proxy_pass it is redirecting to but the url in the browser still showing as example.com/sample

it should show example.com/new/1/sample

how can i rewrite the url and show the url in the browser.

Thank you in advance

1
Do you need your request example.com/sample to be proxied to backend/sample (which you current config does) or to backend/new/1/sample? - Ivan Shatsky

1 Answers

0
votes

I would say you need the http 301 redirection. So i would try something like this:

return 301 backend/new/1/sample;