[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-26 23:49:33
This commit is contained in:
parent
f8c9f254c4
commit
f6a7b9c54b
|
|
@ -1,35 +1,72 @@
|
||||||
# ==========================================================================================
|
# ==========================================================================================
|
||||||
# ARQUIVO: /etc/nginx/sites-available/cloud.grupopralog.com.br.conf
|
# ARQUIVO: /etc/nginx/sites-available/cloud.grupopralog.com.br.conf
|
||||||
# DATA DA ALTERAÇÃO: 2025-09-26 23:18
|
# DATA DA ALTERAÇÃO: 2025-09-26 23:48
|
||||||
#
|
#
|
||||||
# AUDITORIA E OTIMIZAÇÃO POR GEMINI
|
# AUDITORIA E OTIMIZAÇÃO POR GEMINI
|
||||||
# VERSÃO: 9.0 (Fortalecimento de Segurança e Otimização de Performance)
|
# VERSÃO: 10.0 (Configuração Unificada com Rate Limit Inteligente)
|
||||||
#
|
#
|
||||||
# MELHORIAS APLICADAS NESTA VERSÃO:
|
# MELHORIAS APLICADAS NESTA VERSÃO:
|
||||||
# 1. FORTALECIMENTO CONTRA BOTS:
|
# 1. RATE LIMIT INTELIGENTE COM WHITELIST:
|
||||||
# - Adicionado Rate Limiting (limit_req) para mitigar ataques de força bruta e scans.
|
# - Limita requisições apenas para IPs externos (internet).
|
||||||
# - Adicionado um bloco para negar acesso a User-Agents de scanners conhecidos.
|
# - IGNORA o limite para IPs da rede interna/confiáveis, evitando bloqueios
|
||||||
# - Adicionados blocos para retornar erro 404 rapidamente para paths comuns de exploração,
|
# para colaboradores.
|
||||||
# evitando carga desnecessária no backend.
|
|
||||||
#
|
#
|
||||||
# 2. CORREÇÃO DE CABEÇALHOS DE SEGURANÇA (HEADERS):
|
# 2. CONFIGURAÇÃO SELF-CONTAINED:
|
||||||
# - Adicionado o header "Permissions-Policy" para maior segurança.
|
# - Toda a lógica (geo, map, limit_req_zone) foi adicionada a este arquivo
|
||||||
# - Removido o header obsoleto "X-XSS-Protection".
|
# para simplificar a manutenção, não sendo necessário editar o nginx.conf.
|
||||||
# - Forçada a remoção do header "X-Frame-Options" vindo do backend para evitar duplicidade.
|
|
||||||
#
|
|
||||||
# 3. ATUALIZAÇÃO DO CONTENT-SECURITY-POLICY (CSP):
|
|
||||||
# - Corrigidas as vulnerabilidades de "mixed content" trocando "http://" por "https://"
|
|
||||||
# nas diretivas do Office Online.
|
|
||||||
#
|
|
||||||
# 4. OTIMIZAÇÃO DE SSL/TLS:
|
|
||||||
# - A suíte de ciphers foi atualizada para seguir as melhores práticas modernas,
|
|
||||||
# priorizando TLS 1.3.
|
|
||||||
#
|
#
|
||||||
|
# 3. CABEÇALHOS DE SEGURANÇA CORRIGIDOS E ATUALIZADOS.
|
||||||
# ==========================================================================================
|
# ==========================================================================================
|
||||||
|
|
||||||
# A. CONFIGURAÇÃO DE RATE LIMITING (NOVO)
|
# ======================================================================
|
||||||
# Limita requisições por IP a 10 por segundo, com um burst de 20.
|
# INÍCIO - LÓGICA DE WHITELIST PARA RATE LIMIT
|
||||||
limit_req_zone $binary_remote_addr zone=global_limit:20m rate=10r/s;
|
# ======================================================================
|
||||||
|
|
||||||
|
# 1. Bloco GEO: Define uma variável $is_internal como '1' se o IP do cliente
|
||||||
|
# estiver na nossa lista de redes confiáveis. Caso contrário, será '0'.
|
||||||
|
geo $is_internal {
|
||||||
|
default 0;
|
||||||
|
|
||||||
|
# --- IPs PÚBLICOS de Unidades/Escritórios (CENÁRIO A - RECOMENDADO) ---
|
||||||
|
# ESSA É A PARTE MAIS IMPORTANTE. PREENCHA COM OS IPs PÚBLICOS REAIS
|
||||||
|
# DE ONDE SEUS COLABORADORES ACESSAM A INTERNET.
|
||||||
|
# ----------------- PREENCHA AQUI OS SEUS IPS PÚBLICOS -----------------
|
||||||
|
# Ex: 200.201.202.203 1; # Matriz - São Paulo
|
||||||
|
# Ex: 189.188.187.186 1; # Filial - Rio de Janeiro
|
||||||
|
|
||||||
|
# IP Público 1
|
||||||
|
1;
|
||||||
|
# IP Público 2
|
||||||
|
1;
|
||||||
|
# IP Público 3
|
||||||
|
1;
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# --- Redes PRIVADAS (CENÁRIO B - AVANÇADO) ---
|
||||||
|
# Esta seção só funcionará se você tiver um outro proxy na frente do NGINX
|
||||||
|
# que envie o IP original do cliente no header X-Forwarded-For.
|
||||||
|
10.10.0.0/16 1;
|
||||||
|
10.11.0.0/16 1;
|
||||||
|
10.12.0.0/16 1;
|
||||||
|
172.16.0.0/16 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2. Bloco MAP: Cria a chave para o rate limit.
|
||||||
|
# - Se o IP for interno ($is_internal = 1), a chave será vazia (sem limite).
|
||||||
|
# - Se o IP for externo ($is_internal = 0), a chave será o IP do cliente (com limite).
|
||||||
|
map $is_internal $limit_key {
|
||||||
|
0 $binary_remote_addr;
|
||||||
|
1 "";
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3. Definição da ZONA de Rate Limit. Usa a chave dinâmica $limit_key.
|
||||||
|
# Apenas chaves não vazias (IPs externos) serão limitadas.
|
||||||
|
limit_req_zone $limit_key zone=global_limit:20m rate=10r/s;
|
||||||
|
|
||||||
|
# ======================================================================
|
||||||
|
# FIM - LÓGICA DE WHITELIST
|
||||||
|
# ======================================================================
|
||||||
|
|
||||||
# B. CONFIGURAÇÃO DA ZONA DE CACHE (Server-Side)
|
# B. CONFIGURAÇÃO DA ZONA DE CACHE (Server-Side)
|
||||||
proxy_cache_path /var/cache/nginx/nextcloud_cache_grupopralog levels=1:2 keys_zone=nextcloud_cache:20m max_size=2g inactive=120m use_temp_path=off;
|
proxy_cache_path /var/cache/nginx/nextcloud_cache_grupopralog levels=1:2 keys_zone=nextcloud_cache:20m max_size=2g inactive=120m use_temp_path=off;
|
||||||
|
|
@ -52,7 +89,7 @@ server {
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
server_name cloud.grupopralog.com.br;
|
server_name cloud.grupopralog.com.br;
|
||||||
|
|
||||||
# Aplica o rate limiting a todo o tráfego.
|
# Aplica o rate limiting a todo o tráfego HTTP.
|
||||||
limit_req zone=global_limit burst=20 nodelay;
|
limit_req zone=global_limit burst=20 nodelay;
|
||||||
|
|
||||||
location /.well-known/acme-challenge/ {
|
location /.well-known/acme-challenge/ {
|
||||||
|
|
@ -71,9 +108,9 @@ server {
|
||||||
|
|
||||||
client_max_body_size 10G;
|
client_max_body_size 10G;
|
||||||
access_log /var/log/nginx/access.log detailed_proxy;
|
access_log /var/log/nginx/access.log detailed_proxy;
|
||||||
error_log /var/log/nginx/error.log warn; # Mudado para 'warn' para não poluir com 'info'
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
|
||||||
# --- Rate Limiting para o servidor principal ---
|
# --- Aplica o Rate Limiting para o servidor principal ---
|
||||||
limit_req zone=global_limit burst=20 nodelay;
|
limit_req zone=global_limit burst=20 nodelay;
|
||||||
|
|
||||||
# --- Parâmetros de SSL/TLS (Ciphers atualizados conforme best practices) ---
|
# --- Parâmetros de SSL/TLS (Ciphers atualizados conforme best practices) ---
|
||||||
|
|
@ -88,24 +125,23 @@ server {
|
||||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||||
ssl_session_tickets off;
|
ssl_session_tickets off;
|
||||||
|
|
||||||
# OCSP Stapling (mantido, mas verificar resolução de DNS do servidor se o teste externo falhar)
|
# OCSP Stapling
|
||||||
ssl_stapling on;
|
ssl_stapling on;
|
||||||
ssl_stapling_verify on;
|
ssl_stapling_verify on;
|
||||||
ssl_trusted_certificate /etc/letsencrypt/live/cloud.grupopralog.com.br/fullchain.pem;
|
ssl_trusted_certificate /etc/letsencrypt/live/cloud.grupopralog.com.br/fullchain.pem;
|
||||||
resolver 8.8.8.8 8.8.4.4 valid=300s; # Essencial para o OCSP Stapling funcionar
|
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||||
resolver_timeout 5s;
|
resolver_timeout 5s;
|
||||||
|
|
||||||
# --- Cabeçalhos de Segurança Otimizados ---
|
# --- Cabeçalhos de Segurança Otimizados ---
|
||||||
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
|
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
|
||||||
add_header X-Content-Type-Options "nosniff" always;
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
# O header "X-XSS-Protection" foi removido por ser obsoleto.
|
|
||||||
proxy_hide_header "X-Frame-Options";
|
proxy_hide_header "X-Frame-Options";
|
||||||
proxy_hide_header "Feature-Policy";
|
proxy_hide_header "Feature-Policy";
|
||||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
add_header Referrer-Policy "no-referrer" always;
|
add_header Referrer-Policy "no-referrer" always;
|
||||||
# NOVO: Adiciona a Permissions-Policy para desativar funcionalidades sensíveis.
|
|
||||||
add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(), payment=()" always;
|
add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(), payment=()" always;
|
||||||
# --- Bloco de Compressão (sem alterações) ---
|
|
||||||
|
# --- Bloco de Compressão ---
|
||||||
brotli on;
|
brotli on;
|
||||||
brotli_comp_level 6;
|
brotli_comp_level 6;
|
||||||
brotli_min_length 256;
|
brotli_min_length 256;
|
||||||
|
|
@ -117,17 +153,13 @@ server {
|
||||||
gzip_min_length 256;
|
gzip_min_length 256;
|
||||||
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_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;
|
||||||
|
|
||||||
# --- Bloqueio de Bots e Scanners (NOVO) ---
|
# --- Bloqueio de Bots e Scanners ---
|
||||||
# Nega acesso a user-agents maliciosos comuns.
|
|
||||||
if ($http_user_agent ~* (nmap|nikto|sqlmap|wpscan|python-requests|curl)) {
|
if ($http_user_agent ~* (nmap|nikto|sqlmap|wpscan|python-requests|curl)) {
|
||||||
return 403;
|
return 403;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bloqueia acesso a arquivos e diretórios sensíveis diretamente no NGINX.
|
|
||||||
location ~* /(\.git|\.env|\.config|composer\.json|vendor/|config\.php) {
|
location ~* /(\.git|\.env|\.config|composer\.json|vendor/|config\.php) {
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* /(wp-admin|wp-login|xmlrpc\.php) {
|
location ~* /(wp-admin|wp-login|xmlrpc\.php) {
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
|
@ -136,19 +168,16 @@ server {
|
||||||
location = /.well-known/carddav { return 301 /remote.php/dav; }
|
location = /.well-known/carddav { return 301 /remote.php/dav; }
|
||||||
location = /.well-known/caldav { return 301 /remote.php/dav; }
|
location = /.well-known/caldav { return 301 /remote.php/dav; }
|
||||||
|
|
||||||
# --- Bloco do Office Online (sem alterações de funcionalidade) ---
|
# --- Bloco do Office Online ---
|
||||||
# A lentidão reportada é provavelmente um problema no backend (172.16.253.101).
|
|
||||||
location ~ ^/(m|x|we|o|p|wv|op|wd|rtc|rtc2|layouts|view)/ {
|
location ~ ^/(m|x|we|o|p|wv|op|wd|rtc|rtc2|layouts|view)/ {
|
||||||
brotli on;
|
brotli on;
|
||||||
gzip on;
|
gzip on;
|
||||||
expires $cache_asset;
|
expires $cache_asset;
|
||||||
|
|
||||||
proxy_pass http://officeonline_backend;
|
proxy_pass http://officeonline_backend;
|
||||||
# ... (configurações do office online permanecem as mesmas) ...
|
|
||||||
if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' "$scheme://$http_host"; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, HEAD'; add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Accept, Origin, User-Agent, DNT, Cache-Control, X-Mx-ReqToken, Keep-Alive, X-Requested-With, If-Modified-Since, X-UserType'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Max-Age' 1728000; return 204; } add_header 'Access-Control-Allow-Origin' "$scheme://$http_host" always; add_header 'Access-Control-Allow-Credentials' 'true' always; sub_filter 'srvoffice001.itguys.com.br' 'cloud.grupopralog.com.br'; sub_filter_once off; sub_filter_types text/html text/css text/javascript application/javascript application/json; proxy_set_header Host "srvoffice001.itguys.com.br"; 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_set_header X-Forwarded-Host $host; proxy_set_header Accept-Encoding ""; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
|
if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' "$scheme://$http_host"; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, HEAD'; add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Accept, Origin, User-Agent, DNT, Cache-Control, X-Mx-ReqToken, Keep-Alive, X-Requested-With, If-Modified-Since, X-UserType'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Max-Age' 1728000; return 204; } add_header 'Access-Control-Allow-Origin' "$scheme://$http_host" always; add_header 'Access-Control-Allow-Credentials' 'true' always; sub_filter 'srvoffice001.itguys.com.br' 'cloud.grupopralog.com.br'; sub_filter_once off; sub_filter_types text/html text/css text/javascript application/javascript application/json; proxy_set_header Host "srvoffice001.itguys.com.br"; 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_set_header X-Forwarded-Host $host; proxy_set_header Accept-Encoding ""; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Blocos de Cache (sem alterações) ---
|
# --- Blocos de Cache ---
|
||||||
location /avatar/ {
|
location /avatar/ {
|
||||||
proxy_pass http://nextcloud_backend;
|
proxy_pass http://nextcloud_backend;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue