[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-11-18 08:44:49
This commit is contained in:
parent
0ea441191a
commit
f2b46cea99
|
|
@ -1,80 +1,75 @@
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# ARQUIVO: /etc/nginx/sites-available/ferreirareal.com.br.conf
|
# ARQUIVO: /etc/nginx/sites-available/ferreirareal.com.br.conf
|
||||||
# AUTOR: Gemini (Especialista NGINX)
|
|
||||||
# DATA: 27/09/2025 - 17:56
|
|
||||||
# VERSÃO: 2.0 (Padrão Autocontido com Foco em Performance e Segurança)
|
|
||||||
#
|
|
||||||
# DESCRIÇÃO:
|
# DESCRIÇÃO:
|
||||||
# Refatoração completa para site estático. Elimina snippets e adiciona
|
# Configuração de Proxy Reverso OTIMIZADA para o site ferreirareal.com.br.
|
||||||
# compressão (Brotli/Gzip) e cache de navegador para máxima performance.
|
# Força HTTPS, redireciona www para não-www e inclui melhores práticas de
|
||||||
# Integra todas as políticas globais de segurança e logging.
|
# segurança, cache e SEO.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
|
# Define o servidor de backend para o site.
|
||||||
|
upstream ferreirareal_backend {
|
||||||
|
server 172.16.12.5:80;
|
||||||
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS COM WWW
|
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS (não-www)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
|
||||||
server_name ferreirareal.com.br www.ferreirareal.com.br;
|
server_name ferreirareal.com.br www.ferreirareal.com.br;
|
||||||
|
|
||||||
|
# Permite a renovação de certificado Let's Encrypt.
|
||||||
location /.well-known/acme-challenge/ {
|
location /.well-known/acme-challenge/ {
|
||||||
root /var/www/html;
|
root /var/www/html; # Ajuste este caminho se necessário.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Redireciona todo o resto para a versão segura e canônica.
|
||||||
location / {
|
location / {
|
||||||
return 301 https://www.ferreirareal.com.br$request_uri;
|
return 301 https://ferreirareal.com.br$request_uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# BLOCO 2: Redirecionamento de HTTPS SEM WWW para a versão COM WWW
|
# BLOCO 2: Redirecionamento de HTTPS com WWW para a versão sem WWW
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2;
|
listen 443 ssl http2;
|
||||||
listen [::]:443 ssl http2;
|
|
||||||
server_name ferreirareal.com.br;
|
|
||||||
|
|
||||||
# --- Configurações de SSL (Autocontido) ---
|
|
||||||
ssl_certificate /etc/letsencrypt/live/www.ferreirareal.com.br/fullchain.pem;
|
|
||||||
ssl_certificate_key /etc/letsencrypt/live/www.ferreirareal.com.br/privkey.pem;
|
|
||||||
ssl_trusted_certificate /etc/letsencrypt/live/www.ferreirareal.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;
|
|
||||||
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;
|
|
||||||
|
|
||||||
return 301 https://www.ferreirareal.com.br$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ==============================================================================
|
|
||||||
# BLOCO 3: Servidor Principal - PROXY REVERSO COM CACHE (HTTPS COM WWW)
|
|
||||||
# ==============================================================================
|
|
||||||
server {
|
|
||||||
listen 443 ssl http2;
|
|
||||||
listen [::]:443 ssl http2;
|
|
||||||
server_name www.ferreirareal.com.br;
|
server_name www.ferreirareal.com.br;
|
||||||
|
|
||||||
# --- Logs Dedicados (Padronizado) ---
|
# --- IMPORTANTE: Substitua pelos caminhos dos seus certificados ---
|
||||||
|
ssl_certificate /etc/letsencrypt/live/ferreirareal.com.br/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/ferreirareal.com.br/privkey.pem;
|
||||||
|
ssl_trusted_certificate /etc/letsencrypt/live/ferreirareal.com.br/fullchain.pem;
|
||||||
|
|
||||||
|
# Apenas redireciona, não precisa de mais nada aqui.
|
||||||
|
return 301 https://ferreirareal.com.br$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# BLOCO 3: Servidor Principal - Proxy Reverso (HTTPS, não-www)
|
||||||
|
# ==============================================================================
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
server_name ferreirareal.com.br;
|
||||||
|
|
||||||
|
# --- Logs ---
|
||||||
access_log /var/log/nginx/ferreirareal.com.br.access.log detailed_proxy;
|
access_log /var/log/nginx/ferreirareal.com.br.access.log detailed_proxy;
|
||||||
access_log /var/log/nginx/ferreirareal.com.br.bad-bot.log suspicious_bot if=$block_request;
|
access_log /var/log/nginx/ferreirareal.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||||
error_log /var/log/nginx/ferreirareal.com.br.error.log warn;
|
error_log /var/log/nginx/ferreirareal.com.br.error.log warn;
|
||||||
|
|
||||||
# --- Segurança (Integração com nginx.conf) ---
|
# --- Segurança (Integração com nginx.conf) ---
|
||||||
if ($block_request) {
|
if ($block_request) {
|
||||||
return 404;
|
return 404; # Bloqueia bots e scanners conhecidos
|
||||||
}
|
}
|
||||||
limit_req zone=global_limit burst=100 nodelay; # Burst alto para site com muitos assets
|
limit_req zone=global_limit burst=20 nodelay; # Limite de requisições geral
|
||||||
limit_req zone=bad_bot_limit;
|
limit_req zone=bad_bot_limit; # Limite mais estrito para bots
|
||||||
|
|
||||||
# --- Configurações de SSL/TLS (Padrão Autocontido) ---
|
# --- Configurações de SSL/TLS Otimizadas ---
|
||||||
ssl_certificate /etc/letsencrypt/live/www.ferreirareal.com.br/fullchain.pem;
|
# IMPORTANTE: Garanta que os caminhos abaixo estão corretos.
|
||||||
ssl_certificate_key /etc/letsencrypt/live/www.ferreirareal.com.br/privkey.pem;
|
ssl_certificate /etc/letsencrypt/live/ferreirareal.com.br/fullchain.pem;
|
||||||
ssl_trusted_certificate /etc/letsencrypt/live/www.ferreirareal.com.br/fullchain.pem;
|
ssl_certificate_key /etc/letsencrypt/live/ferreirareal.com.br/privkey.pem;
|
||||||
|
ssl_trusted_certificate /etc/letsencrypt/live/ferreirareal.com.br/fullchain.pem;
|
||||||
|
|
||||||
ssl_session_timeout 1d;
|
ssl_session_timeout 1d;
|
||||||
ssl_session_cache shared:SSL:60m;
|
ssl_session_cache shared:SSL:60m;
|
||||||
ssl_session_tickets off;
|
ssl_session_tickets off;
|
||||||
|
|
@ -84,52 +79,60 @@ server {
|
||||||
ssl_stapling on;
|
ssl_stapling on;
|
||||||
ssl_stapling_verify on;
|
ssl_stapling_verify on;
|
||||||
|
|
||||||
# --- Cabeçalhos de Segurança (Padrão Autocontido) ---
|
# --- Cabeçalhos de Segurança e SEO ---
|
||||||
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;
|
||||||
# CSP para um site estático simples.
|
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' data:; object-src 'none'; frame-ancestors 'self';" always;
|
||||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self'; font-src 'self'; object-src 'none'; frame-ancestors 'none';" always;
|
|
||||||
|
|
||||||
# --- OTIMIZAÇÃO DE PERFORMANCE: Compressão Brotli & Gzip ---
|
# --- Configurações de Compressão Brotli & Gzip ---
|
||||||
brotli on;
|
brotli on;
|
||||||
brotli_comp_level 6;
|
brotli_comp_level 6;
|
||||||
brotli_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
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 on;
|
||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
gzip_min_length 1024;
|
gzip_min_length 1024;
|
||||||
gzip_proxied any;
|
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 image/svg+xml;
|
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]\.";
|
||||||
|
|
||||||
# --- Configuração de Cache de Proxy ---
|
# --- Parâmetros de Proxy Globais ---
|
||||||
proxy_cache static_cache;
|
proxy_set_header Host $http_host;
|
||||||
add_header X-Proxy-Cache $upstream_cache_status;
|
|
||||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
|
||||||
proxy_cache_revalidate on;
|
|
||||||
proxy_cache_lock on;
|
|
||||||
|
|
||||||
# --- Parâmetros de Proxy (Autocontido) ---
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
# --- Estratégia de Cache (IMPORTANTE) ---
|
||||||
|
# Lembre-se de adicionar a linha 'proxy_cache_path' correspondente em nginx.conf!
|
||||||
|
proxy_cache ferreirareal_cache; # Nome de cache exclusivo para este site.
|
||||||
|
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; # Mostra se o cache foi HIT, MISS, etc.
|
||||||
|
|
||||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||||
|
|
||||||
# 1. Rota para Arquivos Estáticos (Cache Agressivo de NGINX e Navegador)
|
# 1. Localização para o formulário (SEM CACHE)
|
||||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
location = /Contatos.html {
|
||||||
proxy_pass http://172.16.12.5:80;
|
proxy_no_cache 1; # Não sirva do cache
|
||||||
proxy_cache_valid 200 30d;
|
proxy_cache_bypass 1; # Ignore o cache e vá direto para o backend
|
||||||
access_log off;
|
proxy_pass http://ferreirareal_backend;
|
||||||
# OTIMIZAÇÃO DE PERFORMANCE: Cache de Navegador
|
|
||||||
expires 1y;
|
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 2. Rota Principal para HTML (Cache Curto no NGINX, sem cache no navegador)
|
# 2. Localização para assets estáticos (CACHE AGRESSIVO)
|
||||||
|
location ~* \.(jpg|jpeg|gif|png|webp|svg|css|js|ico|woff2?|ttf|json)$ {
|
||||||
|
expires 1y; # Cache de navegador por 1 ano
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
proxy_cache_valid 200 30d; # Cache de Nginx por 30 dias
|
||||||
|
proxy_pass http://ferreirareal_backend;
|
||||||
|
access_log off; # Opcional: desliga o log para assets
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3. Localização para páginas HTML (CACHE CURTO)
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://172.16.12.5:80;
|
expires 15m; # Cache de navegador por 15 minutos
|
||||||
proxy_cache_valid 200 10m;
|
proxy_cache_valid 200 15m;
|
||||||
|
proxy_pass http://ferreirareal_backend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue