user3357914
user3357914

Reputation: 1

Move nginx to different server

I'm running a node app and nginx 1.8.0. on the same server. Nginx routes requests using

server_name subdom.domain.com;

           location / {
           proxy_pass http://127.0.0.1:3000;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection 'upgrade';
           proxy_set_header Host      $host;
           proxy_set_header X-Forwarded-For $remote_addr;
   }

Everything works perfectly fine. I now want to put my nginx on a different server changing the configuration to:

server_name subdom.domain.com;

               location / {
               proxy_pass http://<ipofthenewserver>:3000;
               proxy_http_version 1.1;
               proxy_set_header Upgrade $http_upgrade;
               proxy_set_header Connection 'upgrade';
               proxy_set_header Host      $host;
               proxy_set_header X-Forwarded-For $remote_addr;
       }

All I get is "504 Gateway Time-out".

Upvotes: 0

Views: 2723

Answers (2)

Vlad Churakov
Vlad Churakov

Reputation: 348

If connection had been refused by the back-end server, you would have got "502 Bad Gateway" error.

There are several methods to check it:

  1. Look what happens on the new nginx server: tcpdump -i <name_of_iface> tcp and host <ip_of_be_server> and port 3000 -A
  2. Make requests using curl from the new nginx server to back-end server
  3. Look what happens on the back-end server using tcpdump

and so on

Upvotes: 1

Thanh Nguyen Van
Thanh Nguyen Van

Reputation: 11822

I just re-read your topic, you have to configure nginx in new server

  http://ipoftheoldserver:3000

Not:

  http://ipofthenewserver:3000

and Make sure port application 3000(in old server) is open in over the world.

Upvotes: 1

Related Questions