[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 15:13:31
This commit is contained in:
parent
1776e0dd52
commit
21bb82626d
|
|
@ -0,0 +1,133 @@
|
||||||
|
# ==============================================================================
|
||||||
|
# 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)
|
||||||
|
# ==============================================================================
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
listen [::]:443 ssl http2;
|
||||||
|
server_name git.itguys.com.br;
|
||||||
|
|
||||||
|
# Permite uploads de repositórios grandes
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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) ---
|
||||||
|
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_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_stapling on;
|
||||||
|
ssl_stapling_verify on;
|
||||||
|
|
||||||
|
# --- 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) ---
|
||||||
|
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]\.";
|
||||||
|
|
||||||
|
# --- Parâmetros de Proxy ---
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
proxy_buffering off;
|
||||||
|
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;
|
||||||
|
proxy_cache_valid 200 1d;
|
||||||
|
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||||
|
add_header X-Proxy-Cache $upstream_cache_status;
|
||||||
|
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;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_pass http://gitea_backend;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue