[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-24 20:51:56
This commit is contained in:
parent
07048755e4
commit
b275454fd0
|
|
@ -1,156 +0,0 @@
|
||||||
# ==============================================================================
|
|
||||||
# ARQUIVO: /etc/nginx/sites-available/git.itguys.com.br.conf
|
|
||||||
# AUTOR: Gemini (Especialista NGINX)
|
|
||||||
# DATA: 24/09/2025 - 20:42
|
|
||||||
# VERSÃO: 4.0 (Adicionada Proteção Anti-Bot e Rate Limiting)
|
|
||||||
#
|
|
||||||
# DESCRIÇÃO:
|
|
||||||
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para Gitea.
|
|
||||||
# Esta versão inclui bloqueio de bots/crawlers maliciosos por User-Agent
|
|
||||||
# e limitação de requisições por IP para mitigar abusos.
|
|
||||||
# ==============================================================================
|
|
||||||
|
|
||||||
# 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;
|
|
||||||
|
|
||||||
location /.well-known/acme-challenge/ {
|
|
||||||
root /var/www/html;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
client_max_body_size 10G;
|
|
||||||
access_log /var/log/nginx/git.itguys.com.br.access.log;
|
|
||||||
error_log /var/log/nginx/git.itguys.com.br.error.log warn;
|
|
||||||
|
|
||||||
# =================================================================
|
|
||||||
# INÍCIO: Definições de Proteção (Anti-Bot & Rate Limit)
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# --- Bloqueio de Crawlers e Bots Indesejados ---
|
|
||||||
# Se o User-Agent corresponder a algum da lista, a variável $bad_bot será 1.
|
|
||||||
if ($http_user_agent ~* (AhrefsBot|Baiduspider|BLEXBot|Bytespider|DotBot|SemrushBot|YandexBot|PetalBot|MJ12bot|MegaIndex|heritrix|Python-urllib|Wget|Go-http-client) ) {
|
|
||||||
set $bad_bot 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Bloqueia referrers de spam conhecidos.
|
|
||||||
if ( $http_referer ~* (semalt.com|buttons-for-website.com) ) {
|
|
||||||
set $bad_bot 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Bloqueia a requisição se for de um bot indesejado.
|
|
||||||
if ($bad_bot = 1) {
|
|
||||||
return 403; # Retorna 'Forbidden'
|
|
||||||
}
|
|
||||||
|
|
||||||
# =================================================================
|
|
||||||
# FIM: Definições de Proteção
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# =================================================================
|
|
||||||
# INÍCIO: Configurações de SSL/TLS
|
|
||||||
# =================================================================
|
|
||||||
ssl_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.pem;
|
|
||||||
ssl_certificate_key /etc/letsencrypt/live/git.itguys.com.br/privkey.pem;
|
|
||||||
ssl_session_timeout 1d;
|
|
||||||
ssl_session_tickets off;
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers off;
|
|
||||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY135_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';
|
|
||||||
ssl_stapling on;
|
|
||||||
ssl_stapling_verify on;
|
|
||||||
# =================================================================
|
|
||||||
# FIM: Configurações de SSL/TLS
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# =================================================================
|
|
||||||
# INÍCIO: 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 X-XSS-Protection "1; mode=block" always;
|
|
||||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
|
||||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; object-src 'none'; frame-ancestors 'self';" always;
|
|
||||||
# =================================================================
|
|
||||||
# FIM: Cabeçalhos de Segurança
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# =================================================================
|
|
||||||
# INÍCIO: 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]\.";
|
|
||||||
# =================================================================
|
|
||||||
# FIM: Configurações de Compressão
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# =================================================================
|
|
||||||
# INÍCIO: 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;
|
|
||||||
# =================================================================
|
|
||||||
# FIM: Parâmetros de Proxy
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
|
||||||
|
|
||||||
# 1. Rota Otimizada para Operações Git
|
|
||||||
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