logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: mod_evasive question
Author
sambache



Joined: 11 Feb 2014
Posts: 19
Location: Canada, Yorkton, Sk

PostPosted: Thu 26 Nov '26 5:32    Post subject: mod_evasive question Reply with quote

running Apache with some vhosts directly and a few vhosts as reverse proxy for some domains I am not sure where to place the mod_evasive configuration.

Is it ok to place the mod_evasive configuration in httpd.conf or is it better to place it in each vhost?

Also, if placing it in the vhost of the reverse proxy domain, is mod_evasive applied or is this only applied to vhosts hosted on Apache?

This is all new to me and I am a bit lost here.
A bit of advise would help a lot.

Thank you
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 478
Location: UK

PostPosted: Sat 28 Nov '26 22:19    Post subject: Reply with quote

Nobody's chosen to reply to this request to date, so...

I've no personal experience of using mod_evasive in anger, but regarding your concerns, the module documentation provides guidance.

Notably, mod_evasive operates on a connection basis, so assuming your vhosts are all listening on the same port, then a global level configuration would be appropriate, rather than duplicating settings in each <VirtualHost>.

There are two reasons:

1. mod_evasive is designed to detect and mitigate request patterns from a given client (such as repeated requests or excessive concurrent requests).
2. With multiple virtual hosts, you generally want consistent protection across all hosted sites, rather than independent per-vhost policies.

There is an important distinction between Apache's global configuration scope and how mod_evasive actually tracks requests. The documentation (README.md) explicitly supports both approaches:

- Global configuration enables it across all virtual hosts.
- Configuration inside a <VirtualHost> enables it selectively for that vhost.

These are the recommended defaults for the Apache configuration, outside all vhost sections:
Code:
<IfModule mod_evasive24.c>
    DOSEnabled On
    DOSHashTableSize 3097
    DOSPageCount 2
    DOSSiteCount 50
    DOSPageInterval 1
    DOSSiteInterval 1
    DOSBlockingPeriod 10
</IfModule>

If necessary, adjust the thresholds to suit your traffic.

One important consideration relating to reverse proxies, which is arguably more important than the global-versus-vhost question.

If Apache sits behind a reverse proxy or load balancer, make sure it sees the actual client IP address rather than the proxy's IP address.

Otherwise, mod_evasive will see all incoming requests as originating from the same proxy IP and potentially block legitimate users together.

If you're using mod_remoteip, check your configuration and ensure that:

- RemoteIPHeader is configured for the header supplied by your trusted proxy.
- RemoteIPTrustedProxy or RemoteIPInternalProxy identifies trusted proxy addresses.
- The proxy overwrites the client-IP header rather than trusting arbitrary incoming values.

My view: Use global mod_evasive configuration, with correctly configured client-IP handling. This gives you consistent protection across all your vhosts without maintaining duplicate configurations.
Back to top


Reply to topic   Topic: mod_evasive question View previous topic :: View next topic
Post new topic   Forum Index -> Apache