Docker Community Forums

Share and learn in the Docker community.

Dockercloud-haproxy virtual host path


(Slowie) #1

When setting the “VIRTUAL_HOST=*/api” haproxy does not redirect to that service. If I set the “” or “VIRTUAL_HOST=*” that works fine. Below are the acl rules that are being set. Any help would be greatly aprreciated

frontend port_80
bind :80
reqadd X-Forwarded-Proto:\ http
maxconn 4096
acl is_websocket hdr(Upgrade) -i WebSocket
acl host_rule_1 hdr_reg(host) -i ^.$
acl host_rule_1_port hdr_reg(host) -i ^.
acl path_rule_1 path -i /api
use_backend SERVICE_SIMPLE_SERVER if path_rule_1 host_rule_1 or path_rule_1 host_rule_1_port

(Andrew) #2

I didn’t think you could put the wildcard in there with other elements. It is either a wildcard or not a wildcard.

Here is the lines in the source code:

            if "*" in host:
                  host_rules.append("acl host_rule_%d hdr_reg(host) -i ^%s$" % (
                      rule_counter, host.replace(".", "\.").replace("*", ".*")))
                  host_rules.append("acl host_rule_%d_port hdr_reg(host) -i ^%s:%s$" % (

You may be able to write your own frontend commands to do what you are after.

I could be wrong with this, I am still learning about HAPROXY’s features.