# Problem with ACL routing

**URL:** <https://discourse.haproxy.org/t/problem-with-acl-routing/8751>\
**Category:** Help!\
**Created:** [June 9, 2023, 2:20pm UTC](https://discourse.haproxy.org/t/problem-with-acl-routing/8751 "2023-06-09T14:20:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavlo](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@Pavlo](https://discourse.haproxy.org/u/Pavlo)\
**Post date:** [June 9, 2023, 2:20pm UTC](https://discourse.haproxy.org/t/problem-with-acl-routing/8751/1 "2023-06-09T14:20:50Z")

</div>

I created a simple config for tests.

```auto
frontend main-api
  mode http
  option httplog
  bind *:8080
  option forwardfor
  acl prod hdr(host) -i api-bcf-prod.<domain>
  acl tst hdr(host) -i api-bcf-tst.<domain>

#PROD Env
  use_backend main-api-prod if prod

#TST Env
  use_backend main-api-tst if tst

# default_backend main-api-prod

backend main-api-prod
  mode http
  option httplog
  option forwardfor
  server main-api-prod bcf-lb-prod.service.consul:80 check inter 5s rise 5 fall 5

backend main-api-tst
  mode http
  option httplog
  option forwardfor
  server main-api-tst bcf-lb-prod.service.consul:81 check inter 5s rise 5 fall 5

```

where “domain” - this is public domain  
when i trying to connect  
curl [http://api-bcf-prod](http://api-bcf-prod).“domain”:8080 or  
curl [http://api-bcf-tst](http://api-bcf-tst).“domain”:8080  
i get error -

```auto
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

```

If i set

```auto
default_backend main-api-prod

```

i can get only main-api-prod in both request’s.

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [June 9, 2023, 2:27pm UTC](https://discourse.haproxy.org/t/problem-with-acl-routing/8751/2 "2023-06-09T14:27:15Z")

</div>

If you specify a non standard port, your host header will be non-standard too.

```
$ curl -v 10.0.0.25:1880
* Trying 10.0.0.25:1880...
* Connected to 10.0.0.25 (10.0.0.25) port 1880 (#0)
> GET / HTTP/1.1
> Host: 10.0.0.25:1880
> User-Agent: curl/8.0.1
> Accept: */*

```

Include the port in the ACL statement, or use something like `-m beg` to only match the first part of the host header.

---

<div class="post-metadata">

**Author:** ![Pavlo](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@Pavlo](https://discourse.haproxy.org/u/Pavlo)\
**Post date:** [June 10, 2023, 8:50am UTC](https://discourse.haproxy.org/t/problem-with-acl-routing/8751/3 "2023-06-10T08:50:31Z")

</div>

> [@lukastribus](#):
>
> Include the port in the ACL statement, or use something like `-m beg` to only match the first part of the host header.

Great and simple! 🙂 Thanks a lot.
