GNU/Linux >> Tutoriales Linux >  >> Ubuntu

¿Cómo bloquear direcciones IP y proteger archivos y carpetas con apache y .htaccess en ubuntu?

En este tutorial, vamos a crear una lista de bloqueo para nuestro sitio web para que las direcciones IP que sabemos que son malas no puedan conectarse a nuestro servidor. También vamos a proteger los archivos que no queremos que otras personas abran en línea.

Primero editamos 000-default.conf y haz los cambios necesarios:

<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)

Ahora tenemos que crear un archivo .htaccess y poner direcciones IP para bloquear y archivos para proteger:

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. Cómo instalar y configurar Nextcloud con Apache en Ubuntu 18.04

  2. Cómo instalar y proteger phpMyAdmin con Apache en Ubuntu 18.04

  3. Cómo instalar y configurar ownCloud con Apache en Ubuntu 18.04

  4. Cómo monitorear los archivos de registro del servidor con Logwatch en Debian y Ubuntu

  5. Cómo instalar el software Ghost Blog con Apache y SSL en Ubuntu 16.04

Cómo hacer una copia de seguridad y restaurar archivos y carpetas en Ubuntu

Cómo abrir y editar archivos y carpetas en Ubuntu Desktop como administrador

Cómo ver archivos y carpetas ocultos en Ubuntu File Manager

Cómo hacer una copia de seguridad de archivos con Déjà Dup y Duplicity en Ubuntu 18.04 LTS

Cómo instalar Drupal con Apache en Debian y Ubuntu

Cómo instalar Django 3.2 en Ubuntu 20.04 con Apache y WSGI