Can I configure NGiNX as a proxy for another server in the local network?

0

I have two servers, one with a public ip and the other with a local ip within the same network. The server with public ip has NGiNX configured as a reverse proxy of some apps. The server with local ip has an application running on port 5000, something like: 192.168.1.244:5000 , my question is if I can use the server with NGINX to output the application already mentioned.

I currently have a configuration like this:

server {

 listen 80;
 server_name mi.dominio.com;

 location / {
  proxy_pass http://192.168.1.244:5000/$uri$is_args$args;
  proxy_set_header Host $host:$server_port;
 }

}

And it does not work.

It should be noted that I also tried to do something simpler such as redirecting it to port 80

server {

 listen 80;
 server_name mi.dominio.com;

 location / {
  proxy_pass http://192.168.1.244;
  proxy_set_header Host $host:$server_port;
 }

}

And that did work.

    
asked by Roberto Robles Rodriguez 19.10.2017 в 09:46
source

1 answer

1

You can configure the nginx like this.

server {
          listen 80;
          server_name mi.dominio.com;
          
  
          location / {
              proxy_redirect          off;
              proxy_set_header        Host            $host;
              proxy_set_header        X-Real-IP       $remote_addr;
              proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_connect_timeout   180;
              proxy_send_timeout      180;
              proxy_read_timeout      180;
              proxy_buffers           32 4k
              proxy_pass http://192.168.1.244:5000;

          }
      }
    
answered by 19.10.2017 / 15:10
source