149 lines
6.2 KiB
Plaintext
149 lines
6.2 KiB
Plaintext
# ==============================================================================
|
|
# ARQUIVO: /etc/nginx/sites-available/itguys.com.br.conf
|
|
# AUTOR: Gemini (Especialista NGINX)
|
|
# DATA: 27/09/2025 - 15:20
|
|
# VERSÃO: 3.0 (Correção de Cipher SSL e Integração com Políticas Globais)
|
|
#
|
|
# DESCRIÇÃO:
|
|
# Configuração de Proxy Reverso OTIMIZADA para o site público itguys.com.br.
|
|
# Esta versão corrige o erro ERR_SSL_VERSION_OR_CIPHER_MISMATCH com uma lista
|
|
# de cifras mais compatível e integra o site com as políticas de segurança,
|
|
# logging e rate limiting definidas em /etc/nginx/nginx.conf.
|
|
# ==============================================================================
|
|
|
|
# Define o nosso servidor web como um "upstream" para fácil referência.
|
|
upstream itguys_backend {
|
|
server 172.16.12.17:80;
|
|
}
|
|
|
|
# ==============================================================================
|
|
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS com WWW
|
|
# ==============================================================================
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name itguys.com.br www.itguys.com.br;
|
|
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/html;
|
|
}
|
|
|
|
location / {
|
|
return 301 https://www.itguys.com.br$request_uri;
|
|
}
|
|
}
|
|
|
|
# ==============================================================================
|
|
# BLOCO 2: Redirecionamento de HTTPS SEM WWW para a versão COM WWW
|
|
# ==============================================================================
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name itguys.com.br;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/www.itguys.com.br/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/www.itguys.com.br/privkey.pem;
|
|
ssl_trusted_certificate /etc/letsencrypt/live/www.itguys.com.br/fullchain.pem;
|
|
|
|
# Apenas redireciona, não precisa de mais nada aqui.
|
|
return 301 https://www.itguys.com.br$request_uri;
|
|
}
|
|
|
|
# ==============================================================================
|
|
# BLOCO 3: Servidor Principal - Proxy Reverso (HTTPS COM WWW)
|
|
# ==============================================================================
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name www.itguys.com.br;
|
|
|
|
# --- Logs ---
|
|
access_log /var/log/nginx/itguys.com.br.access.log detailed_proxy;
|
|
access_log /var/log/nginx/itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
|
error_log /var/log/nginx/itguys.com.br.error.log warn;
|
|
|
|
# --- Segurança (Integração com nginx.conf) ---
|
|
if ($block_request) {
|
|
return 404;
|
|
}
|
|
limit_req zone=global_limit burst=20 nodelay;
|
|
limit_req zone=bad_bot_limit;
|
|
|
|
# --- Configurações de SSL/TLS (CORRIGIDO) ---
|
|
ssl_certificate /etc/letsencrypt/live/www.itguys.com.br/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/www.itguys.com.br/privkey.pem;
|
|
ssl_trusted_certificate /etc/letsencrypt/live/www.itguys.com.br/fullchain.pem;
|
|
ssl_session_timeout 1d;
|
|
ssl_session_cache shared:SSL:60m;
|
|
ssl_session_tickets off;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers off;
|
|
|
|
# ATUALIZADO: Lista de cifras mais ampla para máxima compatibilidade.
|
|
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_verify on;
|
|
|
|
# --- Cabeçalhos de Segurança e SEO ---
|
|
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;
|
|
# CSP para um site estático/simples, permitindo Google Tag Manager.
|
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https://www.googletagmanager.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; img-src 'self' data:; font-src 'self' data: https://cdn.jsdelivr.net; connect-src 'self' https://www.google-analytics.com; object-src 'none'; frame-ancestors 'self';" always;
|
|
|
|
# --- Configurações de Compressão Brotli & Gzip ---
|
|
brotli on;
|
|
brotli_comp_level 6;
|
|
brotli_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_proxied expired no-cache no-store private auth;
|
|
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
|
gzip_disable "MSIE [1-6]\.";
|
|
|
|
# --- Parâmetros de Proxy Globais ---
|
|
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;
|
|
|
|
# --- Estratégia de Cache ---
|
|
proxy_cache itguys_cache;
|
|
proxy_cache_revalidate on;
|
|
proxy_cache_lock on;
|
|
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
|
add_header X-Proxy-Cache $upstream_cache_status;
|
|
|
|
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
|
location = /robots.txt {
|
|
add_header Content-Type text/plain;
|
|
return 200 "User-agent: *\nAllow: /\n";
|
|
}
|
|
|
|
# 1. Localização para o formulário (SEM CACHE)
|
|
location = /php/enviar.php {
|
|
proxy_no_cache 1;
|
|
proxy_cache_bypass 1;
|
|
proxy_pass http://itguys_backend;
|
|
}
|
|
|
|
# 2. Localização para assets estáticos (CACHE AGRESSIVO)
|
|
location ~* \.(jpg|jpeg|gif|png|webp|svg|css|js|ico|woff2?|ttf|json)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
proxy_cache_valid 200 30d;
|
|
proxy_pass http://itguys_backend;
|
|
access_log off;
|
|
}
|
|
|
|
# 3. Localização para páginas HTML (CACHE CURTO)
|
|
location / {
|
|
expires 10m; # Cache de navegador curto para HTML
|
|
proxy_cache_valid 200 10m;
|
|
proxy_pass http://itguys_backend;
|
|
}
|
|
}
|