Welcome! Log In Create A New Profile

Advanced

Re: Using the mirror module

Francis Daly
August 14, 2018 03:46AM
On Thu, Aug 09, 2018 at 07:04:50PM -0400, jlangr wrote:

Hi there,

> We got this working to wrap up the day.

Good that you have something working for you.

> My ignorance of nginx meant that I
> was interpreting the example literally--I viewed the "/mirror" as the name
> for the internal route, but that actually becomes part of the URL the mirror
> location proxy forwards to.

It's actually a bit more subtle than that.

The argument to the "mirror" directive is the local url of the subrequest;
it should start with "/" or "@".

Then, in the matching location{}, if you choose to proxy_pass, then the
proxy_pass rules come in to play. And it is proxy_pass that decides what
request to make to the upstream server.

http://nginx.org/r/proxy_pass

> mirror /;

That means that the subrequest will be exactly "/"...

> location = / {

....which will be handled in this location...

> set $upstream_endpoint http://1.2.3.4:3002;
> proxy_pass $upstream_endpoint$request_uri;

....and the proxy_pass argument includes something after the host:port,
so that is what the request to upstream will be.

An alternative could have been to use a named location -- "mirror
@mirror;", with "location @mirror { proxy_pass http://1.2.3.4:3002; }"
-- which would avoid the need for some of the extra variables.


But, once you have something that works, there is no need to change it :-)

Cheers,

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

Using the mirror module

Kenny Meyer March 13, 2018 04:40PM

Re: Using the mirror module

Roman Arutyunyan March 13, 2018 05:36PM

Re: Using the mirror module

Kenny Meyer March 13, 2018 06:06PM

Re: Using the mirror module

pbooth March 13, 2018 06:32PM

Re: Using the mirror module

Roman Arutyunyan March 13, 2018 06:38PM

Re: Using the mirror module

Kenny Meyer March 14, 2018 07:58AM

Re: Using the mirror module

Roman Arutyunyan March 14, 2018 08:34AM

Re: Using the mirror module

pbooth March 14, 2018 08:32AM

Re: Using the mirror module

jlangr August 09, 2018 03:14PM

Re: Using the mirror module

jlangr August 09, 2018 05:08PM

Re: Using the mirror module

Francis Daly August 09, 2018 06:30PM

Re: Using the mirror module

jlangr August 09, 2018 07:04PM

Re: Using the mirror module

jlangr August 09, 2018 07:05PM

Re: Using the mirror module

Francis Daly August 14, 2018 03:46AM

Re: Using the mirror module

jlangr August 14, 2018 10:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 188
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