Selected from Linux Selected from PHP
- Ubuntu 17.10 Install google's mod pagespeed for apache - PHP-Ubuntu-Youtube-dl simple script for converting and downloading youtube video or mp3
- Ubuntu SSH tunnel via proxy - PHP while loop with every row with a different color
- Install GoAccess Apache Log Analyzer Tool on Ubuntu 17.10 - PHP use while loop in function
- SSHFS and map folder with a proxy - PHP List Files And Folders As links
- How to connect to SSH server with a proxy - PHP Extract Text From String
➥ How to block ip addresses and protect files and folders with apache and .htaccess in ubuntu
Added by sonik on 09-06-2017 and keywords: php, website, block, ip, apache, htaccess, ubuntu, linux [ Print Article ]

Steb by step how to tutorial on how to protect your site with the help of apache and .htaccess.
Edit 000-default.conf and make the needed changes:
pico /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

ServerName www.webleit.info
ServerAdmin your@mail.com
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

Create a .htaccess file:
pico /var/www/html/.htaccess

And add:
order allow,deny
deny from 91.247.38.54
deny from 91.247.38.55
deny from 91.247.38.57
deny from 198.15.180.240
deny from 67.229.79.154
deny from 188.120.229.212
deny from 85.128.142.38
allow from all

# Protect the htaccess file
<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>

# Protect functions.php
<Files functions.php>
Order Allow,Deny
Deny from all
</Files>

# Protect header.php
<Files header.php>
Order Allow,Deny
Deny from all
</Files>

# Protect footer.php
<Files footer.php>
Order Allow,Deny
Deny from all
</Files>

# Protect snowstorm.js
<Files snowstorm.js>
Order Allow,Deny
Deny from all
</Files>

@All rights reserved with Copyright Webleit.info 2018 by Sonik_Blast [ Site Map ] [ RSS ] [ YouTube Mp3 Downloader and converter ]