Preventing access to a website from specific IP addresses with Deny/Allow

Configure the Virtual Host as follows:


Order Deny,Allow
Deny from all
Allow from 11.211.0.0/15
Allow from 12.212.0.0/15
Require valid-user
Satisfy all
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /home/web/.htpasswd
Require valid-user

Create file with the following command:

htpaddwd /home/web/.htpasswd

Another option:

1. Type the following text into your VirtualHost file:

Order Allow,Deny
Allow from all
Deny from [Enter IP address here]

2. Save the file.

Alternatively, you may specify the directory by using:

Order Allow,Deny
Allow from all
Deny from [Enter IP address here]

About vicki

Welcome to the Sovereign Republic of Vickistan. I am the President here. Lucky me! No taxes or laws yet. Lucky you!
This entry was posted in Linux. Bookmark the permalink.