Disclaimer:
I have opened a similar question of stack overflow before realize that stack overflow is mean to code questions...
My problem:
I am trying to access a a web service connected to my nginx server over a ssh tunnel. It works perfectly if I ssh the server, and curl the tunnel port. My next step would be to do a proxy_pass on my nginx configuration to allow us to access that service given the port. I tough I had nailed it using the following configuration:
location ~ ^/test/([0-9]+)/ {
#allow our.ip/32;
proxy_pass http://127.0.0.1:$1/;
}
When the index load, it try to redirect to a page named login.php (which exists, and I can reach it by using curl localhost:port/login.php). After some research, I came up with the solution of remove the slashes from both the location and proxy_pass, making it look like this:
location ~ ^/test/([0-9]+) {
#allow our.ip/32;
proxy_pass http://127.0.0.1:$1;
}
This is pretty much what you find in most of the examples, BUT IT DON'T WORK. It just 502 and I can't figure out why.
EDIT
This is the nginx error log from the request:
2021/01/11 14:21:49 [error] 88542#88542: *19093 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: my.server.address, request: "GET /test/1480/ HTTP/2.0", upstream: "http://127.0.0.1:1480/test/1480/", host: "my.server.address"
It should not pass the "/test/" to the remote host...