162 lines
6.3 KiB
Plaintext
162 lines
6.3 KiB
Plaintext
# ====================================================================================
|
|
# Configuração NGINX para: pralog.com.br (Proxy Reverso para WordPress)
|
|
# Data da Criação/Alteração: 2025-10-08 (v3 - Compressão e Hardening TLS)
|
|
#
|
|
# Contexto:
|
|
# - Adicionada compressão Brotli e Gzip para otimizar a entrega de assets.
|
|
# - Realizado hardening na configuração SSL/TLS para nota A+ e compatibilidade Apple.
|
|
# - Limpeza do bloco de redirecionamento HTTP.
|
|
# ====================================================================================
|
|
|
|
# --- Definições Globais (fora do bloco 'server') ---
|
|
limit_req_zone $binary_remote_addr zone=wp_login:10m rate=5r/m;
|
|
|
|
map $http_user_agent $block_bad_bots {
|
|
default 0;
|
|
"~*(sqlmap|nikto|wpscan|python-requests|curl|wget|nmap)" 1;
|
|
"~*(nessus|acunetix|masscan|zgrab)" 1;
|
|
"~*BLEXBot" 1;
|
|
}
|
|
|
|
# --- Servidor HTTP (Porta 80) -> Redirecionamento para HTTPS (Formato Limpo) ---
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name pralog.com.br www.pralog.com.br;
|
|
|
|
access_log /var/log/nginx/pralog.com.br.redirects.log;
|
|
error_log /var/log/nginx/pralog.com.br.redirects.error.log;
|
|
|
|
# Exceção para o ACME Challenge (Let's Encrypt)
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/certbot;
|
|
}
|
|
|
|
# Redirecionamento permanente e limpo para HTTPS
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
# --- Servidor HTTPS (Porta 443) - Configuração Principal ---
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name pralog.com.br www.pralog.com.br;
|
|
|
|
root /var/www/html; # Fallback
|
|
|
|
# Logs Específicos do Site
|
|
access_log /var/log/nginx/pralog.com.br.access.log;
|
|
error_log /var/log/nginx/pralog.com.br.error.log warn;
|
|
|
|
# -----------------------------------------------------------------
|
|
# SSL/TLS - Hardening para Nota A+ e Compatibilidade
|
|
# -----------------------------------------------------------------
|
|
ssl_certificate /etc/letsencrypt/live/pralog.com.br/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/pralog.com.br/privkey.pem;
|
|
|
|
# Adicionado TLS 1.3 e uma suíte de ciphers mais ampla para compatibilidade
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
|
|
ssl_session_timeout 1d;
|
|
ssl_session_tickets off;
|
|
|
|
# Resolver para OCSP Stapling funcionar corretamente
|
|
resolver 8.8.8.8 1.1.1.1 valid=300s;
|
|
resolver_timeout 5s;
|
|
|
|
ssl_stapling on;
|
|
ssl_stapling_verify on;
|
|
ssl_trusted_certificate /etc/letsencrypt/live/pralog.com.br/fullchain.pem;
|
|
|
|
# -----------------------------------------------------------------
|
|
# Headers de Segurança
|
|
# -----------------------------------------------------------------
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
|
|
|
# -----------------------------------------------------------------
|
|
# Compressão (Brotli e Gzip)
|
|
# -----------------------------------------------------------------
|
|
# Brotli (prioridade se o navegador suportar)
|
|
brotli on;
|
|
brotli_comp_level 6;
|
|
brotli_min_length 1024; # Não comprime arquivos menores que 1024 bytes
|
|
brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
|
|
|
|
# Gzip (fallback para navegadores sem suporte a Brotli)
|
|
gzip on;
|
|
gzip_min_length 1024; # Não comprime arquivos menores que 1024 bytes
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 5;
|
|
gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
|
|
|
|
# ... (Restante do arquivo permanece o mesmo) ...
|
|
|
|
# -----------------------------------------------------------------
|
|
# Proteção Contra Bots e Acessos Indevidos
|
|
# -----------------------------------------------------------------
|
|
if ($block_bad_bots) {
|
|
return 404;
|
|
}
|
|
|
|
location ~ /\. { deny all; }
|
|
location ~* /(?:setup\.php|README\.md|readme\.html|license\.txt|wp-config-sample\.php|web\.config) { deny all; }
|
|
location ~* \.(env|git|svn|bak|sql|zip|tar\.gz)$ { deny all; }
|
|
location = /xmlrpc.php { deny all; }
|
|
|
|
# ... (O restante das suas configurações de location permanecem iguais)
|
|
location = /wp-login.php {
|
|
limit_req zone=wp_login burst=3 nodelay;
|
|
proxy_pass https://172.16.12.25;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_name $host;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_read_timeout 90s;
|
|
proxy_buffering off;
|
|
}
|
|
|
|
location ~* \.(jpg|jpeg|gif|png|webp|svg|ico|css|js|woff|woff2|ttf|eot)$ {
|
|
proxy_pass https://172.16.12.25;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_name $host;
|
|
expires 30d;
|
|
add_header Cache-Control "public";
|
|
access_log off;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass https://172.16.12.25;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_name $host;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_connect_timeout 90s;
|
|
proxy_send_timeout 90s;
|
|
proxy_read_timeout 90s;
|
|
proxy_buffering off;
|
|
}
|
|
}
|