0

I'm hoping someone can help me with this. I'm looking to proxy pass something like this:

http://storage.domainname.com:port

to this:

http://192.168.12.10:port

My problem is that the port is dynamic, and it's not feasible for me to write dozens of location blocks for it.

This is my conf (I'm using port 61788 for testing):

server {
    listen 61788;

    server_name storage.*;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        set $upstream_app 192.168.12.10;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:61788;
    }
}

I don't think using location regex is applicable here, as the port is specified in the host. I've tried using $remote_host in proxy_pass, but that gave me a bad gateway error. Does anyone have any ideas?

2
  • The port number that received the original request should be $server_port. Jun 4, 2021 at 13:28
  • Awesome, thank you so much for your help!
    – Anthony Ma
    Jun 4, 2021 at 13:31

1 Answer 1

0

Turns out I need to use $server_port instead or $remote_port!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .