From 4ea1c8f83830d97eff364578b76f123931e424b8 Mon Sep 17 00:00:00 2001 From: "srvproxy001.itguys.com.br" Date: Sun, 21 Sep 2025 20:46:44 -0300 Subject: [PATCH] =?UTF-8?q?[Auto-Sync]=20Atualiza=C3=A7=C3=A3o=20das=20con?= =?UTF-8?q?figura=C3=A7=C3=B5es=20em=20srvproxy001.itguys.com.br=20-=20202?= =?UTF-8?q?5-09-21=2020:46:44?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sites-available/unifi.itguys.com.br.conf | 128 ------------------ 1 file changed, 128 deletions(-) delete mode 100644 nginx/sites-available/unifi.itguys.com.br.conf diff --git a/nginx/sites-available/unifi.itguys.com.br.conf b/nginx/sites-available/unifi.itguys.com.br.conf deleted file mode 100644 index 9df4765..0000000 --- a/nginx/sites-available/unifi.itguys.com.br.conf +++ /dev/null @@ -1,128 +0,0 @@ -# ============================================================================== -# ARQUIVO: /etc/nginx/sites-available/unifi.itguys.com.br.conf (VERSÃO FINAL) -# AUTOR: Gemini (Especialista NGINX) -# DATA: 21/09/2025 -# -# DESCRIÇÃO: -# Configuração UNIFICADA para UniFi Controller, usando um único location / com -# cache condicional para máxima compatibilidade e performance. -# -# ESTRATÉGIA: -# - Um único `location /` trata todas as requisições da UI para evitar conflitos. -# - Todos os cabeçalhos necessários (API, WebSocket) são aplicados a tudo. -# - O cache é ATIVADO por padrão, mas DESATIVADO condicionalmente para -# rotas dinâmicas e métodos de requisição que não sejam GET. -# ============================================================================== - -# Define o backend da interface web do UniFi (HTTPS). -upstream unifi_backend_web { - server 172.16.254.123:8443; -} - -# Define o backend da porta "inform" do UniFi (HTTP). -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; - - # --- CONFIGURAÇÕES DE SSL E SEGURANÇA --- - ssl_certificate /etc/letsencrypt/live/unifi.itguys.com.br/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/unifi.itguys.com.br/privkey.pem; # managed by Certbot - include /etc/nginx/snippets/ssl_params.conf; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Frame-Options "SAMEORIGIN" always; - - # --- POLÍTICAS DE ACESSO E LOGS --- - include /etc/nginx/snippets/internal_networks.conf; - include /etc/nginx/snippets/global_robots.conf; - access_log /var/log/nginx/unifi.itguys.com.br.access.log; - error_log /var/log/nginx/unifi.itguys.com.br.error.log warn; - - # --- PARÂMETROS DE PROXY GLOBAIS --- - include /etc/nginx/snippets/proxy_params.conf; - proxy_ssl_verify off; - - # --- ROTA UNIFICADA PARA TODA A APLICAÇÃO --- - location / { - # --- LÓGICA DE CACHE CONDICIONAL --- - # Por padrão, o cache está ativo. As regras abaixo definem quando NÃO usar o cache. - set $do_not_cache 0; - - # Não cacheia requisições que não sejam GET ou HEAD. - if ($request_method !~ ^(GET|HEAD)$) { - set $do_not_cache 1; - } - - # Não cacheia as rotas dinâmicas da aplicação. - if ($request_uri ~* "^/(api|wss|manage|v2|proxy)") { - set $do_not_cache 1; - } - - proxy_no_cache $do_not_cache; - proxy_cache_bypass $do_not_cache; - - # Configurações de cache para o que for permitido cachear (assets estáticos). - proxy_cache unifi_cache; - proxy_cache_valid 200 7d; - proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; - add_header X-Proxy-Cache $upstream_cache_status; - - # --- CABEÇALHOS DE PROXY UNIFICADOS --- - # Cabeçalhos para WebSockets (ignorados por requisições normais). - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - - # Cabeçalho para corrigir o erro "403 Forbidden" na API. - proxy_set_header X-Csrf-Token $cookie_csrf_token; - - # --- PROXY PASS --- - proxy_pass https://unifi_backend_web; - } - - # --- Páginas de Erro Personalizadas --- - include /etc/nginx/snippets/custom_errors.conf; -} - -# ============================================================================== -# BLOCO 3: Servidor para o "Inform" dos Dispositivos (HTTP na porta 8080) -# ============================================================================== -server { - listen 8080; - listen [::]:8080; - server_name unifi.itguys.com.br; - - include /etc/nginx/snippets/internal_networks.conf; - access_log /var/log/nginx/unifi-inform.log; - error_log /var/log/nginx/unifi-inform.error.log; - - location / { - include /etc/nginx/snippets/proxy_params.conf; - proxy_read_timeout 600s; - proxy_send_timeout 600s; - proxy_pass http://unifi_backend_inform; - } -}