Proxy all traffic without matching the domain names in Haproxy

1

I'm using Haproxy in my VPS for stream some video content. with my current setup I need to mention each every domain in the front-end and back-end section in my Haproxy.conf file. if I need to watch 10 channels I need to add many domains. I only use this proxy for certain streaming site not for all the web traffic. I installed Dnsmasq on my openwrt router and I can point only necessary domains to my VPS. I need to add entry only for dnsmasq and I need Haproxy to proxy all the things dnsmasq throw it. can I configure something like wildcards in Haproxy configuration? or is there any other methods

My haproxy.conf like this

# Frontend for connections over port 80/http
frontend f_sni_catchall  
    mode http
    bind 0.0.0.0:80
    log global
    option httplog
    option accept-invalid-http-request
    capture request  header Host len 50
    capture request  header User-Agent len 150

    use_backend b_sni_catchall      if { hdr(host) -i www.example.com }

    default_backend b_deadend

# Backend for handling connections over port 80/http
backend b_sni_catchall  
    log global
    mode http
    option httplog
    option http-server-close


    server www.example.com www.example.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

instead of using www.example.com I need to use something like this with the wild card

use_backend b_sni_catchall      if { hdr(host) -i *.com }

server*e.com *.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

Using full domains in the config file is not possible due to DNS resolving issue. Haproxy wont start with some domain names. Other than that I need to set DNS pointing using dnsmasq or Bind. for do that I need haproxy to configured as forward all the domains what it get from the user

gripenfighter

Posted 2017-05-16T05:35:30.910

Reputation: 157

Please post the relevant block from you haproxy config and haproxy version. – Jim G. – 2017-05-24T19:12:12.757

@JimG. please check I updated my question with the Haproxy conf file – gripenfighter – 2017-05-26T03:03:04.893

Answers

1

As was mentioned before, to be conclusive we would need to know your version, since config format has changed between versions, but heres how i do it (1.6.3)

frontend web
    bind *:80 name http

    ### Wildcard ACL ###
    acl is_wild hdr_dom(host) -i wild

    ### Wildcard Backend###
    use_backend wild if is_wild


backend wild
    cookie  WILD_HTTP insert
    server  wild 10.1.1.1:80 cookie A check

As you may see, no * needed, anything that matches (ie wild.mydomain.com, mydomain.wild.com, something.mewild.com) will be send to this acl, and then will use the desired backend mapping.

Tobias Hagenbeek

Posted 2017-05-16T05:35:30.910

Reputation: 126