I am running an apache webserver and on the same host a propriatry websocket server who listens on port 8181 for incoming websocket calls.
The client is a browser, loading down a website from the apache on port 80 and the javascript inside the website opens the websocket connection to the websocket servers.
For various reasons I would now like to make the websocket call on the same port 80.
In order to route the traffic I would like to set up an HAProxy on the host who listens on the port 80. For this purpose I would change the Apache port to 8000 for instance.
HAProxy is now expected to listen on port 80 for incoming traffic and route it to port 8000 (apache) if it is http and to port 8181 if it is websocket traffic
However, I am doing hard with the configuration as I am completely novice in haproxy.
At least the websocket traffic does not get routed to the websocket server with the following configuration
Any idea, why? The configuration so far looks like
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 2000
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
option http-server-close
option forwardfor
retries 3
maxconn 2000
timeout connect 5000
timeout client 50000
timeout server 50000
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
frontend public
bind *:80
maxconn 60000
acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws
use_backend ws if is_websocket
default_backend www
backend www
timeout server 30s
server www1 127.0.0.1:8000
option http-server-close
backend ws
timeout server 600s
server ws1 127.0.0.1:8181
Best regards Wuppi