115 lines
4.2 KiB
ApacheConf
Executable File
115 lines
4.2 KiB
ApacheConf
Executable File
# Configuración básica
|
|
Options -Indexes +FollowSymLinks -MultiViews
|
|
|
|
# Habilitar reescritura de URLs
|
|
<IfModule mod_rewrite.c>
|
|
RewriteEngine On
|
|
|
|
# Asegurar que el servidor siga los enlaces simbólicos
|
|
Options +FollowSymLinks
|
|
|
|
# Regla para el webhook de Telegram - debe ser lo primero
|
|
RewriteCond %{REQUEST_URI} ^/telegram_bot_webhook\.php [NC]
|
|
RewriteRule ^ - [L]
|
|
|
|
# Reglas para otros archivos de webhook
|
|
RewriteRule ^(telegram_webhook|test_webhook|set_webhook)\.php$ - [L,NC]
|
|
|
|
# Excluir archivos específicos de la verificación de sesión
|
|
RewriteCond %{REQUEST_URI} !^/login\.php [NC]
|
|
RewriteCond %{REQUEST_URI} !^/assets/ [NC]
|
|
RewriteCond %{REQUEST_URI} !^/translate_proxy\.php [NC]
|
|
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|png|gif|ico|svg|woff2?|ttf|eot|json|txt|map)$ [NC]
|
|
|
|
# Para el resto de las rutas, redirigir a login.php si no hay sesión
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|
RewriteCond %{REQUEST_URI} !^/translate_proxy\.php [NC]
|
|
RewriteRule ^(.*)$ /login.php [L,QSA]
|
|
</IfModule>
|
|
|
|
# Configuración de seguridad
|
|
<IfModule mod_headers.c>
|
|
# Protección básica de cabeceras
|
|
Header always set X-Frame-Options "SAMEORIGIN"
|
|
Header always set X-XSS-Protection "1; mode=block"
|
|
Header always set X-Content-Type-Options "nosniff"
|
|
|
|
# Habilita la política de seguridad de contenido (CSP) - Ajusta según sea necesario
|
|
# Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:;"
|
|
|
|
# Habilita HSTS (solo para HTTPS)
|
|
# Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
|
|
|
|
# Configuración de referrer policy
|
|
Header always set Referrer-Policy "strict-origin-when-cross-origin"
|
|
|
|
# Eliminar cabeceras que revelan información
|
|
Header unset X-Powered-By
|
|
Header unset X-Pingback
|
|
Header unset Server
|
|
Header unset X-AspNet-Version
|
|
Header unset X-AspNetMvc-Version
|
|
</IfModule>
|
|
|
|
# Proteger archivos sensibles
|
|
<FilesMatch "^\.env$|composer\.(json|lock)|package(-lock)?\.json|.*\.(sql|log|bak|swp|swo|gitignore|gitattributes|htaccess|htpasswd|DS_Store)$">
|
|
<IfModule mod_authz_core.c>
|
|
Require all denied
|
|
</IfModule>
|
|
<IfModule !mod_authz_core.c>
|
|
Order deny,allow
|
|
Deny from all
|
|
</IfModule>
|
|
</FilesMatch>
|
|
|
|
# Deshabilitar la visualización de directorios
|
|
Options -Indexes
|
|
|
|
# Prevenir acceso a archivos ocultos
|
|
<FilesMatch "^\.">
|
|
Require all denied
|
|
</FilesMatch>
|
|
|
|
# Configuración de caché para mejorar el rendimiento
|
|
<IfModule mod_expires.c>
|
|
ExpiresActive On
|
|
ExpiresByType image/jpg "access plus 1 year"
|
|
ExpiresByType image/jpeg "access plus 1 year"
|
|
ExpiresByType image/gif "access plus 1 year"
|
|
ExpiresByType image/png "access plus 1 year"
|
|
ExpiresByType text/css "access plus 1 month"
|
|
ExpiresByType application/pdf "access plus 1 month"
|
|
ExpiresByType text/x-javascript "access plus 1 month"
|
|
ExpiresByType application/x-shockwave-flash "access plus 1 month"
|
|
ExpiresByType image/x-icon "access plus 1 year"
|
|
ExpiresDefault "access plus 2 days"
|
|
</IfModule>
|
|
|
|
# Comprimir archivos para mejorar el rendimiento
|
|
<IfModule mod_deflate.c>
|
|
AddOutputFilterByType DEFLATE text/plain
|
|
AddOutputFilterByType DEFLATE text/html
|
|
AddOutputFilterByType DEFLATE text/xml
|
|
AddOutputFilterByType DEFLATE text/css
|
|
AddOutputFilterByType DEFLATE application/xml
|
|
AddOutputFilterByType DEFLATE application/xhtml+xml
|
|
AddOutputFilterByType DEFLATE application/rss+xml
|
|
AddOutputFilterByType DEFLATE application/javascript
|
|
AddOutputFilterByType DEFLATE application/x-javascript
|
|
AddOutputFilterByType DEFLATE image/svg+xml
|
|
</IfModule>
|
|
|
|
# Configuración de PHP
|
|
<IfModule mod_php7.c>
|
|
php_flag display_errors off
|
|
php_value max_execution_time 30
|
|
php_value max_input_time 60
|
|
php_value max_input_vars 1000
|
|
php_value memory_limit 128M
|
|
php_value post_max_size 32M
|
|
php_value upload_max_filesize 32M
|
|
php_flag log_errors on
|
|
php_value error_log /var/log/php_errors.log
|
|
</IfModule>
|