Skip to content

Instantly share code, notes, and snippets.

@kehers
Last active October 13, 2021 17:37
Show Gist options
  • Save kehers/8f346d077f4f7d0585a1 to your computer and use it in GitHub Desktop.
Save kehers/8f346d077f4f7d0585a1 to your computer and use it in GitHub Desktop.
Simple HAProxy config to forward :80 to :3000 (for a Node app)
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
contimeout 5000
clitimeout 50000
srvtimeout 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
stats enable
stats auth someuser:somepassword
stats uri /haproxyStats
frontend http-in
bind :80
default_backend app
# is this a socket io request?
acl is_websocket path_beg /socket.io
acl is_websocket hdr(Upgrade) -i WebSocket AND hdr_beg(Host) -i ws
use_backend websocket if is_websocket
backend websocket
balance source
option forwardfor
no option httpclose
option http-server-close
option forceclose
timeout queue 5s
timeout server 24h
timeout connect 24h
server node1 localhost:3000 check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment