Mobile app version of vmapp.org
Login or Join
Lee4591628

: How to set up a single IP blocklist for multiple sites hosted on the same account When running multiple sites on the same hosting account, one might find that an attacker has attempted to

@Lee4591628

Posted in: #Apache #Apache2 #Htaccess #IpAddress #Security

When running multiple sites on the same hosting account, one might find that an attacker has attempted to breach one site. A webmaster may want to block the IP address from all sites hosted in the same account.

Is there a way to keep the list of banned IP addresses/ranges in a single location that can be referenced by all the websites in the same account?

(Example: a file that contains a list of IP addresses/ranges located at the root of the file system and simply referenced in the .htaccess file of each website.)

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Lee4591628

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

The more efficient way to blacklist IP addresses is to use your operating system's firewall, or by using a module coded specifically for this purpose, like ModSecurity.

If you don't have access to your OS and cannot add modules, then you could edit your Apache configuration file with the following (to block the example IP address 111.222.33.444):

<Location />
<Limit GET POST PUT>
order allow,deny
allow from all
deny from 111.222.33.444
</Limit>
</Location>


Then restart Apache. As covered here, that should work for all your virtual hosts.

Alternatively, you can try to use the include directive for each virtual host config as covered here (use deny from for each IP to block instead of allow from).

Lastly, if you do not have access to either your OS's firewall, server modules, or server configuration files (as might be the case with a shared web hosting account), you could use a server-side script like Perl to copy the IP's from a central file into each .htaccess file, and schedule this as a cron job so that each virtual host will share the same list of IP's to blacklist/block.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme