Guia de configuración Apache
Opciones de seguridad en definición de sitio:
Son medidas recogidas de diferentes sitios
FileEtag None
Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline';"
Header set Content-Security-Policy "default-src 'self'; script-src 'unsafe-inline';"
Header set Content-Security-Policy "default-src 'self'; input-protection 'drag';"
Header always set X-XSS-Protection 1
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options nosniff
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline';"
Header set Content-Security-Policy "default-src 'self'; script-src 'unsafe-inline';"
Header set Content-Security-Policy "default-src 'self'; input-protection 'drag';"
Header always set X-XSS-Protection 1
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options nosniff
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
Autenticación radius
AuthType Basic
AuthName "Necesaria clave de paso"
AuthBasicProvider PAM
AuthPAMService html-srv-internet
require user hugo evelyn pablo intercambio-lechuga
AuthName "Necesaria clave de paso"
AuthBasicProvider PAM
AuthPAMService html-srv-internet
require user hugo evelyn pablo intercambio-lechuga
Configuración del PAM /etc/pam.d/html-srv-internet:
auth required pam_radius_auth.so account required pam_radius_auth.so
Dar acceso, sin listado, para descarga a un directorio en HTTP
En sites-available
<VirtualHost *:80>
ServerName srv-internet.lechuga.eu
ServerAdmin admin@lechuga.eu
DocumentRoot /mnt/html_internet
#Prohibimos el acceso a cualquier archivo o directorio
<Directory /mnt/html_internet>
Order deny,allow
Deny from all
</Directory>
#Damos acceso sin listado al directorio donde se pondrá el challenge
<Directory /mnt/html_internet/.well-known/acme-challenge>
Options -Indexes
Order allow,deny
Allow from all
</Directory>
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
ServerName srv-internet.lechuga.eu
ServerAdmin admin@lechuga.eu
DocumentRoot /mnt/html_internet
#Prohibimos el acceso a cualquier archivo o directorio
<Directory /mnt/html_internet>
Order deny,allow
Deny from all
</Directory>
#Damos acceso sin listado al directorio donde se pondrá el challenge
<Directory /mnt/html_internet/.well-known/acme-challenge>
Options -Indexes
Order allow,deny
Allow from all
</Directory>
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Servicio HTTPS Seguro
En sites-available
<VirtualHost *:443>
#Raíz de este vserver
DocumentRoot /mnt/html_internet
# No permitimos usmear directorios
<Directory /mnt/html_internet/>
Options -Indexes
</Directory>
#Opciones de logging
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Configuracion SSL muy restrictiva, pero segura
SSLEngine on
SSLProtocol -all +TLSv1.2
SSLHonorCipherOrder on
SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384
SSLCertificateFile /etc/ssl/certs/lechuga.eu.crt
SSLCertificateKeyFile /etc/ssl/private/lechuga.eu.key
SSLCACertificateFile /etc/ssl/certs/lechuga.eu.chain.crt
# Necesario para php
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
</VirtualHost>
#Raíz de este vserver
DocumentRoot /mnt/html_internet
# No permitimos usmear directorios
<Directory /mnt/html_internet/>
Options -Indexes
</Directory>
#Opciones de logging
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Configuracion SSL muy restrictiva, pero segura
SSLEngine on
SSLProtocol -all +TLSv1.2
SSLHonorCipherOrder on
SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384
SSLCertificateFile /etc/ssl/certs/lechuga.eu.crt
SSLCertificateKeyFile /etc/ssl/private/lechuga.eu.key
SSLCACertificateFile /etc/ssl/certs/lechuga.eu.chain.crt
# Necesario para php
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
</VirtualHost>
Ejemplo apache2.conf
ServerRoot "/etc/apache2"
MaxRequestWorkers 5
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel info
HostnameLookups Off
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
MaxRequestWorkers 5
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel info
HostnameLookups Off
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>