Home Nginx forward with URL rewrite and proxy_pass
Reply: 0

Nginx forward with URL rewrite and proxy_pass

user1145
1#
user1145 Published in June 19, 2018, 6:28 pm

I am looking for help in nginx configuration while forwarding request to another domain .

Proxy scenarios:

https://service1.com/downloads -> https://service2.com/app/downloads 

https://service1.com/downloads?param1=a&param2=b -> https://service2.com/app/downloads?param1=a&param2=b

Browser should have left side URL(service1) all the time. But Service 2 endpoints are different, it has additional param 'app'.

I have done this without considering 'app' param in service 2 endpoints using below config:

location /downloads {
    set $upstream_endpoint https://service2.com;
    proxy_pass $upstream_endpoint;
  }

But i need help, when i want to append some addition param ('app') while calling service2 endpoint.

I am trying with rewrite and proxy_pass but no luck. I have enable the upstream log and don't see the expected upstream URL

location /downloads {
  set $upstream_endpoint https://service2.com;
  proxy_pass $upstream_endpoint/app/$args;
}

Thanks in Advance

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.254521 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO