[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-24 21:10:48
This commit is contained in:
parent
78b154d255
commit
b39f9a8b4f
|
|
@ -1,52 +1,40 @@
|
|||
# =================================================================================================
|
||||
# ARQUIVO DE CONFIGURAÇÃO PARA: mimir.itguys.com.br (Zabbix)
|
||||
# AUDITADO E OTIMIZADO POR: Gemini (Especialista NGINX)
|
||||
# DATA DA ALTERAÇÃO: 2025-09-23 21:48
|
||||
# DATA DA ALTERAÇÃO: 24/09/2025 - 21:08
|
||||
# VERSÃO: 4.1 (Aplicadas otimizações de compressão, segurança e cache)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para Zabbix.
|
||||
#
|
||||
# PONTOS CHAVE DA OTIMIZAÇÃO:
|
||||
# MELHORIAS IMPLEMENTADAS:
|
||||
#
|
||||
# 1. ARQUIVO AUTOCONTIDO:
|
||||
# - Para facilitar a auditoria e a portabilidade, os snippets 'ssl_params.conf',
|
||||
# 'proxy_params.conf' e 'global_robots.conf' foram internalizados. As diretivas
|
||||
# agora estão declaradas diretamente neste arquivo. O snippet 'internal_networks.conf'
|
||||
# foi mantido por ser específico do seu ambiente.
|
||||
# 1. COMPRESSÃO BROTLI E GZIP:
|
||||
# - Adicionada compressão de texto via Brotli (prioritário) e Gzip (fallback).
|
||||
# Isso irá reduzir drasticamente o tamanho dos assets e acelerar o carregamento,
|
||||
# principalmente em dashboards com muitos dados.
|
||||
#
|
||||
# 2. SEGURANÇA SSL/TLS REFORÇADA (HSTS):
|
||||
# - Adicionado o cabeçalho 'Strict-Transport-Security' (HSTS). Ele força o navegador
|
||||
# a se comunicar exclusivamente via HTTPS, prevenindo ataques 'man-in-the-middle'.
|
||||
# - Protocolos e Ciphers modernos foram explicitamente definidos.
|
||||
# 2. SEGURANÇA SSL/TLS ATUALIZADA:
|
||||
# - Suíte de cifras (ciphers) modernizada para maior segurança.
|
||||
# - Adicionado 'ssl_stapling' e 'ssl_trusted_certificate' para otimizar a conexão
|
||||
# e remover avisos do NGINX.
|
||||
#
|
||||
# 3. CACHE DE NAVEGADOR (CLIENT-SIDE):
|
||||
# - Adicionada a diretiva 'expires 30d' no bloco de assets estáticos. Isso instrui o
|
||||
# navegador do usuário a armazenar esses arquivos localmente por 30 dias, reduzindo
|
||||
# drasticamente o número de requisições e acelerando o carregamento para visitas recorrentes.
|
||||
# 3. CONTENT-SECURITY-POLICY (CSP):
|
||||
# - Adicionado cabeçalho CSP para mitigar ataques XSS. A política permite
|
||||
# 'unsafe-inline' e 'unsafe-eval', necessários para o funcionamento da UI do Zabbix.
|
||||
#
|
||||
# 4. CACHE DE SERVIDOR (SERVER-SIDE) MAIS ROBUSTO:
|
||||
# - A diretiva 'proxy_cache_valid' foi aprimorada para também cachear outras respostas
|
||||
# (como 404s) por um curto período (1 minuto), reduzindo a carga no backend.
|
||||
#
|
||||
# 5. BUFFERING OTIMIZADO:
|
||||
# - Adicionadas diretivas 'proxy_buffers' e 'proxy_buffer_size' para otimizar o
|
||||
# gerenciamento de memória e a performance ao lidar com respostas do backend.
|
||||
#
|
||||
# 6. SUGESTÃO AVANÇADA (COMENTADA): OTIMIZAÇÃO COM PHP-FPM
|
||||
# - A configuração original faz proxy para outro servidor web (172.16.254.11). Uma
|
||||
# arquitetura mais performática seria o NGINX se comunicar diretamente com o
|
||||
# PHP-FPM. Adicionei um bloco 'location ~ \.php$' comentado como exemplo de
|
||||
# como essa configuração avançada poderia ser implementada.
|
||||
# 4. CACHE OTIMIZADO:
|
||||
# - O cabeçalho 'Cache-Control' para assets estáticos foi aprimorado com a diretiva
|
||||
# 'immutable' para um cache de navegador mais eficiente.
|
||||
#
|
||||
# =================================================================================================
|
||||
|
||||
# Define o nosso servidor Zabbix como um "upstream" para fácil referência.
|
||||
upstream zabbix_backend {
|
||||
server 172.16.254.11; # Mantenha 'keepalive' se houver muitas conexões
|
||||
server 172.16.254.11;
|
||||
}
|
||||
|
||||
# (REF: 1) Define a zona de cache para os assets estáticos do Zabbix.
|
||||
# Esta linha deve estar no seu /etc/nginx/nginx.conf, dentro do bloco http {}.
|
||||
# Lembrete: A zona de cache deve estar definida no /etc/nginx/nginx.conf, dentro do bloco http {}.
|
||||
# proxy_cache_path /var/cache/nginx/zabbix_cache keys_zone=zabbix_cache:10m inactive=60m max_size=500m;
|
||||
|
||||
# ==============================================================================
|
||||
|
|
@ -75,30 +63,59 @@ server {
|
|||
listen [::]:443 ssl http2;
|
||||
server_name mimir.itguys.com.br;
|
||||
|
||||
# Define um diretório raiz, útil para servir páginas de erro ou outros arquivos locais.
|
||||
root /var/www/html;
|
||||
|
||||
# --- CONFIGURAÇÕES DE SSL E SEGURANÇA ---
|
||||
# (REF: 1 e 2)
|
||||
# =================================================================
|
||||
# INÍCIO: Configurações de SSL/TLS (ATUALIZADO)
|
||||
# =================================================================
|
||||
ssl_certificate /etc/letsencrypt/live/mimir.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/mimir.itguys.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/mimir.itguys.com.br/fullchain.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
|
||||
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_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
# =================================================================
|
||||
# FIM: Configurações de SSL/TLS
|
||||
# =================================================================
|
||||
|
||||
# Cabeçalhos de Segurança
|
||||
# =================================================================
|
||||
# INÍCIO: Cabeçalhos de Segurança (ATUALIZADO)
|
||||
# =================================================================
|
||||
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 X-XSS-Protection "1; mode=block" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
# CSP para Zabbix, permitindo scripts e estilos inline.
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; object-src 'none'; frame-ancestors 'self';" always;
|
||||
# =================================================================
|
||||
# FIM: Cabeçalhos de Segurança
|
||||
# =================================================================
|
||||
|
||||
# --- POLÍTICAS DE ACESSO E LOGS ---
|
||||
# A TRAVA DE SEGURANÇA: Restringe o acesso à rede interna. (Mantido como include)
|
||||
# =================================================================
|
||||
# INÍCIO: Configurações de Compressão Brotli & Gzip (NOVO)
|
||||
# =================================================================
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
# =================================================================
|
||||
# FIM: Configurações de Compressão
|
||||
# =================================================================
|
||||
|
||||
# A TRAVA DE SEGURANÇA: Restringe o acesso à rede interna.
|
||||
include /etc/nginx/snippets/internal_networks.conf;
|
||||
|
||||
# (REF: 1) Bloqueia a indexação por motores de busca.
|
||||
# Bloqueia a indexação por motores de busca.
|
||||
location = /robots.txt {
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "User-agent: *\nDisallow: /\n";
|
||||
|
|
@ -110,7 +127,6 @@ server {
|
|||
error_log /var/log/nginx/mimir.itguys.com.br.error.log warn;
|
||||
|
||||
# --- PARÂMETROS DE PROXY GLOBAIS ---
|
||||
# (REF: 1 e 5)
|
||||
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;
|
||||
|
|
@ -124,16 +140,13 @@ server {
|
|||
proxy_buffers 8 16k;
|
||||
proxy_buffer_size 32k;
|
||||
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||
|
||||
# 1. Rota para assets estáticos da UI (CACHE AGRESSIVO)
|
||||
# 1. Rota para assets estáticos (CACHE AGRESSIVO - ATUALIZADO)
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
# (REF: 3) Cache de Navegador
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
add_header Cache-Control "public, immutable"; # Aprimorado
|
||||
|
||||
# (REF: 4) Cache de Servidor
|
||||
proxy_cache zabbix_cache;
|
||||
proxy_cache_valid 200 302 7d;
|
||||
proxy_cache_valid any 1m;
|
||||
|
|
@ -144,7 +157,6 @@ server {
|
|||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE)
|
||||
# Apanha o zabbix.php, dashboards, APIs, etc.
|
||||
location / {
|
||||
proxy_pass http://zabbix_backend;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue