GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come bloccare gli indirizzi IP e proteggere file e cartelle con apache e .htaccess in Ubuntu?

In questo tutorial creeremo un elenco di blocchi per il nostro sito Web in modo che gli indirizzi IP che sappiamo essere cattivi non possano connettersi al nostro server. Inoltre, proteggeremo i file che non vogliamo vengano aperti da altre persone online.

Per prima cosa modifichiamo 000-default.conf e apportare le modifiche necessarie:

<code>pico /etc/apache2/sites-enabled/000-default.conf</code>
Code language: Bash (bash)
<VirtualHost *:80>
<Directory /home/latewebi/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName www.lateweb.info
ServerAdmin [email protected]
DocumentRoot /home/latewebi/public_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>
Code language: Apache (apache)

Ora dobbiamo creare un file .htaccess e inserire indirizzi IP da bloccare e file da proteggere:

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>
Code language: Apache (apache)

Ubuntu
  1. Come installare e configurare Nextcloud con Apache su Ubuntu 18.04

  2. Come installare e proteggere phpMyAdmin con Apache su Ubuntu 18.04

  3. Come installare e configurare ownCloud con Apache su Ubuntu 18.04

  4. Come monitorare i file di registro del server con Logwatch su Debian e Ubuntu

  5. Come installare il software Ghost Blog con Apache e SSL su Ubuntu 16.04

Come eseguire il backup e il ripristino di file e cartelle su Ubuntu

Come aprire e modificare file e cartelle in Ubuntu Desktop come amministratore

Come visualizzare file e cartelle nascosti in Ubuntu File Manager

Come eseguire il backup dei file con Déjà Dup e Duplicity su Ubuntu 18.04 LTS

Come installare Drupal con Apache su Debian e Ubuntu

Come installare Django 3.2 su Ubuntu 20.04 con Apache e WSGI