Forward data from orginal IP to a new IP

I have this configure file, but it is long-winded。
in nginx, are there having one expression to handle it

server {
listen 192.168.1.2:10000;
proxy_pass 192.168.0.3:10000;
}

server {
    listen     192.168.1.2:10001;
    proxy_pass  192.168.0.3:10001;
}

server {
    listen     192.168.1.2:10002;
    proxy_pass  192.168.0.3:10002;
}

server {
    listen     192.168.1.2:10003;
    proxy_pass  192.168.0.3:10003;
}

server {
    listen     192.168.1.2:10004;
    proxy_pass  192.168.0.3:10004;
}

server {
    listen     192.168.1.2:10005;
    proxy_pass  192.168.0.3:10005;
}

server {
    listen     192.168.1.2:10006;
    proxy_pass  192.168.0.3:10006;
}

server {
    listen     192.168.1.2:10007;
    proxy_pass  192.168.0.3:10007;
}

server {
    listen     192.168.1.2:10008;
    proxy_pass  192.168.0.3:10008;
}

server {
    listen     192.168.1.2:10009;
    proxy_pass  192.168.0.3:10009;
}

server {
    listen     192.168.1.2:10010;
    proxy_pass  192.168.0.4:10010;
}

server {
    listen     192.168.1.2:10011;
    proxy_pass  192.168.0.4:10011;
}

server {
    listen     192.168.1.2:10012;
    proxy_pass  192.168.0.4:10012;
}

server {
    listen     192.168.1.2:10013;
    proxy_pass  192.168.0.4:10013;
}

server {
    listen     192.168.1.2:10014;
    proxy_pass  192.168.0.4:10014;
}

server {
    listen     192.168.1.2:10015;
    proxy_pass  192.168.0.4:10015;
}

server {
    listen     192.168.1.2:10016;
    proxy_pass  192.168.0.4:10016;
}

server {
    listen     192.168.1.2:10017;
    proxy_pass  192.168.0.4:10017;
}

server {
    listen     192.168.1.2:10018;
    proxy_pass  192.168.0.4:10018;
}

server {
    listen     192.168.1.2:10019;
    proxy_pass  192.168.0.4:10019;
}

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

It seems the lock lies in the fact there is no generic way for the
listen
directive to specify multiple ports, so you are stuck with that much
server
blocks.

Now, you could use the $server_port variable in the proxy_pass
directive,
but that brings no real improvement.

You could use configuration management tools to template configuration
generation, relieving you of the burden of maintaing all those blocks by
hand.

B. R.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs