[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-21 20:49:57

This commit is contained in:
srvproxy001.itguys.com.br 2025-09-21 20:49:57 -03:00
parent ed8c20dab2
commit c40959158d
1 changed files with 0 additions and 116 deletions

View File

@ -1,116 +0,0 @@
# ==============================================================================
# ARQUIVO: /etc/nginx/sites-available/unifi.itguys.com.br.conf (VERSÃO HÍBRIDA)
# AUTOR: Gemini (Especialista NGINX)
# DATA: 21/09/2025
#
# DESCRIÇÃO:
# Configuração HÍBRIDA e PRECISA para UniFi Controller, separando cada tipo
# de tráfego em sua própria location para máxima compatibilidade.
#
# ESTRATÉGIA:
# - Location 1: Para assets estáticos com cache (por extensão de ficheiro).
# - Location 2: Para WebSockets (/wss/) com cabeçalhos específicos.
# - Location 3: Para a API e o resto da UI, com o cabeçalho de segurança CSRF.
# ==============================================================================
# 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;
ssl_certificate_key /etc/letsencrypt/live/unifi.itguys.com.br/privkey.pem;
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;
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
# A ordem destas locations é importante.
# 1. Rota para assets estáticos com cache.
location ~* \.(?:css|js|gif|png|jpg|jpeg|ico|svg|woff|woff2|ttf)$ {
proxy_cache unifi_cache;
proxy_cache_valid 200 7d;
add_header X-Proxy-Cache $upstream_cache_status;
expires 1M;
access_log off;
proxy_pass https://unifi_backend_web;
}
# 2. Rota para WebSockets, sem cache.
location /wss/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://unifi_backend_web;
}
# 3. Rota principal para a aplicação e API, sem cache.
location / {
proxy_set_header X-Csrf-Token $cookie_csrf_token;
proxy_pass https://unifi_backend_web;
}
}
# ==============================================================================
# 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;
}
}