# Web socket in http mode

**URL:** <https://discourse.haproxy.org/t/web-socket-in-http-mode/11893>\
**Category:** Help!\
**Created:** [July 2, 2025, 5:44pm UTC](https://discourse.haproxy.org/t/web-socket-in-http-mode/11893 "2025-07-02T17:44:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![k.zelenin](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@k.zelenin](https://discourse.haproxy.org/u/k.zelenin)\
**Post date:** [July 2, 2025, 5:44pm UTC](https://discourse.haproxy.org/t/web-socket-in-http-mode/11893/1 "2025-07-02T17:44:11Z")

</div>

I’m trying to set up proxy in http mode using haproxy. The problem with tcp is that I need to read headers. So what I’m doing wrong? I was tried so many times with different configurations, but it just no working. (Nginx in that case works ok)

p.s. is reverse-proxied servers which available by subdomain

So I would be glad to get any advices with that problem

```auto
global
    log stdout format raw daemon debug

defaults
    log global
    option dontlognull
    timeout connect 5s
    timeout client 30s
    timeout server 30s

frontend ws_front
    bind *:8000
    mode http

    http-request set-var(req.cleaned_host) hdr(host)

    http-request set-var(req.cleaned_host) var(req.cleaned_host),regsub(^.*://,)

    http-request set-var(req.cleaned_host) var(req.cleaned_host),regsub(:.*$,)

    http-request set-var(txn.backend_host) var(req.cleaned_host),map(/etc/haproxy/servers_map.txt)

    acl is_proxy1 var(txn.backend_host) -m dom proxy1
    acl is_proxy2 var(txn.backend_host) -m dom old

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

    use_backend nginx_ws_proxy if is_proxy1
    use_backend nginx_ws_old if is_proxy2

backend nginx_ws_proxy
    mode http
    http-request set-header Host <subdomain><domain>
    option forwardfor # This sets X-Forwarded-For
    timeout queue 5000
    timeout server 5000
    timeout connect 5000

    server nginx_srv <ip1>:8000 ssl verify none

backend nginx_ws_old
    mode http
    
    server nginx_srv <ip2>:8002 ssl verify none

```
