[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 17:25:49
This commit is contained in:
parent
c4d2579e4b
commit
284d26163b
|
|
@ -0,0 +1,134 @@
|
||||||
|
# =================================================================================================
|
||||||
|
# ARQUIVO: business.itguys.com.br
|
||||||
|
# AUTOR: Gemini (Especialista NGINX)
|
||||||
|
# DATA: 27/09/2025 - 17:22
|
||||||
|
# VERSÃO: 2.0 (Hardening de Segurança e Padronização com Políticas Globais)
|
||||||
|
#
|
||||||
|
# DESCRIÇÃO:
|
||||||
|
# Mantém as otimizações de performance (Preconnect, Cache) e implementa as
|
||||||
|
# políticas globais de segurança (Rate Limit, Bot Block). Corrige a vulnerabilidade
|
||||||
|
# de verificação de SSL do backend e padroniza logs e diretivas TLS.
|
||||||
|
# =================================================================================================
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# BLOCO 1: Redirecionamento de HTTP para HTTPS
|
||||||
|
# ==============================================================================
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name business.itguys.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 business.itguys.com.br;
|
||||||
|
|
||||||
|
# --- Logs Dedicados (Padronizado) ---
|
||||||
|
access_log /var/log/nginx/business.itguys.com.br.access.log detailed_proxy;
|
||||||
|
access_log /var/log/nginx/business.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||||
|
error_log /var/log/nginx/business.itguys.com.br.error.log warn;
|
||||||
|
|
||||||
|
# --- Segurança (Integração com nginx.conf) ---
|
||||||
|
if ($block_request) {
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
limit_req zone=global_limit burst=20 nodelay;
|
||||||
|
limit_req zone=bad_bot_limit;
|
||||||
|
|
||||||
|
# --- Configurações de SSL/TLS (Padronizado) ---
|
||||||
|
ssl_certificate /etc/letsencrypt/live/business.itguys.com.br/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/business.itguys.com.br/privkey.pem;
|
||||||
|
ssl_trusted_certificate /etc/letsencrypt/live/business.itguys.com.br/fullchain.pem;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_prefer_server_ciphers off;
|
||||||
|
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_tickets off;
|
||||||
|
ssl_stapling on;
|
||||||
|
ssl_stapling_verify on;
|
||||||
|
|
||||||
|
# --- Cabeçalhos de Segurança (Otimizados) ---
|
||||||
|
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;
|
||||||
|
# ADICIONADO: CSP para segurança moderna, permitindo recursos externos necessários.
|
||||||
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net; style-src 'self' https://cdn.jsdelivr.net; font-src https://cdn.jsdelivr.net; object-src 'none';" always;
|
||||||
|
|
||||||
|
# --- Otimização de Carregamento (Preconnect e Preload) ---
|
||||||
|
add_header Link "<https://cdn.jsdelivr.net>; rel=preconnect" always;
|
||||||
|
add_header Link "<https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css>; rel=preload; as=style" always;
|
||||||
|
|
||||||
|
# --- Configurações de Compressão (Brotli & Gzip) ---
|
||||||
|
brotli on;
|
||||||
|
brotli_comp_level 6;
|
||||||
|
brotli_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
||||||
|
|
||||||
|
# --- Otimização de Conexão Keepalive ---
|
||||||
|
keepalive_timeout 75s;
|
||||||
|
keepalive_requests 1000;
|
||||||
|
|
||||||
|
# --- Estratégia de Cache Segura ---
|
||||||
|
# IMPORTANTE: Substitua 'seu_cookie_de_sessao' pelo nome real do cookie de sessão da sua aplicação.
|
||||||
|
set $session_cookie_name "seu_cookie_de_sessao";
|
||||||
|
|
||||||
|
proxy_cache business_cache;
|
||||||
|
add_header X-Proxy-Cache $upstream_cache_status;
|
||||||
|
proxy_cache_key "$scheme$request_method$host$request_uri$cookie_$session_cookie_name";
|
||||||
|
proxy_cache_bypass $cookie_$session_cookie_name $http_authorization;
|
||||||
|
proxy_no_cache $cookie_$session_cookie_name $http_authorization;
|
||||||
|
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||||
|
proxy_next_upstream_timeout 5s;
|
||||||
|
|
||||||
|
# --- Parâmetros de Proxy (Com Hardening Corrigido) ---
|
||||||
|
proxy_set_header Host $http_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_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_read_timeout 90s;
|
||||||
|
# CORREÇÃO DE SEGURANÇA: Habilita a verificação do certificado SSL do backend.
|
||||||
|
proxy_ssl_verify on;
|
||||||
|
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
proxy_ssl_name business.itguys.com.br;
|
||||||
|
|
||||||
|
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||||
|
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|webp|wasm|woff2?|ttf|eot)$ {
|
||||||
|
proxy_ignore_headers Cache-Control Expires;
|
||||||
|
proxy_cache_valid 200 60m;
|
||||||
|
proxy_cache_valid any 5m;
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
proxy_pass https://172.16.121.13;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||||
|
proxy_pass https://172.16.121.13;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
internal;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue