Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have found that a random domain has set its DNS records to point to my server's IP address, which is a HAProxy load balancer in front of 4 apache servers. How do I prevent HAProxy from accepting requests from this domain, and only allowing requests to the legitimate domain?

Thanks

share|improve this question
    
Can you elaborate on that? which DNS records? are you wanting to make sure that your server only responds positively to HTTP GET requests for your domain name? –  Matt Mar 5 '12 at 18:21

2 Answers 2

up vote 1 down vote accepted

In the frontend definition in your HAProxy config:

frontend bla bla bla
<other settings>

#all HTTP traffic must use the correct site name
acl host-mysite hdr(Host) -i mysite.example.com
redirect location http://mysite.example.com/ if !host-mysite

<more settings for frontend>

backend foo
<backend config>

You could also outright block it if you prefer by using:

#block if request isn't for mysite
acl host-mysite hdr(Host) -i mysite.example.com
block if !host-mysite
share|improve this answer
    
Thanks, much appreciated –  Tom Mar 5 '12 at 21:38

Filter on the value of the Host HTTP header, e.g. hdr(Host) -i myhost.example.tld.

share|improve this answer
    
In iptables, or the HAProxy config, or where? –  Tom Mar 5 '12 at 19:00
    
In the HAProxy ACLs. –  Ignacio Vazquez-Abrams Mar 5 '12 at 19:01
    
Thank you very much –  Tom Mar 5 '12 at 21:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.