Search code examples
haproxy

HAProxy allow port for specific hostname value?


Is there a way to set HAProxy to listen on a specific port only if the hostname from the IP used matches a certain criteria?

The distinctin is important: My server has multiple IPs, which match a domain (www1.xxxx.com, www2.xxxx.com, etc).

I want to open port YYYY only if the domain used to connect to HAProxy is www.xxxx.com. If testing via www1.xxxx.com, that port would be refused.

Note that HAProxy is used in TCP mode, not HTTP.

Is this possible?


Solution

  • May be something like this?

    
    listen port_3306
      bind :3306
      mode tcp
      acl my-ip src 216.58.204.78
      tcp-request content accept if my-ip
      server  my-test-comms localhost:3306 check
    
    

    Attaching the documentation link, may be you can play around with those settings.

    Hope this helps.