HAProxy and other hosted sites on the same IP
-
Hello,
I've setup HAPROXY to serve several websites on port 80 on the same machine.
The configuration is the following:and the backend config:
OK, so when accessing http://lookingglass.xxxxx.net, everything works fine.
Also HAPROXY logs show everything is fine:The problems I face are:
- If I access the WAN's IP I will get to the exact same page as http://lookingglass.xxxx.net, even if I don't use a hostname
- If I try to host another site on port 80 and use the same HAProxy setup scenario, I will still get presented with the same page as http://lookingglass.xxxx.net
Any ideas what can be the cause and how can I fix this behavior?
Thanks.
-
Not sure if you figured it out already since this post is a few days old, but I think you need to do two things:
- Remove your "Default Backend" entry (if you have a default entry, everything will be sent to that backend, regardless of the ACL you defined above)
- For the "Use Backend" action, you wanna populate the "Condition Acl Name" field or else the action wont match.
So in your case, set the "condition acl name" to "LookingGlass" (the name you gave your "Host Matches:" ACL)
You now should get a 503 error for all other requests until you define another acl that matches the host name and send that to the same (or a different) backend via another "Use Backend" action entry.
Hope this helps. Still a beginner with ha proxy so not sure if this is the way to go, but for me in a similar situation that was what I had to do.