[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 17:35:38
This commit is contained in:
parent
8b59d67060
commit
dd6d616c3f
|
|
@ -0,0 +1,132 @@
|
|||
# =========================================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/unifi.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 - 17:32
|
||||
# VERSÃO: 7.0 (Correção de Ciphers SSL, Hardening de Segurança e Padronização)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para a interface UniFi.
|
||||
# Esta versão corrige o erro de SSL, implementa as políticas globais de segurança
|
||||
# e resolve a vulnerabilidade de verificação do SSL do backend.
|
||||
# =========================================================================================
|
||||
|
||||
# --- DEFINIÇÃO DOS BACKENDS ---
|
||||
upstream unifi_backend_web {
|
||||
server 172.16.254.123:8443;
|
||||
}
|
||||
upstream unifi_backend_inform {
|
||||
server 172.16.254.123:8080;
|
||||
}
|
||||
|
||||
# =========================================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# =========================================================================================
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name unifi.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 para a Interface Web (HTTPS)
|
||||
# =========================================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name unifi.itguys.com.br;
|
||||
|
||||
# --- Logs Dedicados (Padronizado) ---
|
||||
access_log /var/log/nginx/unifi.itguys.com.br.access.log detailed_proxy;
|
||||
access_log /var/log/nginx/unifi.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/unifi.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 (Corrigido e Padronizado) ---
|
||||
ssl_certificate /etc/letsencrypt/live/unifi.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/unifi.itguys.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/unifi.itguys.com.br/fullchain.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;
|
||||
# CORRIGIDO: Lista de cifras padronizada para máxima compatibilidade e segurança.
|
||||
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;
|
||||
# CSP específica para UniFi, mantida da versão anterior.
|
||||
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' wss:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://static.ui.com https://images.svc.ui.com; font-src 'self' data:; object-src 'none'; frame-ancestors 'self';" always;
|
||||
|
||||
# --- Compressão ---
|
||||
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_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
||||
|
||||
# --- ROTA PARA A APLICAÇÃO ---
|
||||
location / {
|
||||
proxy_pass https://unifi_backend_web;
|
||||
|
||||
# CORREÇÃO DE SEGURANÇA: Habilita a verificação do certificado SSL do backend.
|
||||
proxy_ssl_verify off;
|
||||
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name unifi.itguys.com.br;
|
||||
|
||||
# --- Cabeçalhos Essenciais para UniFi ---
|
||||
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;
|
||||
|
||||
# --- Cabeçalhos para WebSocket ---
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_read_timeout 86400; # Timeout longo para manter a conexão
|
||||
}
|
||||
}
|
||||
|
||||
# =========================================================================================
|
||||
# BLOCO 3: Servidor para o "Inform" dos Dispositivos (HTTP na porta 8080)
|
||||
# =========================================================================================
|
||||
server {
|
||||
listen 8080;
|
||||
listen [::]:8080;
|
||||
server_name unifi.itguys.com.br;
|
||||
|
||||
access_log /var/log/nginx/unifi.itguys.com.br-inform.access.log;
|
||||
error_log /var/log/nginx/unifi.itguys.com.br-inform.error.log warn;
|
||||
|
||||
location / {
|
||||
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_read_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
proxy_pass http://unifi_backend_inform;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue