[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 15:17:49
This commit is contained in:
parent
ee90434453
commit
5c2b47d590
|
|
@ -1,3 +1,40 @@
|
||||||
|
# ==============================================================================
|
||||||
|
# ARQUIVO: /etc/nginx/sites-available/git.itguys.com.br.conf
|
||||||
|
# AUTOR: Gemini (Especialista NGINX)
|
||||||
|
# DATA: 27/09/2025 - 15:15
|
||||||
|
# VERSÃO: 6.1 (Correção de compatibilidade de Ciphers SSL/TLS)
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# e inclui uma lista de cifras SSL/TLS mais ampla para máxima compatibilidade
|
||||||
|
# com navegadores modernos, corrigindo o erro ERR_SSL_VERSION_OR_CIPHER_MISMATCH.
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# 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)
|
# BLOCO 2: Servidor Principal - Proxy Reverso para Gitea (HTTPS)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
@ -10,45 +47,45 @@ server {
|
||||||
client_max_body_size 10G;
|
client_max_body_size 10G;
|
||||||
|
|
||||||
# --- Logs ---
|
# --- Logs ---
|
||||||
|
# Utiliza o formato JSON detalhado definido globalmente.
|
||||||
access_log /var/log/nginx/git.itguys.com.br.access.log detailed_proxy;
|
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;
|
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;
|
error_log /var/log/nginx/git.itguys.com.br.error.log warn;
|
||||||
|
|
||||||
# --- Segurança (Integração com nginx.conf) ---
|
# --- Segurança (Integração com nginx.conf) ---
|
||||||
|
# Bloqueia requisições de bots maliciosos e URIs suspeitas (definidos no map global).
|
||||||
if ($block_request) {
|
if ($block_request) {
|
||||||
return 404;
|
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=global_limit burst=20 nodelay;
|
||||||
limit_req zone=bad_bot_limit;
|
limit_req zone=bad_bot_limit;
|
||||||
|
|
||||||
# =================================================================
|
# --- Configurações de SSL/TLS (CORRIGIDO) ---
|
||||||
# INÍCIO: Configurações de SSL/TLS (CORRIGIDO)
|
|
||||||
# =================================================================
|
|
||||||
ssl_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/git.itguys.com.br/privkey.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_trusted_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.pem;
|
||||||
|
|
||||||
ssl_session_timeout 1d;
|
ssl_session_timeout 1d;
|
||||||
ssl_session_cache shared:SSL:60m;
|
ssl_session_cache shared:SSL:60m; # Utiliza o cache de sessão SSL global
|
||||||
ssl_session_tickets off;
|
ssl_session_tickets off;
|
||||||
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
ssl_prefer_server_ciphers off; # REVERTIDO: Deixar 'off' para maior compatibilidade.
|
ssl_prefer_server_ciphers off; # Mantido 'off' para maior compatibilidade.
|
||||||
|
|
||||||
# ATUALIZADO: Lista de cifras mais ampla, mantendo alta segurança (baseado nas recomendações do Mozilla).
|
# 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_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 on;
|
||||||
ssl_stapling_verify on;
|
ssl_stapling_verify on;
|
||||||
# =================================================================
|
|
||||||
# FIM: Configurações de SSL/TLS
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# --- Cabeçalhos de Segurança ---
|
# --- Cabeçalhos de Segurança ---
|
||||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
add_header X-Content-Type-Options "nosniff" always;
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
add_header Referrer-Policy "no-referrer-when-downgrade" 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.
|
||||||
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;
|
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) ---
|
# --- Configurações de Compressão (Brotli & Gzip) ---
|
||||||
|
|
@ -69,6 +106,8 @@ server {
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
# --- 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) {
|
location ~ /.*/(git-upload-pack|git-receive-pack|info/refs|HEAD|objects) {
|
||||||
proxy_read_timeout 3600s;
|
proxy_read_timeout 3600s;
|
||||||
proxy_send_timeout 3600s;
|
proxy_send_timeout 3600s;
|
||||||
|
|
@ -76,6 +115,8 @@ server {
|
||||||
proxy_request_buffering off;
|
proxy_request_buffering off;
|
||||||
proxy_pass http://gitea_backend;
|
proxy_pass http://gitea_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 2. Rota para Cache de Ativos Estáticos
|
||||||
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|webp|woff2?)$ {
|
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|webp|woff2?)$ {
|
||||||
proxy_pass http://gitea_backend;
|
proxy_pass http://gitea_backend;
|
||||||
proxy_cache gitea_cache;
|
proxy_cache gitea_cache;
|
||||||
|
|
@ -85,6 +126,8 @@ server {
|
||||||
expires 1y;
|
expires 1y;
|
||||||
add_header Cache-Control "public, immutable";
|
add_header Cache-Control "public, immutable";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 3. Rota Principal para a UI e WebSockets (SEM CACHE)
|
||||||
location / {
|
location / {
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue