[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-15 21:08:22
This commit is contained in:
parent
2659d1f8fa
commit
17e3274768
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue