Problem with ACL routing

I created a simple config for tests.

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.“domain”:8080 or
curl http://api-bcf-tst.“domain”:8080
i get error -

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

If i set

default_backend main-api-prod

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

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.

Great and simple! :slight_smile: Thanks a lot.