From ee90434453d7d43812db2b5adde742ad57ae14e4 Mon Sep 17 00:00:00 2001 From: "srvproxy001.itguys.com.br" Date: Sat, 27 Sep 2025 15:16:01 -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-27=2015:16:01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx/sites-available/git.itguys.com.br.conf | 69 +++++--------------- 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/nginx/sites-available/git.itguys.com.br.conf b/nginx/sites-available/git.itguys.com.br.conf index c0e5777..c0960e4 100644 --- a/nginx/sites-available/git.itguys.com.br.conf +++ b/nginx/sites-available/git.itguys.com.br.conf @@ -1,39 +1,3 @@ -# ============================================================================== -# ARQUIVO: /etc/nginx/sites-available/git.itguys.com.br.conf -# AUTOR: Gemini (Especialista NGINX) -# DATA: 27/09/2025 - 15:10 -# VERSÃO: 6.0 (Integrado com políticas globais de nginx.conf) -# -# DESCRIÇÃO: -# Configuração de Proxy Reverso OTIMIZADA e SEGURA para Gitea. -# Esta versão utiliza as diretivas globais de segurança, rate limiting e logging -# definidas em /etc/nginx/nginx.conf para centralizar e fortalecer a proteção. -# ============================================================================== - -# Define o nosso servidor Gitea como um "upstream" para fácil referência. -upstream gitea_backend { - server 10.10.253.128; # IP do servidor Gitea -} - -# ============================================================================== -# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS -# ============================================================================== -server { - listen 80; - listen [::]:80; - server_name git.itguys.com.br; - - # Permite a renovação de certificados SSL via Let's Encrypt - location /.well-known/acme-challenge/ { - root /var/www/html; - } - - # Redireciona todo o tráfego para a versão segura (HTTPS) - location / { - return 301 https://$host$request_uri; - } -} - # ============================================================================== # BLOCO 2: Servidor Principal - Proxy Reverso para Gitea (HTTPS) # ============================================================================== @@ -46,42 +10,45 @@ server { client_max_body_size 10G; # --- Logs --- - # Utiliza o formato JSON detalhado definido globalmente. access_log /var/log/nginx/git.itguys.com.br.access.log detailed_proxy; - # Log dedicado para requisições bloqueadas pela segurança. access_log /var/log/nginx/git.itguys.com.br.bad-bot.log suspicious_bot if=$block_request; error_log /var/log/nginx/git.itguys.com.br.error.log warn; # --- Segurança (Integração com nginx.conf) --- - # Bloqueia requisições de bots maliciosos e URIs suspeitas (definidos no map global). if ($block_request) { - return 404; # Retorna 404 para não dar pistas ao atacante. + return 404; } - - # Aplica rate limiting global e um limite mais estrito para bots. limit_req zone=global_limit burst=20 nodelay; limit_req zone=bad_bot_limit; - # --- Configurações de SSL/TLS (Otimizadas) --- + # ================================================================= + # INÍCIO: Configurações de SSL/TLS (CORRIGIDO) + # ================================================================= ssl_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/git.itguys.com.br/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.pem; + ssl_session_timeout 1d; - ssl_session_cache shared:SSL:60m; # Utiliza o cache de sessão SSL global + ssl_session_cache shared:SSL:60m; ssl_session_tickets off; + ssl_protocols TLSv1.2 TLSv1.3; - ssl_prefer_server_ciphers on; # Garante que os ciphers mais fortes do servidor sejam preferidos em TLSv1.2. - ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY13_05_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384'; + ssl_prefer_server_ciphers off; # REVERTIDO: Deixar 'off' para maior compatibilidade. + + # ATUALIZADO: Lista de cifras mais ampla, mantendo alta segurança (baseado nas recomendações do Mozilla). + 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; + # ================================================================= + # 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 Referrer-Policy "no-referrer-when-downgrade" always; - # O header X-XSS-Protection foi removido por ser obsoleto e substituído por uma CSP forte. - # CSP ajustada para permitir avatares do Gravatar, conforme versão anterior. add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: *.gravatar.com; font-src 'self' data:; manifest-src 'self' data:; object-src 'none'; frame-ancestors 'self';" always; # --- Configurações de Compressão (Brotli & Gzip) --- @@ -102,8 +69,6 @@ server { proxy_set_header X-Forwarded-Proto $scheme; # --- REGRAS DE ROTEAMENTO (LOCATIONS) --- - - # 1. Rota Otimizada para Operações Git (clone, push, pull) location ~ /.*/(git-upload-pack|git-receive-pack|info/refs|HEAD|objects) { proxy_read_timeout 3600s; proxy_send_timeout 3600s; @@ -111,8 +76,6 @@ server { proxy_request_buffering off; proxy_pass http://gitea_backend; } - - # 2. Rota para Cache de Ativos Estáticos location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|webp|woff2?)$ { proxy_pass http://gitea_backend; proxy_cache gitea_cache; @@ -122,8 +85,6 @@ server { expires 1y; add_header Cache-Control "public, immutable"; } - - # 3. Rota Principal para a UI e WebSockets (SEM CACHE) location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade;