Contoh kita akan memblokir akses ke apache dari semua IP kecuali IP yang sudah di tentukan, buka file /etc/apache2/apache2.conf (Debian/Ubuntu), /etc/httpd/conf/httpd.conf (Fedora/CentOS)
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
Ubah menjadi
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted Order allow,deny Allow from 192.168.2.0/24 Allow from 127.0.0.0/8 </Directory>
Pada contoh diatas yang bisa mengakses Apache adalah 192.168.2.0/24 (LAN) dan 127.0.0.0/8 (localhost), ingat untuk mengijinkan akses dari 127.0.0.0/8 karena beberapa aplikasi mengakses Apache lewat IP tersebut.
Bila anda ingin memblokir akses ke Apache kecuali localhost, gunakan
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted Order allow,deny Allow from 127.0.0.0/8 </Directory>
Setiap anda melakukan perubahan di file konfiguras ingat untuk merestart service apache.