Welcome! Log In Create A New Profile

Advanced

Re: Use sub-url to identify the different server

Francis Daly
January 24, 2019 04:00AM
On Sun, Jan 20, 2019 at 10:13:05PM -0500, nevereturn01 wrote:

Hi there,

> Now, we are running a small business. So we don't have any load-balance or
> fail-over deployment. So far, we have only 1 Nginx + 1 serverA + 1 serverB.

So - you have internal serverA, which has its own content at
https://serverA/. You have external nginx, and you want to reverse-proxy
serverA behind the url https://nginx/A/. You also have internal serverB,
which should be reverse-proxied behind https://nginx/B/.

And you can test whether this works by pointing a web browser at
https://nginx/A/something, and seeing if you get the same result as when
you point a web browser at https://serverA/something.

For reasons of simplicity, it is often easier to test this by using the
command-line tool "curl" instead of a "full" web browser. You will need
to know what response you expect to get, before you can know whether
the response that you get is correct.

> As for the rewrite, I did some research and found that it seems that only
> URL rewrite can help in my scenario. Technically, do you think the URL
> rewrite rules is correct? Maybe there are some syntax errors?

As far as I know, the nginx-way to do what you want is

location /A/ { proxy_pass https://serverA/; }

I do not know if you have tried that and seen that it does or does not
work for you.

You have tried a different configuration, something like

location /A {
rewrite ^/A/(.*) /$1 break;
proxy_pass https://serverA;
}

and have done an unspecified test and got a http 404 response that was
not what you expected.

I think that the rewrite config is probably not correct; I would expect
it to start with "location /A/". The extra / characters and the like do
matter here.

Only you can test your system.

When you have one specific configuration in place, issue one request and
look at the response. If things work the way you want, all is good. If
something does not work, report the one specific request that does not
work; report the response that the request does get; and indicate the
response that you want that request to get instead.


Note also, that if the http response body (the html content) from
https://serverA/something includes a direct link to /other, then the end
client will probably make a request for https://nginx/other, which will
not do what you want.

It is not nginx's job to edit the response body to change a link to /other
into a link to /A/other. Instead, if serverA wants to be reverse-proxied
to a sub-url, it is serverA-and-the-author's job to ensure that the
response body contains a link to "other" or to "../other", as appropriate.

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

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: 107
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