[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 17:11:53
This commit is contained in:
parent
e11c55d5c7
commit
9f6964ceb0
|
|
@ -1,111 +0,0 @@
|
||||||
# ==============================================================================
|
|
||||||
# ARQUIVO: /etc/nginx/sites-available/anatram.com.br.conf
|
|
||||||
# AUTOR: Gemini (Especialista NGINX)
|
|
||||||
# DATA: 27/09/2025 - 17:09
|
|
||||||
# VERSÃO: 2.0 (Padronização, Hardening de Segurança e Rate Limiting)
|
|
||||||
#
|
|
||||||
# DESCRIÇÃO:
|
|
||||||
# Configuração de Proxy Reverso para o site anatram.com.br.
|
|
||||||
# Esta versão implementa as políticas globais de segurança e logging, corrige
|
|
||||||
# uma vulnerabilidade na verificação do SSL do backend e adiciona rate limiting.
|
|
||||||
# ==============================================================================
|
|
||||||
|
|
||||||
# ==============================================================================
|
|
||||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
|
||||||
# ==============================================================================
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
server_name anatram.com.br;
|
|
||||||
|
|
||||||
location /.well-known/acme-challenge/ {
|
|
||||||
root /var/www/html;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
return 301 https://$host$request_uri;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ==============================================================================
|
|
||||||
# BLOCO 2: Servidor Principal - Proxy Reverso (HTTPS)
|
|
||||||
# ==============================================================================
|
|
||||||
server {
|
|
||||||
listen 443 ssl http2;
|
|
||||||
listen [::]:443 ssl http2;
|
|
||||||
server_name anatram.com.br;
|
|
||||||
|
|
||||||
# --- Logs ---
|
|
||||||
access_log /var/log/nginx/anatram.com.br.access.log detailed_proxy;
|
|
||||||
access_log /var/log/nginx/anatram.com.br.bad-bot.log suspicious_bot if=$block_request;
|
|
||||||
error_log /var/log/nginx/anatram.com.br.error.log warn;
|
|
||||||
|
|
||||||
# --- Segurança (Integração com nginx.conf) ---
|
|
||||||
if ($block_request) {
|
|
||||||
return 444; # Fecha a conexão sem resposta, eficaz contra bots.
|
|
||||||
}
|
|
||||||
|
|
||||||
# Aplica rate limiting global e um limite mais estrito para bots.
|
|
||||||
limit_req zone=global_limit burst=20 nodelay;
|
|
||||||
limit_req zone=bad_bot_limit;
|
|
||||||
|
|
||||||
# --- Configurações de SSL/TLS (Padronizadas) ---
|
|
||||||
ssl_certificate /etc/letsencrypt/live/anatram.com.br/fullchain.pem;
|
|
||||||
ssl_certificate_key /etc/letsencrypt/live/anatram.com.br/privkey.pem;
|
|
||||||
ssl_trusted_certificate /etc/letsencrypt/live/anatram.com.br/fullchain.pem; # Padronizado
|
|
||||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
|
||||||
ssl_session_timeout 1d;
|
|
||||||
ssl_session_cache shared:SSL:60m;
|
|
||||||
ssl_session_tickets off;
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers off; # Padronizado
|
|
||||||
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_stapling on;
|
|
||||||
ssl_stapling_verify on;
|
|
||||||
|
|
||||||
# --- Cabeçalhos 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;
|
|
||||||
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
|
||||||
# ATENÇÃO: Esta CSP é muito restritiva. Se o site usar recursos externos (CDNs, Google Fonts, etc.), eles precisarão ser adicionados aqui.
|
|
||||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self'; font-src 'self'; connect-src 'self'; object-src 'none'; frame-ancestors 'self';" always;
|
|
||||||
|
|
||||||
# --- Parâmetros de Proxy (Com Hardening) ---
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
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_connect_timeout 60s;
|
|
||||||
proxy_send_timeout 60s;
|
|
||||||
proxy_read_timeout 60s;
|
|
||||||
|
|
||||||
# CORREÇÃO DE SEGURANÇA: Habilita a verificação do certificado SSL do backend.
|
|
||||||
proxy_ssl_verify on;
|
|
||||||
proxy_ssl_server_name on;
|
|
||||||
proxy_ssl_name anatram.com.br; # Garante que o NGINX valide o certificado para este nome.
|
|
||||||
|
|
||||||
# --- Estratégia de Cache ---
|
|
||||||
proxy_cache static_cache;
|
|
||||||
add_header X-Proxy-Cache $upstream_cache_status;
|
|
||||||
|
|
||||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
|
||||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
|
||||||
proxy_pass https://172.16.12.9:443;
|
|
||||||
proxy_cache_valid 200 30d;
|
|
||||||
proxy_cache_valid any 1m;
|
|
||||||
expires 30d;
|
|
||||||
add_header Cache-Control "public";
|
|
||||||
access_log off;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass https://172.16.12.9:443;
|
|
||||||
proxy_no_cache 1;
|
|
||||||
proxy_cache_bypass 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue