Forwarding Multiple port to Single port using nginx











up vote
5
down vote

favorite
2












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?










share|improve this question




























    up vote
    5
    down vote

    favorite
    2












    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?










    share|improve this question


























      up vote
      5
      down vote

      favorite
      2









      up vote
      5
      down vote

      favorite
      2






      2





      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?










      share|improve this question















      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?







      nginx reverse-proxy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 2 '15 at 11:59









      jkt123

      2,5541220




      2,5541220










      asked Apr 2 '15 at 11:38









      Hari

      148118




      148118






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          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;
          }
          }





          share|improve this answer




























            up vote
            12
            down vote













            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;
            }
            }





            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f604408%2fforwarding-multiple-port-to-single-port-using-nginx%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              5
              down vote



              accepted










              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;
              }
              }





              share|improve this answer

























                up vote
                5
                down vote



                accepted










                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;
                }
                }





                share|improve this answer























                  up vote
                  5
                  down vote



                  accepted







                  up vote
                  5
                  down vote



                  accepted






                  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;
                  }
                  }





                  share|improve this answer












                  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;
                  }
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 2 '15 at 11:56









                  jkt123

                  2,5541220




                  2,5541220
























                      up vote
                      12
                      down vote













                      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;
                      }
                      }





                      share|improve this answer



























                        up vote
                        12
                        down vote













                        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;
                        }
                        }





                        share|improve this answer

























                          up vote
                          12
                          down vote










                          up vote
                          12
                          down vote









                          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;
                          }
                          }





                          share|improve this answer














                          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;
                          }
                          }






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Apr 9 '15 at 14:27









                          jkt123

                          2,5541220




                          2,5541220










                          answered Apr 3 '15 at 6:17









                          Hari

                          148118




                          148118






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f604408%2fforwarding-multiple-port-to-single-port-using-nginx%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                              Mangá

                              Eduardo VII do Reino Unido