Forum: NGINX Fwd: NGINX config for websocket HA failover

5af0270229f9cdcf4eed647612e9ec64?d=identicon&s=25 Hari Poludasu (Guest)
on 2014-05-26 14:21
(Received via mailing list)
Hi,



I would like to use NGINX for failover in my HA setup. I have two VMs
running in Active-Active mode and listening on 9080 port for WebSocket
connections from clients. I would like to use NGINX to route all
websocket
traffic to route to VM1 and must route to VM2 only on failure of VM1.

NGINX is running on my windows, If I use the following config, is it
enough?

http {

upstream web_rack {

server vm1:9080;

server vm2:9080;

}

server {

listen 80;

server_name localhost;

location / {

proxy_pass http://web_rack;

proxy_http_version 1.1;

proxy_set_header Upgrade websocket;

proxy_set_header Connection upgrade;

}

}

}

What changes I need to do in config to add the failover mechanism to
allow
NGINX to route websocket traffic to vm2 only on vm1 failure?



Thanks and regards,

Hari
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-05-26 14:25
(Received via mailing list)
Hello!

On Mon, May 26, 2014 at 05:51:11PM +0530, Hari Poludasu wrote:

>
> http {
>
> upstream web_rack {
>
> server vm1:9080;
>
> server vm2:9080;
>
> }

[...]

> What changes I need to do in config to add the failover mechanism to allow
> NGINX to route websocket traffic to vm2 only on vm1 failure?

Use the "backup" flag on vm2, see here for details:

http://nginx.org/en/docs/http/ngx_http_upstream_mo...

--
Maxim Dounin
http://nginx.org/
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.