Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

blacklist ips with apache conf (instead of .htaccess)

setup/enable ip blacklist (only once!)

  • edit apache conf to use blacklist using command /etc/apache2/apache2.conf. add the following lines:
    # Block ip addresses in our ipblacklist.conf file
    <Location />
          Require all granted
          Include /etc/apache2/ipblacklist.conf

add to existing blacklist (as needed)

  • create/edit blacklist file using the command sudo nano /etc/apache2/ipblacklist.conf. for each address you want to block, create a line with Require not ip <address>, e.g., Require not ip You can also add multiple addresses on one line separated by spaces, but it's harder to change/manage later.

(thanks to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment