Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server running Apache that often gets unwanted proxy requests, mostly for sites like or I don't have mod_proxy loaded, so these requests don't actually work. But what happens is that the content returned corresponds to the home page for my website, presumably because that's the default virtual host. The thing is, I'd rather not send back the full index page to someone who obviously isn't actually interested in my website; I consider it a waste of bandwidth and resources. I'd rather respond with an HTTP error code (400 I suppose) to signal that my server does not work as a proxy, and also to make myself feel better when I examine the access logs ;-)

What's the recommended way to configure Apache to return an error code for a proxy request? (By "proxy request" I mean one that provides an absolute URL in the HTTP request line.) And which HTTP error code is most appropriate for this?

By the way, I thought this would have been asked already but I looked and didn't find it.

share|improve this question
up vote 2 down vote accepted

You could simply configure a default vhost that denies all request:

<VirtualHost *:80>
  ServerName deny.all
  <Location />
    Order allow,deny
    Deny from all

With that in place, all requests accessing a vhost that is not explicitly configure will be denied with HTTP error code 403 ("Forbidden").

Also be sure to have a look at the Apache wiki page on proxy abuse for more details. Beyond the solution above, they will also give you hints for a mod_rewrite-based solution.

share|improve this answer
simple but helpfull advice – Froggiz Oct 26 '15 at 13:44

Your Answer


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.