From 17e327476825eaca1c6d08146c4116d6af195989 Mon Sep 17 00:00:00 2001 From: "srvproxy001.itguys.com.br" Date: Mon, 15 Sep 2025 21:08:22 -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-15=2021:08:22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx/sites-available/git.itguys.com.br.conf | 102 +++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 nginx/sites-available/git.itguys.com.br.conf diff --git a/nginx/sites-available/git.itguys.com.br.conf b/nginx/sites-available/git.itguys.com.br.conf new file mode 100644 index 0000000..f936d21 --- /dev/null +++ b/nginx/sites-available/git.itguys.com.br.conf @@ -0,0 +1,102 @@ +# Ficheiro: /etc/nginx/sites-available/git.itguys.com.br.conf +# +# Configuração de Proxy Reverso com Cache Inteligente e suporte para operações Git sobre HTTP/S. +# Esta versão é para acesso público e NÃO usa HTTP/3. + +# ============================================================================== +# BLOCO HTTP: Redirecionar todo o tráfego inseguro para HTTPS +# ============================================================================== +server { + listen 80; + listen [::]:80; + server_name git.itguys.com.br; + + # Regra especial para a validação do Let's Encrypt funcionar corretamente. + location /.well-known/acme-challenge/ { + root /var/www/html; + } + + location / { + return 301 https://$host$request_uri; + } +} + +# ============================================================================== +# BLOCO HTTPS: O Coração da nossa Configuração +# ============================================================================== +server { + # --- Configuração de Escuta (Apenas TCP para HTTP/2) --- + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name git.itguys.com.br; + + # --- Certificados SSL (Geridos pelo Certbot) --- + #ssl_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.pem; + #ssl_certificate_key /etc/letsencrypt/live/git.itguys.com.br/privkey.pem; + + # --- Cabeçalhos de Segurança --- + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + + # --- Configurações de Log --- + access_log /var/log/nginx/access.log detailed_proxy; + error_log /var/log/nginx/error.log; + + # --- ESTRATÉGIA DE CACHE HÍBRIDA E SEGURA --- + proxy_cache zabbix_cache; + add_header X-Proxy-Cache $upstream_cache_status; + proxy_no_cache 1; + proxy_cache_bypass 1; + + # --- LOCALIZAÇÃO PARA OPERAÇÕES GIT (SEM CACHE, TIMEOUTS LONGOS) --- + # Esta regra é a mais importante. Ela captura as URLs usadas pelos clientes Git. + location ~ /.*/(git-upload-pack|git-receive-pack|info/refs|HEAD|objects) { + # DESATIVA o cache completamente para estas operações. + proxy_no_cache 1; + proxy_cache_bypass 1; + + # Aumenta os timeouts para 1 hora para suportar pushes e pulls grandes. + proxy_read_timeout 3600s; + proxy_send_timeout 300s; + + # Desativa o buffering para permitir o streaming de grandes volumes de dados. + proxy_buffering off; + proxy_request_buffering off; + + proxy_pass http://10.10.253.128:3000; + + # Cabeçalhos de proxy essenciais + 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; + } + + # --- LOCALIZAÇÃO PARA FICHEIROS ESTÁTICOS (CACHE ATIVADO) --- + # Esta regra captura ficheiros que são seguros para cachear (interface do Gitea). + location ~* \.(jpg|jpeg|gif|png|webp|svg|css|js|ico|woff2|ttf)$ { + # Ativa o cache apenas para estes ficheiros. + proxy_no_cache 0; + proxy_cache_bypass 0; + proxy_cache_valid 200 60m; + + proxy_pass http://10.10.253.128:3000; + proxy_set_header Host $host; + } + + # --- LOCALIZAÇÃO PRINCIPAL PARA A INTERFACE WEB (SEM CACHE) --- + # Esta regra apanha todo o resto do tráfego (páginas, APIs, WebSockets). + location / { + # O cache permanece desativado aqui por causa da regra geral do servidor. + proxy_pass http://10.10.253.128:3000; + + # Cabeçalhos essenciais para que a interface e os WebSockets funcionem. + 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; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } +}