Thursday, 15 March 2012

node.js - Nginx + Express + Socket.IO workarounds -



node.js - Nginx + Express + Socket.IO workarounds -

as know @ time nginx stable version can't proxy tcp connections. if express , socket.io work on same port need utilize other proxy solution.

but there other ways bypass problem:

what if set socket.io hear different port, express listens. example: nginx proxies 80 port 8000 port, express listens on 8000 port, socket.io listens 8001 port , client connects socket.io straight 8001 port. using nginx_tcp_proxy_module can proxy tcp connections, can't utilize http on same port. utilize such solution: nginx proxies 80 port 8000 port , 81 port (for websockets) 8001, express listens on 8000 port, socket.io listens on 8001 port , client connects socket.io 81 port.

what advantages , disadvantages these approaches have?

i prefer utilize haproxy in front end , have 1 public open port. "rooting" done per path.

the config looks (you can find many tutorials/resources)

frontend 0.0.0.0:80 acl is_websocket path_beg /websocket/ use_backend nodejs if is_websocket default_backend nginx backend nodejs server srv_node 127.0.0.1:16852 backend nginx balance roundrobin server srv_static 127.0.0.1:8080

node.js nginx express socket.io

No comments:

Post a Comment