0

I have hosted my domain in a Shared IP hosting platform. I have configured HAProxy on Google Compute Engine to route the traffic through. But When I tried to access the HAProxy server IP, I'm getting my shared hosting platform default page (Like CPanel default page when we tried to access the site via IP address.)

Here is the additional configuration I have added in HAProxy config:

resolvers public-dns
  nameserver dns1 4.4.4.4:53
  nameserver dns2 8.8.8.8:53

frontend http
  bind *:80
  stats uri /haproxy?stats
  default_backend site-backend

backend site-backend
    mode http
    balance roundrobin
    option httpclose
    option forwardfor
    reqadd Host:\ app.domain_name.com
    server mysite app.domain_name.com:80 resolvers public-dns check inter 1000 resolve-prefer ipv4

How do I get my correct website using HAProxy ?

Rookie
  • 101
  • 2

1 Answers1

1

HAProxy is connecting to app.domain_name.com (BTW be sure to set up a Resolvers block for this as HAProxy does not normally re-lookup the resolution), but sending the original request through verbatim. This is missing the Host header that your provider is using to differentiate the requests.

The HAProxy Documentation describes using the reqadd configuration to have HAProxy bolt on a Host header:

reqadd      Host:\ app.domain_name.com

Please also look at the the resolvers section to make sure you handle DNS resolution of app.domain_name.com properly as otherwise it may unexpectedly break when the provider shuffles their IPs around.

Jason Martin
  • 5,023
  • 17
  • 24