6

I want to proxy pass all requests coming from a series of ports into single port. I am able to proxy pass a single port to another like so:

server {
    listen 3333;
    server_name test.in *.test.in;

    location / {
        proxy_pass  http://10.1.1.2:5479/;
        include /etc/nginx/proxy_params;
    }
}

So when I try test.in:3333 it redirects to 10.1.1.2:5479.

In the same way I need to proxy pass these:

test.in 4440 to 10.1.1.2:5479
test.in 4441 to 10.1.1.2:5479  
test.in 4442 to 10.1.1.2:5479   

How can I do this?

jkt123
  • 3,600
Hari
  • 303
  • 1
  • 2
  • 8

2 Answers2

14

It's also working...

server {
    listen 4442;
    listen 4441;
    listen 4443;
    listen 4444;

    location / {
        proxy_pass  http://10.1.1.2:5479/;
        include /etc/nginx/proxy_params;
    }
}
jkt123
  • 3,600
Hari
  • 303
  • 1
  • 2
  • 8
6

You should be able to do this by setting up multiple server blocks, similar to the one in your example, listening on the different ports (4440, 4441, and 4442) and having an identical proxy_pass configuration section.

For example:

server {
    listen 4440;

    location / {
        proxy_pass  http://10.1.1.2:5479/;
        include /etc/nginx/proxy_params;
    }
}
server {
    listen 4441;

    location / {
        proxy_pass  http://10.1.1.2:5479/;
        include /etc/nginx/proxy_params;
    }
}
server {
    listen 4442;

    location / {
        proxy_pass  http://10.1.1.2:5479/;
        include /etc/nginx/proxy_params;
    }
}
jkt123
  • 3,600