Francis Daly
January 14, 2019 09:08AM
On Sun, Jan 13, 2019 at 10:18:06PM -0500, nevereturn01 wrote:

Hi there,

> Since I'm not in the website develop team, I cannot let them change the url
> structure:(

That's a shame.

Whether is easy (or even possible) to reverse-proxy the "site1" content
at a different part of the url hierarchy is almost entirely down to the
"site1" content.

> Now, I'm tring to use URL rewrite.
> I've tried the following:
> ==============================
> location /site1 {
> rewrite ^/site1/(.*) /$1 break;
> proxy_pass https://10.1.1.1;
> ==============================
> However, it didn't work and I got a Http 404 error.

What one request did you make of nginx?

What request did nginx make of the upstream server?

What response came back?

It is usually useful to test using "curl" rather than a full web browser,
because it hides less from you.

> If URL rewrite can help in this scenario, is there anything wrong with my
> rewrite rule?

You got a 404.

I had suggested config without rewrite. Does that one help at all?

(The main difference, I think, between rewrite and no-rewrite configs
here, is the effective proxy_redirect config that applies. If you ask
nginx for /site1/dir, nginx should ask upstream for /dir, and upstream
will probably return 301 with a redirect to /dir/. With your config,
your browser will get a redirect to /dir/, to which nginx will probably
return 404. With my config, your browser should get a redirect to
/site1/dir/, which has a chance of working.)

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

Use sub-url to identify the different server

nevereturn01 January 10, 2019 02:54AM

Re: Use sub-url to identify the different server

Francis Daly January 10, 2019 06:50PM

Re: Use sub-url to identify the different server

nevereturn01 January 13, 2019 10:18PM

Re: Use sub-url to identify the different server

Francis Daly January 14, 2019 09:08AM

Re: Use sub-url to identify the different server

nevereturn01 January 20, 2019 10:13PM

Re: Use sub-url to identify the different server

Francis Daly January 24, 2019 04:00AM

Re: Use sub-url to identify the different server

nevereturn01 February 10, 2019 10:21PM

Re: Use sub-url to identify the different server

Francis Daly February 11, 2019 05:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 95
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready