Nginx reverse proxy an IP address field

if an IP address starts at 11.119.0.10-ends at 11.119.0.254
, the outside cannot be accessed, so you need to do a reverse proxy in nginx. The virtual machine started is like taking an IP, port at random in this range.
if it is to write an agent, one is too troublesome, is there any easy way

?
Mar.20,2021

you may need to use geo_module , refer to the answer stackoverflow , and then your configuration may be as follows:

geo $upstream  {
    default default_upstream;

    10.50.0.0/16 some_upstream;
    10.51.0.0/16 another_upstream;
}

upstream default_upstream {
    server 192.168.0.1:80;
}

upstream some_upstream {
    server 192.168.0.2:80;
}

upstream another_upstream {
    server 192.168.0.3:80;
}

server {
    ...
    location ... {
        ...
        proxy_pass http://$upstream;
    }
    ...
}
Menu