0

I need proxing to different backend but whith same url, so rewriting thould be like this

URL: http://myservrer.com/server/monitoring1?(parameters) 
REWRITE TO: http://1.1.1.1/server/monitoring?(parameters)

URL: http://myservrer.com/server/monitoring2?(parameters) 
REWRITE TO: http://2.2.2.2/server/monitoring?(parameters)

My current config:

location /server/monitoring1 {             
proxy_pass http://1.1.1.1:82/server/monitoring;                                                              
}
location /server/monitoring2 {             
proxy_pass http://2.2.2.2:82/server/monitoring;                                                              
}

How to change it with rewrite options?

1 Answers1

0
location /server/monitoring1 {             
    rewrite ^/server/monitoring1\?(.*) http://1.1.1.1:82/server/monitoring?$1 redirect;
}
location /server/monitoring2 {
    rewrite ^/server/monitoring2\?(.*) http://2.2.2.2:82/server/monitoring?$1 redirect;
}
Marcel
  • 1,730
  • 10
  • 15
  • 3
    This is a well-formatted example, but examples should not comprise the entire body of an answer. Adding a brief description of what you changed and why would be very helpful. – Andrew B Apr 09 '13 at 22:54
  • Well, the example above answers the question completely. He asked for a translation of his config using rewrites. That's what I did. – Marcel Apr 10 '13 at 13:29