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.