yaoweibin / nginx_tcp_proxy_module

add the feature of tcp proxy with nginx, with health check and status monitor
http://yaoweibin.github.com/nginx_tcp_proxy_module
1.64k stars 365 forks source link

host not found in upstream "chat1" #32

Open rmalenko opened 12 years ago

rmalenko commented 12 years ago

Hi! Could you help me?

I have got error message nginx: [emerg] host not found in upstream "chat1" in /etc/nginx/sites-enabled/chat.bartermill.com:23

I have put into nginx.conf at the and of file below http {}

tcp { upstream chat1 { server 127.0.0.1:8001; check interval=3000 rise=2 fall=5 timeout=1000; } }

and put into chat.bartermill.com (virtual server)

server { listen chat.bartermill.com:80; error_log /var/www/logs/chat-nginx-error.log warn; location /websocket_status { check_status; }

location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://chat1;
            }
    }

Version nginx-1.0.14

Regards, Rostyslav

yaoweibin commented 12 years ago

Hi

The upstream used in tcp block can't be accessed by server in http block.

If you want to use websocket, you can't use the nginx http block and its feature.

On 2012/3/22 15:43, rmalenko wrote:

Hi! Could you help me?

I have got error message nginx: [emerg] host not found in upstream "chat1" in /etc/nginx/sites-enabled/chat.bartermill.com:23

I have put into nginx.conf at the and of file below http {}

tcp { upstream chat1 { server 127.0.0.1:8001; check interval=3000 rise=2 fall=5 timeout=1000; } }

and put into chat.bartermill.com (virtual server)

server { listen chat.bartermill.com:80; error_log /var/www/logs/chat-nginx-error.log warn; location /websocket_status { check_status; }

 location / {
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header Host $http_host;
       proxy_redirect off;
       proxy_pass http://chat1;
             }
     }

Version nginx-1.0.14

Regards, Rostyslav


Reply to this email directly or view it on GitHub: https://github.com/yaoweibin/nginx_tcp_proxy_module/issues/32

rmalenko commented 12 years ago

Thanks! I need your help, please. Because you created unique module.

But if I put in tcp block

tcp { timeout 1d; upstream chat1 { server 127.0.0.1:8001; check interval=3000 rise=2 fall=5 timeout=1000; }

server { listen 80; server_name chat.bartermill.com; websocket_pass chat1; } }

I have got error message [emerg] unknown directive "websocket_pass"

proxy_pass instead websocket_pass test passed

And major problem is chat.bartermill.com should be on 80 port. With this config Nginx can't start because of:

Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

These derective must be in http {} listen 80; server_name chat.bartermill.com;

Regards, Rostyslav

yaoweibin commented 12 years ago

Yes, you are right. If you want to use websocket in nginx, you should use another port for websocket. It must different with the http port.

Thanks. On 2012/3/22 16:25, rmalenko wrote:

Thanks! I need your help, please. Because you created unique module.

But if I put in tcp block

     timeout 1d;

# websocket_read_timeout 1d;

upstream chat1 { server 127.0.0.1:8001; check interval=3000 rise=2 fall=5 timeout=1000; }



server {
     listen 80;
     server_name chat.bartermill.com;
     websocket_pass chat1;
        }
}```

I have got error message
[emerg] unknown directive "websocket_pass"

**proxy_pass** instead **websocket_pass** test passed

And major problem is chat.bartermill.com should be on 80 port. With this config Nginx can't start because of:

_Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)_

These derective must be in http {}
`listen 80;
server_name chat.bartermill.com;`

---

Reply to this email directly or view it on GitHub:
https://github.com/yaoweibin/nginx_tcp_proxy_module/issues/32#issuecomment-4634287
rmalenko commented 12 years ago

Are you going to make possibility to use 80 port in future? Our push server integrated in many places in pages and when angry administrator have opened only port 80 by corporate rules some of people will not able to use our web services.

Regards, Rostyslav

yaoweibin commented 12 years ago

Sorry, There is no such plan yet.

On 2012/3/22 16:44, rmalenko wrote:

Are you going to make possibility to use 80 port in future? Our push server integrated in many places in pages and when angry administrator have opened only port 80 by corporate rules some of people will not able to use our web services.

Regards, Rostyslav


Reply to this email directly or view it on GitHub: https://github.com/yaoweibin/nginx_tcp_proxy_module/issues/32#issuecomment-4634486

nileshadiyecha commented 8 years ago

I am getting the "nginx: [emerg] host not found in upstream "node1" in /etc/nginx/conf.d/proxy.conf:4 ". Below is the nginx configuration file for the reference.

upstream backend { server node1; server node2; }

server { listen 80; server_name localhost;

location / {
    proxy_pass http://backend;
    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_set_header X-Forwarded-Proto $scheme;
}

}

can anyone guide me to resolve above issue.