[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 22:14:49
This commit is contained in:
parent
166db55593
commit
b739b6368d
|
|
@ -0,0 +1,175 @@
|
||||||
|
# ==============================================================================
|
||||||
|
# ARQUIVO: /etc/nginx/sites-available/ns1.itguys.com.br.conf
|
||||||
|
# AUTOR: Gemini (Especialista NGINX)
|
||||||
|
# DATA: 27/09/2025 (Consolidado e otimizado)
|
||||||
|
#
|
||||||
|
# CONTEXTO:
|
||||||
|
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para Technitium DNS Server.
|
||||||
|
# Todas as configurações, incluindo SSL/TLS e segurança, foram declaradas
|
||||||
|
# diretamente neste arquivo, sem o uso de snippets (exigência do padrão).
|
||||||
|
#
|
||||||
|
# UPSTREAM: https://172.16.254.253:53443 (Observar 'proxy_ssl_verify off')
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# Define o nosso servidor Technitium como um "upstream".
|
||||||
|
# O NGINX irá se conectar a este backend usando HTTPS.
|
||||||
|
upstream technitium_backend {
|
||||||
|
server 172.16.254.253:53443;
|
||||||
|
keepalive 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name ns1.itguys.com.br;
|
||||||
|
|
||||||
|
# Aplica o rate limiting básico (zona global_limit deve estar em nginx.conf)
|
||||||
|
limit_req zone=global_limit burst=20 nodelay;
|
||||||
|
|
||||||
|
location /.well-known/acme-challenge/ {
|
||||||
|
root /var/www/html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# BLOCO 2: Servidor Principal - Proxy Reverso para Technitium DNS (HTTPS)
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
listen [::]:443 ssl http2;
|
||||||
|
server_name ns1.itguys.com.br;
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# LOGS, SEGURANÇA BÁSICA E RATE LIMITING
|
||||||
|
# ============================================================================
|
||||||
|
client_max_body_size 5M; # Tamanho máximo razoável
|
||||||
|
access_log /var/log/nginx/ns1.itguys.com.br.access.log combined;
|
||||||
|
error_log /var/log/nginx/ns1.itguys.com.br.error.log warn;
|
||||||
|
# Log para acessos bloqueados por bots (depende de $is_bad_bot em nginx.conf)
|
||||||
|
access_log /var/log/nginx/ns1.itguys.com.br.bad-bot.log blocked if=$is_bad_bot;
|
||||||
|
|
||||||
|
# Módulo de Segurança Global (Bloqueia bots e URIs suspeitas de nginx.conf)
|
||||||
|
if ($block_request) {
|
||||||
|
return 404; # Retorna 404 de forma discreta
|
||||||
|
}
|
||||||
|
|
||||||
|
# Rate Limiting (zona global_limit deve estar em nginx.conf)
|
||||||
|
limit_req zone=global_limit burst=50 nodelay;
|
||||||
|
|
||||||
|
# --- RESTRIÇÃO DE ACESSO (SUBSTITUI SNIPPET internal_networks.conf) ---
|
||||||
|
# Permite apenas as redes que você incluir (exemplo: sua rede local)
|
||||||
|
# Exemplo:
|
||||||
|
# allow 172.16.0.0/16;
|
||||||
|
# allow 10.0.0.0/8;
|
||||||
|
# deny all;
|
||||||
|
# **REMOVA ou AJUSTE AS DIRETIVAS ACIMA CONFORME SUA POLÍTICA DE SEGURANÇA**
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# CONFIGURAÇÕES DE SSL/TLS (Hardening)
|
||||||
|
# ============================================================================
|
||||||
|
ssl_certificate /etc/letsencrypt/live/ns1.itguys.com.br/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/ns1.itguys.com.br/privkey.pem;
|
||||||
|
ssl_protocols TLSv1.3 TLSv1.2;
|
||||||
|
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||||
|
ssl_session_timeout 1d;
|
||||||
|
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||||
|
ssl_session_tickets off;
|
||||||
|
|
||||||
|
# OCSP Stapling
|
||||||
|
ssl_stapling on;
|
||||||
|
ssl_stapling_verify on;
|
||||||
|
ssl_trusted_certificate /etc/letsencrypt/live/ns1.itguys.com.br/fullchain.pem;
|
||||||
|
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||||
|
resolver_timeout 5s;
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# HEADERS DE SEGURANÇA
|
||||||
|
# ============================================================================
|
||||||
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header Referrer-Policy "no-referrer" always;
|
||||||
|
add_header Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=()" always;
|
||||||
|
# O Technitium é mais simples, o CSP básico é suficiente
|
||||||
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' wss:; font-src 'self'; object-src 'none';" always;
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# COMPRESSÃO
|
||||||
|
# ============================================================================
|
||||||
|
brotli on;
|
||||||
|
brotli_comp_level 6;
|
||||||
|
brotli_min_length 256;
|
||||||
|
brotli_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_min_length 256;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# PARÂMETROS GLOBAIS DE PROXY (SUBSTITUI SNIPPET proxy_params.conf)
|
||||||
|
# ============================================================================
|
||||||
|
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_set_header User-Agent $http_user_agent;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_connect_timeout 60s;
|
||||||
|
proxy_read_timeout 90s;
|
||||||
|
proxy_send_timeout 90s;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_request_buffering off;
|
||||||
|
|
||||||
|
# IMPORTANTE: Desabilita a verificação de certificado para o backend HTTPS
|
||||||
|
# (Necessário se o Technitium estiver usando um certificado autoassinado)
|
||||||
|
proxy_ssl_verify off;
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# REGRAS DE ROTEAMENTO (LOCATIONS)
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# 1. Rota para assets estáticos (CACHE AGRESSIVO)
|
||||||
|
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||||
|
# A zona 'technitium_cache' deve ser definida no seu nginx.conf
|
||||||
|
proxy_cache technitium_cache;
|
||||||
|
proxy_cache_valid 200 7d;
|
||||||
|
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||||
|
add_header Cache-Control "public, max-age=604800, immutable"; # Header de cache
|
||||||
|
add_header X-Proxy-Cache $upstream_cache_status;
|
||||||
|
proxy_pass https://technitium_backend;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2. Rota principal para a aplicação (SEM CACHE, COM WEBSOCKETS)
|
||||||
|
location / {
|
||||||
|
# Configurações de WebSockets
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
proxy_pass https://technitium_backend;
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Páginas de Erro Personalizadas (SUBSTITUI SNIPPET custom_errors.conf) ---
|
||||||
|
# Exemplo:
|
||||||
|
# error_page 403 /403.html;
|
||||||
|
# location = /403.html {
|
||||||
|
# internal;
|
||||||
|
# root /usr/share/nginx/html;
|
||||||
|
# }
|
||||||
|
# error_page 500 502 503 504 /50x.html;
|
||||||
|
# location = /50x.html {
|
||||||
|
# root /usr/share/nginx/html;
|
||||||
|
# }
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue