Modify url at nginx

Francis Daly francis at
Mon Jul 30 21:51:53 UTC 2018

On Mon, Jul 30, 2018 at 02:58:56AM -0400, linsonj wrote:

Hi there,

> What we want is when client type , nginx see url
> as Before proxy pass request to tomcat7, it should modify
> url to so tomcat7 see client url as
> Once request is processed, response is given back to nginx
> and nginx give it back to end url

Untested, but I suggest you add a

  upstream { server; }

and then make the following changes:

> location /server {
> proxy_pass;

change to


> proxy_set_header Host $host;

Remove that.

> proxy_redirect off;

Remove that.

> Would be of great help if someone can advise us how can we modify the url
> based on the use case explained above.

If you don't add the "upstream", then you should change

  proxy_set_header Host $host;


  proxy_set_header Host;

because that is the Host: header that you say you want tomcat to get.

proxy_redirect ( will rewrite a http
Location: response header, if it is given the chance.

The only place I think that this should fail, is if the tomcat service
returns http body content which refers to Ideally,
it shouldn't, or can be configured not to.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list