Skip to content

Instantly share code, notes, and snippets.

@lackac
Created September 22, 2012 19:14
Show Gist options
  • Select an option

  • Save lackac/3767467 to your computer and use it in GitHub Desktop.

Select an option

Save lackac/3767467 to your computer and use it in GitHub Desktop.
HAProxy configuration with Websocket support
global
maxconn 4096 # Total Max Connections. This is dependent on ulimit
nbproc 2
log 127.0.0.1 local1 notice
defaults
mode http
log global
frontend all 0.0.0.0:80
timeout client 86400000
default_backend www_backend
acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws
acl host_bibliaolvaso hdr_sub(Host) -i bibliaolvaso.hu
acl host_todomvc hdr_sub(Host) -i todomvc
use_backend bibliaolvaso_backend if is_websocket host_bibliaolvaso
use_backend todomvc_backend if is_websocket host_todomvc
backend www_backend
balance roundrobin
option forwardfor # This sets X-Forwarded-For
timeout server 86400000
timeout connect 4000
server nginx localhost:81
backend bibliaolvaso_backend
balance roundrobin
option forwardfor # This sets X-Forwarded-For
timeout queue 5000
timeout server 86400000
timeout connect 5000
server bibliaolvaso localhost:7777
backend todomvc_backend
balance roundrobin
option forwardfor # This sets X-Forwarded-For
timeout queue 5000
timeout server 86400000
timeout connect 5000
server todomvc localhost:3003
@indrajeet0510
Copy link
Copy Markdown

Please put proper comments so that if would be easy to understand what configuration line is playing what role.

Copy link
Copy Markdown

ghost commented Jun 9, 2016

@ben-burlingham
Copy link
Copy Markdown

acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws

Still useful 8 years later. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment