# How to do port forward by domain in TCP mode?

**URL:** https://discourse.haproxy.org/t/how-to-do-port-forward-by-domain-in-tcp-mode/6209
**Category:** Help!
**Created:** [February 2, 2021, 1:44am UTC](https://discourse.haproxy.org/t/how-to-do-port-forward-by-domain-in-tcp-mode/6209 "2021-02-02T01:44:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discourse.haproxy.org/u/Terry)
#### Post date: [February 2, 2021, 1:44am UTC](https://discourse.haproxy.org/t/how-to-do-port-forward-by-domain-in-tcp-mode/6209/1 "2021-02-02T01:44:25Z")

</div>

I am using use-server to separate https with different domain requests, but sometimes it will go to wrong server with same url, but when I wrote test python script to send https request 100 times per second, It couldn’t reproduce the wrong situation. Any ideas?

Test URL:

[https://web1.abc.com:8080/](https://web1.abc.com:8080/) (sometimes a few request will go web2)

[https://web2.abc.com:8080/](https://web2.abc.com:8080/) (sometimes a few request will go web1)

`

```auto
frontend http_https_8080
  mode tcp
  bind *:8080
  tcp-request inspect-delay 30s
  tcp-request content accept if HTTP

  use_backend http_server if HTTP
  default_backend local_https_server

backend http_server
  mode tcp
  tcp-request content accept if { req_ssl_hello_type 1 }
  tcp-request inspect-delay 30s

#domain agent
  use-server web1 if { hdr_dom(Host) -i web1.abc.com }
  use-server web2 if { hdr_dom(Host) -i web2.abc.com }
  server web1 10.10.10.10:8080
  server web2 10.10.10.11:8083

frontend local_https_9443
  mode tcp
  bind *:9443 ssl crt /etc/haproxy.pem
  default_backend http_server

backend local_https_server
  mode tcp
  option ssl-hello-chk
  server localhttps localhost:9443

```

`

---

<div class="post-metadata">

### Author: ![Kerasit](https://avatars.discourse-cdn.com/v4/letter/k/7ab992/32.png) [@Kerasit](https://discourse.haproxy.org/u/Kerasit)
#### Post date: [February 3, 2021, 8:37am UTC](https://discourse.haproxy.org/t/how-to-do-port-forward-by-domain-in-tcp-mode/6209/2 "2021-02-03T08:37:03Z")

</div>

You are using TCP mode but try to use HTTP header filtering: hdr\_dom(Host).
