I need to return an error on wrong http_host header. For nginx I would write the following config:
server {
## Deny illegal Host headers
if ($host !~* ^(mydomain.com|www.mydomain.com)$ ) {
return 444;
}
location / {
proxy_pass http://app_server;
...
}
}
How can I do the same for Apache?
UPDATE
Although the trick with virtualhosts does work, I ended up with RewriteRule:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ - [L,R=400]