I have 2 servers: server-1 and server-2, and they both have nginx 1.16 installed on them.
On the server-1 nginx.conf I configured:
listen 80;
location / {
mirror /mirror;
proxy_pass http://server-1:8080;
}
location /mirror {
proxy_pass http://server-2:80;
}
And on the server-2 nginx.conf I configured:
listen 80;
location / {
proxy_pass http://server-2:8080;
}
Now, When Im sending a request to server-1 Im expecting it to be forwarded with the correct path to server-2, but for some reason it sends the request but not with the correct path, but with the path /mirror.
I searched online and find this thread:
Nginx mirror not forwarding to mirror link
When they said Im “have to add the $request_uri to the proxy_pass to send the full URI to the second, mirrored backend.”
So I did, now my server-1 nginx.conf is:
listen 80;
location / {
mirror /mirror;
proxy_pass http://server-1:8080;
}
location /mirror {
proxy_pass http://server-2:80$request_uri;
}
And now, when I check server-2 logs, Im not getting any logs…
Where am I going wrong here?