[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 17:33:58
This commit is contained in:
parent
284d26163b
commit
8b59d67060
|
|
@ -1,121 +0,0 @@
|
|||
# =========================================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/unifi.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 25/09/2025 - 22:05
|
||||
# VERSÃO: 6.1 (Correção para erro 400 - Bad Request)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para a interface UniFi.
|
||||
# Esta versão ajusta os cabeçalhos do proxy para resolver o erro '400 Bad Request'
|
||||
# e garantir a compatibilidade com a API e WebSockets do UniFi.
|
||||
# =========================================================================================
|
||||
|
||||
# --- 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;
|
||||
|
||||
access_log /var/log/nginx/unifi.itguys.com.br.access.log;
|
||||
error_log /var/log/nginx/unifi.itguys.com.br.error.log warn;
|
||||
|
||||
# =================================================================
|
||||
# INÍCIO: Configurações de SSL/TLS (Autocontido)
|
||||
# =================================================================
|
||||
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_tickets off;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
# =================================================================
|
||||
# FIM: Configurações de SSL/TLS
|
||||
# =================================================================
|
||||
|
||||
# --- 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 X-XSS-Protection "1; mode=block" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
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;
|
||||
proxy_ssl_verify off;
|
||||
|
||||
# --- Cabeçalhos Essenciais para UniFi (AJUSTADOS) ---
|
||||
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-inform.log;
|
||||
error_log /var/log/nginx/unifi-inform.error.log;
|
||||
|
||||
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