Welcome! Log In Create A New Profile

Advanced

Re: Modify url at nginx

Francis Daly
July 30, 2018 05:54PM
On Mon, Jul 30, 2018 at 02:58:56AM -0400, linsonj wrote:

Hi there,

> What we want is when client type https://test1.apphost.com , nginx see url
> as test1.apphost.com. Before proxy pass request to tomcat7, it should modify
> url to https://test.apphost.com so tomcat7 see client url as
> test.apphost.com. Once request is processed, response is given back to nginx
> and nginx give it back to end url https://test1.apphost.com

Untested, but I suggest you add a

upstream test.apphost.com { server 127.0.0.1:8080; }

and then make the following changes:

> location /server {
>
> proxy_pass http://127.0.0.1:8080/server;

change to

proxy_pass http://test.apphost.com;

> 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;

to

proxy_set_header Host test.apphost.com;

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

proxy_redirect (http://nginx.org/r/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 test.apphost.com. Ideally,
it shouldn't, or can be configured not to.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Modify url at nginx

linsonj July 30, 2018 02:58AM

Re: Modify url at nginx

pratyush July 30, 2018 03:20AM

Re: Modify url at nginx

Francis Daly July 30, 2018 05:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 269
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready