Using the mirror module

jlangr nginx-forum at forum.nginx.org
Thu Aug 9 23:04:50 UTC 2018


Hi Francis--

We got this working to wrap up the day. 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.

http {
    server {
        listen 3333;
        server_name localhost;

        location / {
            mirror /;
            resolver 8.8.8.8;   # I shouldn't need this, will test tomorrow
            proxy_pass http://1.2.3.4:3001;
        }

        location = / {
            internal;
            resolver 8.8.8.8;
            set $upstream_endpoint http://1.2.3.4:3002;
            proxy_pass $upstream_endpoint$request_uri;
        }
    }
}

That works like a champ. Initially I was trying to use localhost as the
proxy_pass destination, and had turned on port forwarding at my router, but
for whatever reason that was having troubles.

Many thanks in any case!

Jeff

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279036,280832#msg-280832



More information about the nginx mailing list