chore: isolate Traccar config and fix pre-flight cleanup
This commit is contained in:
parent
598b3e3e9a
commit
acabd1a271
|
|
@ -1,118 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/anatram.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 - 17:09
|
||||
# VERSÃO: 2.0 (Padronização, Hardening de Segurança e Rate Limiting)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de Proxy Reverso para o site anatram.com.br.
|
||||
# Esta versão implementa as políticas globais de segurança e logging, corrige
|
||||
# uma vulnerabilidade na verificação do SSL do backend e adiciona rate limiting.
|
||||
# ==============================================================================
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name anatram.com.br;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 2: Servidor Principal - Proxy Reverso (HTTPS)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name anatram.com.br;
|
||||
|
||||
# --- Logs ---
|
||||
access_log /var/log/nginx/anatram.com.br.access.log detailed_proxy;
|
||||
access_log /var/log/nginx/anatram.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/anatram.com.br.error.log warn;
|
||||
|
||||
# --- Segurança (Integração com nginx.conf) ---
|
||||
if ($block_request) {
|
||||
return 444; # Fecha a conexão sem resposta, eficaz contra bots.
|
||||
}
|
||||
|
||||
# Aplica rate limiting global e um limite mais estrito para bots.
|
||||
limit_req zone=global_limit burst=20 nodelay;
|
||||
limit_req zone=bad_bot_limit;
|
||||
|
||||
# --- Configurações de SSL/TLS (Padronizadas) ---
|
||||
ssl_certificate /etc/letsencrypt/live/anatram.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/anatram.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/anatram.com.br/fullchain.pem; # Padronizado
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off; # Padronizado
|
||||
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 ---
|
||||
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;
|
||||
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
||||
# ATENÇÃO: Esta CSP é muito restritiva. Se o site usar recursos externos (CDNs, Google Fonts, etc.), eles precisarão ser adicionados aqui.
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self'; font-src 'self'; connect-src 'self'; 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 image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
# --- Parâmetros de Proxy (Com Hardening) ---
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $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;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
|
||||
# --- Estratégia de Cache ---
|
||||
proxy_cache static_cache;
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
proxy_pass https://172.16.12.9:443;
|
||||
proxy_cache_valid 200 30d;
|
||||
proxy_cache_valid any 1m;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass https://172.16.12.9:443;
|
||||
proxy_no_cache 1;
|
||||
proxy_cache_bypass 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/atendimento.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 23/01/2026
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de Proxy Reverso para Chatwoot (Atendimento).
|
||||
# ==============================================================================
|
||||
|
||||
upstream atendimento_backend {
|
||||
server host.docker.internal:8082;
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP para HTTPS
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name atendimento.itguys.com.br;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 2: Servidor Principal (HTTPS)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name atendimento.itguys.com.br;
|
||||
|
||||
# --- Logs ---
|
||||
access_log /var/log/nginx/atendimento.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/atendimento.itguys.com.br.error.log warn;
|
||||
|
||||
# --- Configurações de SSL/TLS ---
|
||||
ssl_certificate /etc/letsencrypt/live/atendimento.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/atendimento.itguys.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/atendimento.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;
|
||||
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 ---
|
||||
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;
|
||||
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:; connect-src 'self' wss: https:; manifest-src 'self' data:; object-src 'none'; frame-ancestors 'self';" always;
|
||||
|
||||
# --- Configurações de Proxy e WebSockets (Chatwoot) ---
|
||||
location / {
|
||||
proxy_pass http://atendimento_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Timeouts para evitar desconexões em WebSockets
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
|
||||
# Rota para assets estáticos (opcional, mas recomendado)
|
||||
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|webp|woff2?)$ {
|
||||
proxy_pass http://atendimento_backend;
|
||||
proxy_cache off; # Chatwoot gerencia seu próprio cache geralmente, ou ajustar conforme necessidade
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
# =================================================================================================
|
||||
# ARQUIVO: business.itguys.com.br
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 - 17:22
|
||||
# VERSÃO: 2.1 (Ajuste de Upload)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Adicionado bloco de location específico para tratar uploads, aplicando as regras
|
||||
# de tipo de arquivo definidas no mapa global.
|
||||
# =================================================================================================
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 0: Mapeamento de Tipos de Arquivo para Upload
|
||||
# ==============================================================================
|
||||
map $http_content_type $allowed_upload {
|
||||
default 0; # Bloqueia tudo por padrão
|
||||
|
||||
# Tipos de arquivo permitidos
|
||||
"text/csv" 1;
|
||||
"application/pdf" 1;
|
||||
"image/jpeg" 1;
|
||||
"image/png" 1;
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP para HTTPS
|
||||
# ==============================================================================
|
||||
server {
|
||||
if ($host = autolab.itguys.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
if ($host = business.itguys.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name business.itguys.com.br autolab.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 (HTTPS)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name business.itguys.com.br autolab.itguys.com.br;
|
||||
|
||||
# --- Logs Dedicados (Padronizado) ---
|
||||
access_log /var/log/nginx/business.itguys.com.br.access.log detailed_proxy;
|
||||
access_log /var/log/nginx/business.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/business.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;
|
||||
client_max_body_size 512M;
|
||||
|
||||
# --- Configurações de SSL/TLS (Padronizado) ---
|
||||
ssl_certificate /etc/letsencrypt/live/business.itguys.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/business.itguys.com.br/privkey.pem; # managed by Certbot
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/business.itguys.com.br/fullchain.pem;
|
||||
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_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
# --- Cabeçalhos de Segurança (Otimizados) ---
|
||||
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 Content-Security-Policy "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net; style-src 'self' https://cdn.jsdelivr.net; font-src https://cdn.jsdelivr.net; object-src 'none';" always;
|
||||
|
||||
# --- Otimização de Carregamento (Preconnect e Preload) ---
|
||||
add_header Link "<https://cdn.jsdelivr.net>; rel=preconnect" always;
|
||||
add_header Link "<https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css>; rel=preload; as=style" 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 image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
||||
|
||||
# --- Otimização de Conexão Keepalive ---
|
||||
keepalive_timeout 75s;
|
||||
keepalive_requests 1000;
|
||||
|
||||
# --- Estratégia de Cache Segura ---
|
||||
set $session_cookie_name "seu_cookie_de_sessao";
|
||||
proxy_cache business_cache;
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
proxy_cache_key "$scheme$request_method$host$request_uri$cookie_$session_cookie_name";
|
||||
proxy_cache_bypass $cookie_$session_cookie_name $http_authorization;
|
||||
proxy_no_cache $cookie_$session_cookie_name $http_authorization;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
proxy_next_upstream_timeout 5s;
|
||||
|
||||
# --- Parâmetros de Proxy (Com Hardening Corrigido) ---
|
||||
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;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 90s;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||
|
||||
# ==============================================================================
|
||||
# NOVO BLOCO: Tratamento específico para o endpoint de Upload
|
||||
# IMPORTANTE: Adapte "/api/upload/" para o caminho real da sua aplicação.
|
||||
# ==============================================================================
|
||||
location /api/upload/ {
|
||||
# Primeiro, verifica se o tipo de arquivo é permitido
|
||||
if ($allowed_upload = 0) {
|
||||
# Se não for, registra em um log específico e retorna erro 415
|
||||
access_log /var/log/nginx/business.itguys.com.br.upload-blocked.log;
|
||||
return 415; # 415 Unsupported Media Type
|
||||
}
|
||||
|
||||
# Se o arquivo for permitido, a requisição segue para o backend
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
proxy_pass https://172.16.121.13;
|
||||
}
|
||||
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|webp|wasm|woff2?|ttf|eot)$ {
|
||||
proxy_ignore_headers Cache-Control Expires;
|
||||
proxy_cache_valid 200 60m;
|
||||
proxy_cache_valid any 5m;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
proxy_pass https://172.16.121.13;
|
||||
}
|
||||
|
||||
# Uploads (arquivos estáticos do backend)
|
||||
location /uploads/ {
|
||||
alias /var/www/html/Ambiente_de_Testes/Oficina/Backend/business/ambiente_python/uploads;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
location / {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
proxy_pass https://172.16.121.13;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
internal;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,307 +0,0 @@
|
|||
#
|
||||
# Configuração de TESTE: cloud.grupopralog.com.br
|
||||
# Atualizado em: 2025-11-11 @ 01:45 (Horário de Brasília)
|
||||
# Contexto: Correção do 502 (Bad Gateway) no Office Online.
|
||||
# - Adicionado "proxy_ssl_verify off;" ao location WOPI
|
||||
# para permitir certificado autoassinado do backend.
|
||||
#
|
||||
|
||||
map $request_uri $cache_asset {
|
||||
~*\.(css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff|woff2|ttf|otf)$ 1y;
|
||||
default off;
|
||||
}
|
||||
|
||||
map $request_uri $cacheable_session_request {
|
||||
~^/apps/files/$ 1;
|
||||
~^/apps/files/files$ 1;
|
||||
~^/apps/files/\?dir= 1;
|
||||
~^/apps/dashboard/$ 1;
|
||||
~^/remote\.php/dav/files/ 1;
|
||||
default 0;
|
||||
}
|
||||
|
||||
map $cacheable_session_request $session_cache_zone {
|
||||
1 nextcloud_session_cache;
|
||||
default "";
|
||||
}
|
||||
|
||||
upstream nextcloud_backend {
|
||||
server 172.16.253.12;
|
||||
}
|
||||
|
||||
upstream officeonline_backend {
|
||||
server 172.16.253.101;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name cloud.grupopralog.com.br;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name cloud.grupopralog.com.br;
|
||||
|
||||
client_max_body_size 10G;
|
||||
access_log /var/log/nginx/cloud.grupopralog.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/cloud.grupopralog.com.br.error.log warn;
|
||||
access_log /var/log/nginx/cloud.grupopralog.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
# Segurança Headers
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
#add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
|
||||
# Buffers (Globais para este Server)
|
||||
client_body_buffer_size 128M;
|
||||
proxy_buffer_size 512k;
|
||||
proxy_buffers 32 256k;
|
||||
proxy_busy_buffers_size 512k;
|
||||
proxy_connect_timeout 1200s;
|
||||
proxy_send_timeout 1200s;
|
||||
proxy_read_timeout 1200s;
|
||||
proxy_temp_file_write_size 512k;
|
||||
|
||||
# Ocultar headers do backend
|
||||
proxy_hide_header X-Content-Type-Options;
|
||||
proxy_hide_header X-Frame-Options;
|
||||
proxy_hide_header Feature-Policy;
|
||||
proxy_hide_header Content-Security-Policy;
|
||||
|
||||
# SSL
|
||||
ssl_certificate /etc/letsencrypt/live/cloud.grupopralog.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/cloud.grupopralog.com.br/privkey.pem;
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY_1305_SHA2ANET-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# SSL Stapling
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/cloud.grupopralog.com.br/fullchain.pem;
|
||||
resolver 127.0.0.1 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# Compressão
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 1024;
|
||||
brotli_types
|
||||
application/atom+xml
|
||||
application/javascript
|
||||
application/json
|
||||
application/ld+json
|
||||
application/manifest+json
|
||||
application/rss+xml
|
||||
application/vnd.ms-fontobject
|
||||
application/x-font-opentype
|
||||
application/x-font-truetype
|
||||
application/x-javascript
|
||||
application/xhtml+xml
|
||||
application/xml
|
||||
font/eot
|
||||
font/opentype
|
||||
font/otf
|
||||
font/truetype
|
||||
font/woff
|
||||
font/woff2
|
||||
image/svg+xml
|
||||
image/x-icon
|
||||
text/css
|
||||
text/javascript
|
||||
text/plain
|
||||
text/xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 1024;
|
||||
gzip_types
|
||||
application/atom+xml
|
||||
application/javascript
|
||||
application/json
|
||||
application/ld+json
|
||||
application/manifest+json
|
||||
application/rss+xml
|
||||
application/vnd.ms-fontobject
|
||||
application/x-font-opentype
|
||||
application/x-font-truetype
|
||||
application/x-javascript
|
||||
application/xhtml+xml
|
||||
application/xml
|
||||
font/eot
|
||||
font/opentype
|
||||
font/otf
|
||||
font/truetype
|
||||
font/woff
|
||||
font/woff2
|
||||
image/svg+xml
|
||||
image/x-icon
|
||||
text/css
|
||||
text/javascript
|
||||
text/plain
|
||||
text/xml;
|
||||
|
||||
# CalDAV / CardDAV
|
||||
location = /.well-known/carddav { return 301 /remote.php/dav; }
|
||||
location = /.well-known/caldav { return 301 /remote.php/dav; }
|
||||
|
||||
# Office Online (Discovery)
|
||||
location = /hosting/discovery {
|
||||
proxy_pass http://officeonline_backend;
|
||||
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 Accept-Encoding "";
|
||||
proxy_ssl_verify off;
|
||||
#Alteraçoes 12/11/2025
|
||||
sub_filter 'srvoffice001.itguys.com.br' 'cloud.grupopralog.com.br';
|
||||
sub_filter 'https://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
||||
sub_filter 'https:\/\/srvoffice001.itguys.com.br' 'https:\/\/cloud.grupopralog.com.br';
|
||||
sub_filter 'http://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
||||
sub_filter_once off;
|
||||
sub_filter_types text/xml;
|
||||
if ($request_method = 'OPTIONS') {
|
||||
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
||||
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, HEAD';
|
||||
more_set_headers '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';
|
||||
more_set_headers 'Access-Control-Allow-Credentials: true' always;
|
||||
more_set_headers 'Access-Control-Max-Age: 1728000' always;
|
||||
return 204;
|
||||
}
|
||||
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
||||
more_set_headers 'Access-Control-Allow-Credentials: true';
|
||||
#Fim alteracao
|
||||
}
|
||||
|
||||
# Office Online (WOPI)
|
||||
#12/11/2025
|
||||
location ~ ^/(rtc|rtc2)/ {
|
||||
proxy_pass http://officeonline_backend;
|
||||
|
||||
# Headers de Proxy
|
||||
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 "";
|
||||
|
||||
# Configuração ESSENCIAL para WebSockets
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Configuração ESSENCIAL para streaming (Interface estranha)
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
|
||||
# Timeouts longos
|
||||
proxy_connect_timeout 1200s;
|
||||
proxy_send_timeout 1200s;
|
||||
proxy_read_timeout 1200s;
|
||||
}
|
||||
#Fim 12/11/2025
|
||||
|
||||
location ~ ^/(m|x|we|o|p|wv|op|wd|layouts|view|_layouts|app_scripts|Resources)/ {
|
||||
gunzip on;
|
||||
expires -1;
|
||||
etag off;
|
||||
proxy_no_cache 1;
|
||||
proxy_cache_bypass 1;
|
||||
proxy_pass http://officeonline_backend;
|
||||
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";
|
||||
proxy_connect_timeout 1200s;
|
||||
proxy_send_timeout 1200s;
|
||||
proxy_read_timeout 1200s;
|
||||
sub_filter 'srvoffice001.itguys.com.br' 'cloud.grupopralog.com.br';
|
||||
sub_filter 'https://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
||||
sub_filter 'http://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
||||
sub_filter 'https:\/\/srvoffice001.itguys.com.br' 'https:\/\/cloud.grupopralog.com.br';
|
||||
sub_filter 'http:\/\/srvoffice001.itguys.com.br' 'https:\/\/cloud.grupopralog.com.br';
|
||||
sub_filter_once off;
|
||||
sub_filter_types text/html text/css text/javascript application/javascript application/json application/x-javascript application/xml;
|
||||
|
||||
# --- CORRIGIDO AQUI (Adicionado para corrigir o 502) ---
|
||||
#proxy_ssl_verify off;
|
||||
|
||||
more_clear_headers 'X-Content-Type-Options';
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
||||
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, HEAD';
|
||||
more_set_headers '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';
|
||||
more_set_headers 'Access-Control-Allow-Credentials: true' always;
|
||||
more_set_headers 'Access-Control-Max-Age: 1728000' always;
|
||||
return 204;
|
||||
}
|
||||
|
||||
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
||||
more_set_headers 'Access-Control-Allow-Credentials: true';
|
||||
}
|
||||
|
||||
# Bloco de Cache para Ativos Estáticos
|
||||
# Otimizado para máxima performance em arquivos imutáveis (versionados).
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff|woff2|ttf|otf)$ {
|
||||
proxy_pass http://nextcloud_backend;
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
|
||||
# Buffering otimizado para proxy reverso.
|
||||
proxy_buffering on;
|
||||
|
||||
# Cache Headers - Define o cache máximo no navegador (1 ano).
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
|
||||
# Mantém o log de acesso, mas desativa o log para 'arquivo não encontrado'.
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
# Location Padrão (Catch-all) - SEM CACHE
|
||||
location / {
|
||||
proxy_pass http://nextcloud_backend;
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_read_timeout 1200s;
|
||||
proxy_send_timeout 1200s;
|
||||
proxy_buffering on;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
# Ficheiro: /etc/nginx/sites-available/default-catchall.conf
|
||||
#
|
||||
# Bloco "catch-all" (padrão) otimizado para servir múltiplas páginas de erro HTML personalizadas.
|
||||
# Responde a acessos diretos ao IP ou a hostnames não configurados.
|
||||
#
|
||||
# --- EXPLICAÇÃO DAS DIRETIVAS ---
|
||||
#
|
||||
# 1. DIRETIVAS DE ESCUTA (listen):
|
||||
# - Mantidas como no original, escutando nas portas 80 e 443 (HTTP e HTTPS)
|
||||
# - A opção "default_server" marca este bloco como o padrão para qualquer requisição
|
||||
# que não corresponda a outro bloco "server" definido.
|
||||
#
|
||||
# 2. DIRETIVAS SSL (ssl_*):
|
||||
# - Mantidas para usar o certificado "snakeoil" auto-assinado para HTTPS.
|
||||
#
|
||||
# 3. NOME DO SERVIDOR (server_name):
|
||||
# - "server_name _;" é um nome especial que captura qualquer hostname que não
|
||||
# tenha sido explicitamente definido em outros ficheiros de configuração.
|
||||
#
|
||||
# 4. GESTÃO DE LOGS (access_log, log_not_found):
|
||||
# - Mantido como "off" para evitar poluir os ficheiros de log com requisições
|
||||
# indesejadas que caem neste bloco.
|
||||
#
|
||||
# 5. DIRETÓRIO RAIZ (root):
|
||||
# - Define o diretório base onde os seus ficheiros HTML de erro estarão localizados.
|
||||
# - Ex: /var/www/html/errors
|
||||
#
|
||||
# 6. MAPEAMENTO DE ERROS (error_page):
|
||||
# - Esta é a diretiva principal para esta configuração. Ela mapeia um ou mais
|
||||
# códigos de status HTTP para uma URI interna.
|
||||
# - Ex: "error_page 404 /404.html;" instrui o NGINX que, ao encontrar um erro 404,
|
||||
# ele deve fazer uma requisição interna para "/404.html".
|
||||
# - Agrupamos todos os erros 5xx (500, 502, 503, 504) para uma única página
|
||||
# genérica de erro de servidor (50x.html), uma prática comum e eficiente.
|
||||
#
|
||||
# 7. BLOCOS DE LOCALIZAÇÃO INTERNA (location = /<ficheiro>.html):
|
||||
# - Criamos um bloco "location" para cada ficheiro de erro.
|
||||
# - O sinal de igual ("=") garante uma correspondência exata e rápida da URI.
|
||||
# - A diretiva "internal" é crucial para a segurança: ela especifica que estes
|
||||
# ficheiros só podem ser acedidos através de requisições internas do NGINX
|
||||
# (geradas pela diretiva "error_page"), e não por um pedido direto do cliente
|
||||
# no navegador (ex: http://seu-ip/404.html retornará um erro).
|
||||
#
|
||||
# 8. AÇÃO PADRÃO (location /):
|
||||
# - Este bloco captura todas as requisições que chegam a este servidor.
|
||||
# - Em vez de servir um HTML embutido, agora simplesmente retornamos um código "404 Not Found".
|
||||
# - Este "return 404;" aciona a diretiva "error_page 404 ...", que por sua vez
|
||||
# serve o conteúdo do seu ficheiro /404.html personalizado. É uma forma limpa
|
||||
# e semanticamente correta de lidar com um recurso que não existe.
|
||||
|
||||
server {
|
||||
# --- Bloco 1: Configurações de Escuta e Servidor Padrão ---
|
||||
listen 80 default_server;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80 default_server;
|
||||
listen 8080 default_server;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen 443 ssl http2 default_server;
|
||||
listen [::]:443 ssl http2 default_server;
|
||||
|
||||
# --- Bloco 2: Configurações de SSL ---
|
||||
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
||||
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
|
||||
|
||||
# --- Bloco 3: Nome do Servidor ---
|
||||
server_name _;
|
||||
|
||||
# --- Bloco 4: Gestão de Logs ---
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
|
||||
# --- Bloco 5: Diretório Raiz para os Ficheiros de Erro ---
|
||||
root /var/www/html/errors;
|
||||
|
||||
# --- Bloco 6: Mapeamento de Códigos de Erro para Páginas Personalizadas ---
|
||||
location = /nginx_status {
|
||||
stub_status;
|
||||
|
||||
# --- Segurança (removi a linha duplicada para limpeza) ---
|
||||
allow 127.0.0.1; # Acesso local (localhost)
|
||||
allow 172.16.254.1; # Permite o próprio servidor / Zabbix
|
||||
deny all; # Bloqueia todos os outros
|
||||
}
|
||||
|
||||
error_page 403 /403.html;
|
||||
error_page 404 /404.html;
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
# --- Bloco 7: Lógica para Servir as Páginas de Erro de Forma Segura ---
|
||||
location = /403.html {
|
||||
internal;
|
||||
}
|
||||
|
||||
location = /404.html {
|
||||
internal;
|
||||
}
|
||||
|
||||
location = /50x.html {
|
||||
internal;
|
||||
}
|
||||
|
||||
# --- Bloco 8: Ação Padrão para Todas as Requisições ---
|
||||
# Retorna 404 para qualquer URI, o que aciona a regra "error_page" correspondente.
|
||||
location / {
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/dns-primario.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 - 17:46
|
||||
# VERSÃO: 2.0 (Refatoração para Padrão Autocontido e Hardening de Segurança)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração autocontida para Technitium DNS. Elimina todos os snippets,
|
||||
# integra as políticas globais de segurança (Rate Limit, Bot Block), corrige
|
||||
# a verificação de SSL do backend e padroniza todas as diretivas.
|
||||
# ==============================================================================
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP para HTTPS
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name dns-primario.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 Technitium DNS (HTTPS)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name dns-primario.itguys.com.br;
|
||||
|
||||
# --- Logs Dedicados (Padronizado) ---
|
||||
access_log /var/log/nginx/dns-primario.itguys.com.br.access.log detailed_proxy;
|
||||
access_log /var/log/nginx/dns-primario.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/dns-primario.itguys.com.br.error.log warn;
|
||||
|
||||
# --- Segurança (Integração com nginx.conf) ---
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
limit_req zone=global_limit burst=30 nodelay; # Burst maior para interfaces ricas
|
||||
limit_req zone=bad_bot_limit;
|
||||
|
||||
# --- Configurações de SSL/TLS (Padrão Autocontido) ---
|
||||
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 off;
|
||||
ssl_stapling_verify off;
|
||||
|
||||
# --- Cabeçalhos de Segurança (Padrão Autocontido) ---
|
||||
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;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; connect-src 'self' wss:; object-src 'none'; frame-ancestors 'self';" always;
|
||||
|
||||
# --- Configurações de Compressão (Padrão Autocontido) ---
|
||||
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 image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
||||
|
||||
# --- Localização Específica para WebSockets do Technitium ---
|
||||
location /api/socket/ {
|
||||
proxy_pass https://172.16.254.252:53443;
|
||||
|
||||
# --- Verificação de SSL do Backend (Seguro) ---
|
||||
proxy_ssl_verify off;
|
||||
proxy_ssl_trusted_certificate /etc/nginx/certs/technitium_backend.pem;
|
||||
proxy_ssl_server_name off;
|
||||
proxy_ssl_name dns-primario.itguys.com.br;
|
||||
|
||||
# --- Cabeçalhos de Proxy e WebSocket (Autocontido) ---
|
||||
proxy_set_header Host $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;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
# --- Localização Principal para o resto da Interface Web ---
|
||||
location / {
|
||||
proxy_pass https://172.16.254.252:53443;
|
||||
|
||||
# --- Verificação de SSL do Backend (Seguro) ---
|
||||
proxy_ssl_verify off;
|
||||
# ATENÇÃO: Este arquivo precisa ser criado. Veja os próximos passos.
|
||||
proxy_ssl_trusted_certificate /etc/nginx/certs/technitium_backend.pem;
|
||||
proxy_ssl_server_name off;
|
||||
proxy_ssl_name dns-primario.itguys.com.br;
|
||||
|
||||
# --- Cabeçalhos de Proxy (Autocontido) ---
|
||||
proxy_set_header Host $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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/ferreirareal.com.br.conf
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de Proxy Reverso OTIMIZADA para o site ferreirareal.com.br.
|
||||
# Força HTTPS, redireciona www para não-www e inclui melhores práticas de
|
||||
# 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 (não-www)
|
||||
# ==============================================================================
|
||||
server {
|
||||
if ($host = www.ferreirareal.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
if ($host = ferreirareal.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
server_name ferreirareal.com.br www.ferreirareal.com.br;
|
||||
|
||||
# Permite a renovação de certificado Let's Encrypt.
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html; # Ajuste este caminho se necessário.
|
||||
}
|
||||
|
||||
# Redireciona todo o resto para a versão segura e canônica.
|
||||
location / {
|
||||
return 301 https://ferreirareal.com.br$request_uri;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 2: Redirecionamento de HTTPS com WWW para a versão sem WWW
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name www.ferreirareal.com.br;
|
||||
|
||||
# --- 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;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/www.ferreirareal.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/www.ferreirareal.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# 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.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/ferreirareal.com.br.error.log warn;
|
||||
|
||||
# --- Segurança (Integração com nginx.conf) ---
|
||||
if ($block_request) {
|
||||
return 404; # Bloqueia bots e scanners conhecidos
|
||||
}
|
||||
limit_req zone=global_limit burst=20 nodelay; # Limite de requisições geral
|
||||
limit_req zone=bad_bot_limit; # Limite mais estrito para bots
|
||||
|
||||
# --- Configurações de SSL/TLS Otimizadas ---
|
||||
# IMPORTANTE: Garanta que os caminhos abaixo estão corretos.
|
||||
#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;
|
||||
|
||||
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;
|
||||
|
||||
# --- 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;
|
||||
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;
|
||||
|
||||
# --- 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 (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) ---
|
||||
|
||||
# 1. Localização para o formulário (SEM CACHE)
|
||||
location = /Contatos.html {
|
||||
proxy_no_cache 1; # Não sirva do cache
|
||||
proxy_cache_bypass 1; # Ignore o cache e vá direto para o backend
|
||||
proxy_pass http://ferreirareal_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; # 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 / {
|
||||
expires 15m; # Cache de navegador por 15 minutos
|
||||
proxy_cache_valid 200 15m;
|
||||
proxy_pass http://ferreirareal_backend;
|
||||
}
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/www.ferreirareal.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/www.ferreirareal.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
# ==============================================================================
|
||||
# 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;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
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)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name git.itguys.com.br;
|
||||
|
||||
# Permite uploads de repositórios grandes
|
||||
client_max_body_size 10G;
|
||||
|
||||
# --- Logs ---
|
||||
# Utiliza o formato JSON detalhado definido globalmente.
|
||||
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;
|
||||
error_log /var/log/nginx/git.itguys.com.br.error.log warn;
|
||||
|
||||
# --- Segurança (Integração com nginx.conf) ---
|
||||
# Bloqueia requisições de bots maliciosos e URIs suspeitas (definidos no map global).
|
||||
#if ($block_request) {
|
||||
# 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=bad_bot_limit;
|
||||
|
||||
# --- Configurações de SSL/TLS (CORRIGIDO) ---
|
||||
ssl_certificate /etc/letsencrypt/live/git.itguys.com.br/fullchain.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_session_timeout 1d;
|
||||
ssl_session_cache shared:SSL:60m; # Utiliza o cache de sessão SSL global
|
||||
ssl_session_tickets off;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
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).
|
||||
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 ---
|
||||
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;
|
||||
# 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;
|
||||
|
||||
# --- 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]\.";
|
||||
|
||||
# --- 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;
|
||||
|
||||
# --- 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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
# Configuração Nginx para o projeto Integra GPL
|
||||
# Atualizado em: 07/12/2025
|
||||
# Contexto: Hardening de segurança baseado no padrão 'cloud' e otimização de buffers.
|
||||
# Autor: Gemini (Thought Partner)
|
||||
|
||||
upstream integra_gpl_backend {
|
||||
# Backend da aplicação (Python/Node)
|
||||
server 172.16.9.101:8000;
|
||||
|
||||
# Mantém conexões abertas para performance
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
# Servidor HTTP (Redirecionamento HTTPS)
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name integra.grupopralog.com.br;
|
||||
|
||||
# Segurança: Ocultar versão do Nginx
|
||||
server_tokens off;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# Servidor HTTPS Principal
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name integra.grupopralog.com.br;
|
||||
|
||||
# Segurança: Ocultar versão do Nginx
|
||||
server_tokens off;
|
||||
|
||||
# Limite de Upload (Ajustado conforme padrão do cloud, útil para importações grandes)
|
||||
client_max_body_size 10M;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Logs
|
||||
# ----------------------------------------------------------------------
|
||||
access_log /var/log/nginx/integra.grupopralog.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/integra.grupopralog.com.br.error.log warn;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Configuração SSL/TLS (Hardening Avançado)
|
||||
# ----------------------------------------------------------------------
|
||||
ssl_certificate /etc/letsencrypt/live/integra.grupopralog.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/integra.grupopralog.com.br/privkey.pem;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Ciphers Modernos e Seguros (Padrão Mozilla Intermediate)
|
||||
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;
|
||||
|
||||
# Curvas Elípticas e DHParam (Extraído do arquivo 'cloud')
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
|
||||
# Sessão SSL Otimizada
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_cache shared:MozSSL:10m;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# OCSP Stapling
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Headers de Segurança (Hardening 'cloud')
|
||||
# ----------------------------------------------------------------------
|
||||
# HSTS Preload (2 anos - garante HTTPS estrito)
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
|
||||
# Proteção de Frame e Content Type
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Buffers e Timeouts (Evita erro 502 em cargas altas)
|
||||
# ----------------------------------------------------------------------
|
||||
client_body_buffer_size 128M;
|
||||
proxy_buffer_size 512k;
|
||||
proxy_buffers 32 256k;
|
||||
proxy_busy_buffers_size 512k;
|
||||
proxy_temp_file_write_size 512k;
|
||||
|
||||
# Timeouts elevados para processamentos longos de integração
|
||||
proxy_connect_timeout 120s;
|
||||
proxy_send_timeout 1200s;
|
||||
proxy_read_timeout 1200s;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Compressão (Lista expandida do 'cloud')
|
||||
# ----------------------------------------------------------------------
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype font/woff font/woff2 image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype font/woff font/woff2 image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Cache de Arquivos Estáticos (Otimização do 'cloud')
|
||||
# ----------------------------------------------------------------------
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff|woff2|ttf|otf)$ {
|
||||
proxy_pass http://integra_gpl_backend;
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Otimização de buffer para download de assets
|
||||
proxy_buffering on;
|
||||
|
||||
# Cache de 1 ano (Immutable)
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
|
||||
# Performance: desativa log para assets
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Aplicação Principal
|
||||
# ----------------------------------------------------------------------
|
||||
location / {
|
||||
proxy_pass http://integra_gpl_backend;
|
||||
|
||||
# Headers de Proxy
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# WebSockets (Essencial para apps modernos)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Buffering
|
||||
proxy_buffering on;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
# ==============================================================================
|
||||
# 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;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/katalog.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 - 18:00
|
||||
# VERSÃO: 2.0 (Padrão Autocontido com Hardening de Segurança e Performance)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração autocontida para Snipe-IT. Elimina snippets, integra as
|
||||
# políticas globais de segurança (GeoIP, Rate Limit, Bot Block), e adiciona
|
||||
# otimizações de performance (compressão, cache de navegador).
|
||||
# ==============================================================================
|
||||
|
||||
# Define o nosso servidor Snipe-IT como um "upstream" para fácil referência.
|
||||
upstream snipeit_backend {
|
||||
server 10.10.253.112;
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name katalog.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 Snipe-IT (HTTPS)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name katalog.itguys.com.br;
|
||||
|
||||
# --- CONTROLE DE ACESSO (TRAVA DE SEGURANÇA) ---
|
||||
# Utiliza o bloco 'geo' do nginx.conf para permitir acesso apenas à rede interna.
|
||||
if ($is_internal = 0) {
|
||||
return 403 Forbidden;
|
||||
}
|
||||
|
||||
# --- Logs Dedicados (Padronizado) ---
|
||||
access_log /var/log/nginx/katalog.itguys.com.br.access.log detailed_proxy;
|
||||
access_log /var/log/nginx/katalog.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/katalog.itguys.com.br.error.log warn;
|
||||
|
||||
# --- Segurança (Integração com nginx.conf) ---
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
limit_req zone=global_limit burst=40 nodelay; # Burst maior para interfaces de app
|
||||
limit_req zone=bad_bot_limit;
|
||||
|
||||
# --- Configurações de SSL/TLS (Padrão Autocontido) ---
|
||||
ssl_certificate /etc/letsencrypt/live/katalog.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/katalog.itguys.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/katalog.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;
|
||||
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 (Padrão Autocontido) ---
|
||||
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;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; object-src 'none'; frame-ancestors 'self';" always;
|
||||
|
||||
# --- Otimização de Performance: Compressão Brotli & Gzip ---
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_types text/plain text/css application/json application/javascript text/xml application/xml+rss image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml+rss image/svg+xml;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||
|
||||
# 1. Rota para assets estáticos da UI (CACHE AGRESSIVO de NGINX e Navegador)
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
proxy_pass http://snipeit_backend;
|
||||
|
||||
# --- Parâmetros de Proxy (Autocontido) ---
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# --- Cache de Proxy ---
|
||||
proxy_cache snipeit_cache;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
|
||||
# --- OTIMIZAÇÃO DE PERFORMANCE: Cache de Navegador ---
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE)
|
||||
location / {
|
||||
proxy_pass http://snipeit_backend;
|
||||
|
||||
# --- Parâmetros de Proxy (Autocontido) ---
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# O Snipe-IT precisa de um timeout maior para algumas operações.
|
||||
proxy_read_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
# =================================================================================================
|
||||
# ARQUIVO: mimir.itguys.com.br (Zabbix)
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 - 18:06
|
||||
# VERSÃO: 5.0 (Padrão Autocontido, Correção de SSL e Hardening de Segurança)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração autocontida para Zabbix. Corrige o erro de SSL, elimina snippets,
|
||||
# integra as políticas globais de segurança (GeoIP, Rate Limit, Bot Block) e
|
||||
# mantém as otimizações de performance específicas da aplicação.
|
||||
# =================================================================================================
|
||||
|
||||
# Define o nosso servidor Zabbix como um "upstream" para fácil referência.
|
||||
upstream zabbix_backend {
|
||||
server 172.16.254.11;
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name mimir.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 Zabbix (HTTPS)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name mimir.itguys.com.br;
|
||||
|
||||
# --- CONTROLE DE ACESSO (TRAVA DE SEGURANÇA) ---
|
||||
# Utiliza o bloco 'geo' do nginx.conf para permitir acesso apenas à rede interna.
|
||||
if ($is_internal = 0) {
|
||||
return 403 Forbidden;
|
||||
}
|
||||
|
||||
# --- Logs Dedicados (Padronizado) ---
|
||||
access_log /var/log/nginx/mimir.itguys.com.br.access.log detailed_proxy;
|
||||
access_log /var/log/nginx/mimir.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/mimir.itguys.com.br.error.log warn;
|
||||
|
||||
# --- Segurança (Integração com nginx.conf) ---
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
limit_req zone=global_limit burst=50 nodelay; # Burst alto para dashboards Zabbix
|
||||
limit_req zone=bad_bot_limit;
|
||||
|
||||
# --- Configurações de SSL/TLS (Corrigido e Padronizado) ---
|
||||
ssl_certificate /etc/letsencrypt/live/mimir.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/mimir.itguys.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/mimir.itguys.com.br/fullchain.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off;
|
||||
# CORRIGIDO: Lista de cifras padronizada para máxima compatibilidade e segurança.
|
||||
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_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
# --- Cabeçalhos de Segurança ---
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
# CSP específica para Zabbix, mantida da versão anterior.
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; object-src 'none'; frame-ancestors 'self';" always;
|
||||
|
||||
# --- Configurações de Compressão ---
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_types application/atom+xml application/javascript application/json application/rss+xml text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_types application/atom+xml application/javascript application/json application/rss+xml text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
|
||||
# --- Parâmetros de Proxy Otimizados para Zabbix ---
|
||||
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;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_connect_timeout 90s;
|
||||
proxy_send_timeout 90s;
|
||||
proxy_read_timeout 90s;
|
||||
proxy_buffers 8 16k;
|
||||
proxy_buffer_size 32k;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||
|
||||
# 1. Rota para assets estáticos (CACHE AGRESSIVO de NGINX e Navegador)
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
proxy_pass http://zabbix_backend;
|
||||
|
||||
proxy_cache zabbix_cache;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE)
|
||||
location / {
|
||||
proxy_pass http://zabbix_backend;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/monitoramento.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 07/10/2025 (Corrigido para herança de proxy headers)
|
||||
#
|
||||
# CONTEXTO:
|
||||
# Configuração consolidada e segura para Proxy Reverso do Grafana.
|
||||
# Segue a estrutura centralizada: SSL/TLS e Headers diretos no arquivo.
|
||||
#
|
||||
# UPSTREAM: 172.16.254.13:3000
|
||||
# ==============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# UPSTREAM: Servidor Grafana
|
||||
# ------------------------------------------------------------------------------
|
||||
upstream grafana_backend {
|
||||
server 172.16.254.13:3000;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name monitoramento.itguys.com.br;
|
||||
|
||||
# Aplica o rate limiting (zona global_limit deve estar em nginx.conf)
|
||||
limit_req zone=global_limit burst=20 nodelay;
|
||||
|
||||
# Responde ao desafio do Let's Encrypt
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
# Redireciona todo o resto para HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 2: Servidor Principal - Proxy Reverso para Grafana (HTTPS)
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name monitoramento.itguys.com.br;
|
||||
|
||||
# ============================================================================
|
||||
# LOGS, LIMITAÇÃO E SEGURANÇA BÁSICA
|
||||
# ============================================================================
|
||||
client_max_body_size 10M;
|
||||
access_log /var/log/nginx/monitoramento.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/monitoramento.itguys.com.br.error.log warn;
|
||||
access_log /var/log/nginx/monitoramento.itguys.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
# Módulo de Segurança Global (Bloqueia bots e URIs suspeitas de nginx.conf)
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Rate Limiting (zona global_limit deve estar em nginx.conf)
|
||||
limit_req zone=global_limit burst=100 nodelay;
|
||||
|
||||
# ============================================================================
|
||||
# CONFIGURAÇÕES DE SSL/TLS (Hardening)
|
||||
# ============================================================================
|
||||
ssl_certificate /etc/letsencrypt/live/monitoramento.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/monitoramento.itguys.com.br/privkey.pem;
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# OCSP Stapling
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/monitoramento.itguys.com.br/fullchain.pem;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# ============================================================================
|
||||
# HEADERS DE SEGURANÇA
|
||||
# ============================================================================
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=()" always;
|
||||
|
||||
proxy_hide_header "X-Content-Type-Options";
|
||||
proxy_hide_header "X-Frame-Options";
|
||||
proxy_hide_header "Content-Security-Policy";
|
||||
|
||||
# ============================================================================
|
||||
# COMPRESSÃO
|
||||
# ============================================================================
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 256;
|
||||
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_proxied any;
|
||||
gzip_comp_level 6;
|
||||
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;
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# ROTAS ESPECÍFICAS
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# 1. Rota para assets estáticos do Grafana (/public/) - CACHE AGRESSIVO
|
||||
location /public/ {
|
||||
# --- BLOCO DE PROXY PADRÃO ---
|
||||
proxy_set_header Host $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;
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass http://grafana_backend;
|
||||
# Para assets estáticos, o buffer é benéfico
|
||||
proxy_buffering on;
|
||||
proxy_request_buffering on;
|
||||
|
||||
# Headers de Cache
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 2. Rota para WebSockets do Grafana (/api/live/) - SEM CACHE, LONGO TIMEOUT
|
||||
location /api/live/ {
|
||||
# --- BLOCO DE PROXY PADRÃO ---
|
||||
proxy_set_header Host $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;
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass http://grafana_backend;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
|
||||
# --- HEADERS ESPECÍFICOS PARA WEBSOCKETS ---
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400s; # Timeout longo (24h)
|
||||
}
|
||||
|
||||
# 3. Rota principal para a aplicação (SEM CACHE)
|
||||
location / {
|
||||
# --- BLOCO DE PROXY PADRÃO ---
|
||||
proxy_set_header Host $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;
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass http://grafana_backend;
|
||||
proxy_buffering off; # Essencial para interatividade
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 90s;
|
||||
proxy_send_timeout 90s;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/ns1.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 (Consolidado e otimizado)
|
||||
#
|
||||
# CONTEXTO:
|
||||
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para Technitium DNS Server.
|
||||
# Todas as configurações, incluindo SSL/TLS e segurança, foram declaradas
|
||||
# diretamente neste arquivo, sem o uso de snippets (exigência do padrão).
|
||||
#
|
||||
# UPSTREAM: https://172.16.254.253:53443 (Observar 'proxy_ssl_verify off')
|
||||
# ==============================================================================
|
||||
|
||||
# Define o nosso servidor Technitium como um "upstream".
|
||||
# O NGINX irá se conectar a este backend usando HTTPS.
|
||||
upstream technitium_backend {
|
||||
server 172.16.254.253:53443;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name ns1.itguys.com.br;
|
||||
|
||||
# Aplica o rate limiting básico (zona global_limit deve estar em nginx.conf)
|
||||
limit_req zone=global_limit burst=20 nodelay;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 2: Servidor Principal - Proxy Reverso para Technitium DNS (HTTPS)
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name ns1.itguys.com.br;
|
||||
|
||||
# ============================================================================
|
||||
# LOGS, SEGURANÇA BÁSICA E RATE LIMITING
|
||||
# ============================================================================
|
||||
client_max_body_size 5M; # Tamanho máximo razoável
|
||||
access_log /var/log/nginx/ns1.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/ns1.itguys.com.br.error.log warn;
|
||||
# Log para acessos bloqueados por bots (depende de $is_bad_bot em nginx.conf)
|
||||
access_log /var/log/nginx/ns1.itguys.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
# Módulo de Segurança Global (Bloqueia bots e URIs suspeitas de nginx.conf)
|
||||
if ($block_request) {
|
||||
return 404; # Retorna 404 de forma discreta
|
||||
}
|
||||
|
||||
# Rate Limiting (zona global_limit deve estar em nginx.conf)
|
||||
limit_req zone=global_limit burst=50 nodelay;
|
||||
|
||||
# --- RESTRIÇÃO DE ACESSO (SUBSTITUI SNIPPET internal_networks.conf) ---
|
||||
# Permite apenas as redes que você incluir (exemplo: sua rede local)
|
||||
# Exemplo:
|
||||
# allow 172.16.0.0/16;
|
||||
# allow 10.0.0.0/8;
|
||||
# deny all;
|
||||
# **REMOVA ou AJUSTE AS DIRETIVAS ACIMA CONFORME SUA POLÍTICA DE SEGURANÇA**
|
||||
|
||||
# ============================================================================
|
||||
# CONFIGURAÇÕES DE SSL/TLS (Hardening)
|
||||
# ============================================================================
|
||||
#ssl_certificate /etc/letsencrypt/live/ns1.itguys.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/ns1.itguys.com.br/privkey.pem;
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# OCSP Stapling
|
||||
ssl_stapling off;
|
||||
ssl_stapling_verify off;
|
||||
#ssl_trusted_certificate /etc/letsencrypt/live/ns1.itguys.com.br/fullchain.pem;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# ============================================================================
|
||||
# HEADERS DE SEGURANÇA
|
||||
# ============================================================================
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=()" always;
|
||||
# O Technitium é mais simples, o CSP básico é suficiente
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' wss:; font-src 'self'; object-src 'none';" always;
|
||||
|
||||
# ============================================================================
|
||||
# COMPRESSÃO
|
||||
# ============================================================================
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 256;
|
||||
brotli_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 256;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
|
||||
# ============================================================================
|
||||
# PARÂMETROS GLOBAIS DE PROXY (SUBSTITUI SNIPPET proxy_params.conf)
|
||||
# ============================================================================
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header User-Agent $http_user_agent;
|
||||
proxy_http_version 1.1;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_read_timeout 90s;
|
||||
proxy_send_timeout 90s;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
|
||||
# IMPORTANTE: Desabilita a verificação de certificado para o backend HTTPS
|
||||
# (Necessário se o Technitium estiver usando um certificado autoassinado)
|
||||
proxy_ssl_verify off;
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# REGRAS DE ROTEAMENTO (LOCATIONS)
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# 1. Rota para assets estáticos (CACHE AGRESSIVO)
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
# A zona 'technitium_cache' deve ser definida no seu nginx.conf
|
||||
proxy_cache technitium_cache;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
add_header Cache-Control "public, max-age=604800, immutable"; # Header de cache
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
proxy_pass https://technitium_backend;
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE, COM WEBSOCKETS)
|
||||
location / {
|
||||
# Configurações de WebSockets
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
proxy_pass https://technitium_backend;
|
||||
}
|
||||
|
||||
# --- Páginas de Erro Personalizadas (SUBSTITUI SNIPPET custom_errors.conf) ---
|
||||
# Exemplo:
|
||||
# error_page 403 /403.html;
|
||||
# location = /403.html {
|
||||
# internal;
|
||||
# root /usr/share/nginx/html;
|
||||
# }
|
||||
# error_page 500 502 503 504 /50x.html;
|
||||
# location = /50x.html {
|
||||
# root /usr/share/nginx/html;
|
||||
# }
|
||||
}
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/ns2.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 (Consolidado e otimizado)
|
||||
#
|
||||
# CONTEXTO:
|
||||
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para Technitium DNS Server (ns2).
|
||||
# Todas as configurações, incluindo SSL/TLS e segurança, foram declaradas
|
||||
# diretamente neste arquivo, sem o uso de snippets.
|
||||
#
|
||||
# UPSTREAM: https://172.16.254.251:53443 (Observar 'proxy_ssl_verify off')
|
||||
# ==============================================================================
|
||||
|
||||
# Define o nosso servidor Technitium como um "upstream".
|
||||
# O NGINX irá se conectar a este backend usando HTTPS.
|
||||
upstream technitium_backend_ns2 {
|
||||
server 172.16.254.251:53443;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name ns2.itguys.com.br;
|
||||
|
||||
# Aplica o rate limiting básico (zona global_limit deve estar em nginx.conf)
|
||||
limit_req zone=global_limit burst=20 nodelay;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 2: Servidor Principal - Proxy Reverso para Technitium DNS (HTTPS)
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name ns2.itguys.com.br;
|
||||
|
||||
# ============================================================================
|
||||
# LOGS, SEGURANÇA BÁSICA E RATE LIMITING
|
||||
# ============================================================================
|
||||
client_max_body_size 5M;
|
||||
access_log /var/log/nginx/ns2.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/ns2.itguys.com.br.error.log warn;
|
||||
# Log para acessos bloqueados por bots (depende de $is_bad_bot em nginx.conf)
|
||||
access_log /var/log/nginx/ns2.itguys.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
# Módulo de Segurança Global (Bloqueia bots e URIs suspeitas de nginx.conf)
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Rate Limiting (zona global_limit deve estar em nginx.conf)
|
||||
limit_req zone=global_limit burst=50 nodelay;
|
||||
|
||||
# --- RESTRIÇÃO DE ACESSO ---
|
||||
# **INCLUIR REGRAS 'allow' e 'deny' AQUI**
|
||||
# Exemplo:
|
||||
# allow 172.16.0.0/16;
|
||||
# deny all;
|
||||
|
||||
# ============================================================================
|
||||
# CONFIGURAÇÕES DE SSL/TLS (Hardening)
|
||||
# ============================================================================
|
||||
#ssl_certificate /etc/letsencrypt/live/ns2.itguys.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/ns2.itguys.com.br/privkey.pem;
|
||||
#ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# OCSP Stapling
|
||||
ssl_stapling off;
|
||||
ssl_stapling_verify off;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/ns2.itguys.com.br/fullchain.pem;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# ============================================================================
|
||||
# HEADERS DE SEGURANÇA
|
||||
# ============================================================================
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=()" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' wss:; font-src 'self'; object-src 'none';" always;
|
||||
|
||||
# ============================================================================
|
||||
# COMPRESSÃO
|
||||
# ============================================================================
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 256;
|
||||
brotli_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 256;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
|
||||
# ============================================================================
|
||||
# PARÂMETROS GLOBAIS DE PROXY
|
||||
# ============================================================================
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header User-Agent $http_user_agent;
|
||||
proxy_http_version 1.1;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_read_timeout 90s;
|
||||
proxy_send_timeout 90s;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
|
||||
# IMPORTANTE: Desabilita a verificação de certificado para o backend HTTPS
|
||||
proxy_ssl_verify off;
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# REGRAS DE ROTEAMENTO (LOCATIONS)
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# 1. Rota para assets estáticos (CACHE AGRESSIVO)
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
# Reutiliza a mesma zona de cache do ns1
|
||||
proxy_cache technitium_cache;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
add_header Cache-Control "public, max-age=604800, immutable";
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
proxy_pass https://technitium_backend_ns2;
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE, COM WEBSOCKETS)
|
||||
location / {
|
||||
# Configurações de WebSockets
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
proxy_pass https://technitium_backend_ns2;
|
||||
}
|
||||
|
||||
# --- Páginas de Erro Personalizadas ---
|
||||
# Incluir aqui as diretivas de error_page, se necessário.
|
||||
}
|
||||
|
|
@ -1,189 +0,0 @@
|
|||
# ====================================================================================
|
||||
# ARQUIVO DE CONFIGURAÇÃO NGINX
|
||||
# ------------------------------------------------------------------------------------
|
||||
# SITE: petytransportes.com.br (Proxy Reverso para WordPress)
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA DA ALTERAÇÃO: 2025-10-14 (v4 - Versão Final)
|
||||
#
|
||||
# CONTEXTO:
|
||||
# - Arquivo final com diretivas SSL descomentadas, pronto para produção.
|
||||
# - Log condicional para bad bots implementado com o parâmetro 'if='.
|
||||
# - Estrutura de cache, segurança e performance otimizada para WordPress.
|
||||
# ====================================================================================
|
||||
|
||||
# --- Definição da zona de rate limit para a página de login do WordPress ---
|
||||
limit_req_zone $binary_remote_addr zone=pety_wp_login:10m rate=5r/m;
|
||||
|
||||
# ====================================================================================
|
||||
# SERVIDOR HTTP (PORTA 80) - REDIRECIONAMENTO PARA HTTPS
|
||||
# ====================================================================================
|
||||
server {
|
||||
if ($host = www.petytransportes.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
if ($host = petytransportes.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name petytransportes.com.br www.petytransportes.com.br;
|
||||
|
||||
access_log /var/log/nginx/petytransportes.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/petytransportes.com.br.error.log warn;
|
||||
|
||||
# --- Rota para Renovação de Certificado SSL (Let's Encrypt) ---
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
}
|
||||
|
||||
# --- Redirecionamento Permanente para HTTPS ---
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
# ====================================================================================
|
||||
# SERVIDOR HTTPS (PORTA 443) - CONFIGURAÇÃO PRINCIPAL
|
||||
# ====================================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name petytransportes.com.br www.petytransportes.com.br;
|
||||
|
||||
# --- Logs Dedicados do Site ---
|
||||
access_log /var/log/nginx/petytransportes.com.br.access.log detailed_proxy if=!$block_request;
|
||||
access_log /var/log/nginx/petytransportes.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/petytransportes.com.br.error.log warn;
|
||||
|
||||
# ------------------------------------------------
|
||||
# Segurança
|
||||
# ------------------------------------------------
|
||||
# --- BLOQUEIO DE BOTS E URIs MALICIOSAS ---
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# --- Proteção contra acesso a arquivos sensíveis ---
|
||||
location ~ /\. { deny all; }
|
||||
location ~* /(?:setup\.php|README\.md|readme\.html|license\.txt|wp-config-sample\.php|web\.config) { deny all; }
|
||||
location ~* \.(env|git|svn|bak|sql|zip|tar\.gz)$ { deny all; }
|
||||
location = /xmlrpc.php { deny all; }
|
||||
|
||||
# ------------------------------------------------
|
||||
# Configuração SSL/TLS
|
||||
# ------------------------------------------------
|
||||
#ssl_certificate /etc/letsencrypt/live/petytransportes.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/petytransportes.com.br/privkey.pem;
|
||||
#ssl_trusted_certificate /etc/letsencrypt/live/petytransportes.com.br/fullchain.pem;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
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_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
|
||||
resolver 8.8.8.8 1.1.1.1 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
# ------------------------------------------------
|
||||
# Headers 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 Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
|
||||
# ------------------------------------------------
|
||||
# Compressão (Brotli e Gzip)
|
||||
# ------------------------------------------------
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 1024;
|
||||
brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1024;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 5;
|
||||
gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
|
||||
|
||||
# ------------------------------------------------
|
||||
# Locations (Regras de Proxy Reverso)
|
||||
# ------------------------------------------------
|
||||
|
||||
# --- PROTEÇÃO PARA A PÁGINA DE LOGIN ---
|
||||
location = /wp-login.php {
|
||||
limit_req zone=pety_wp_login burst=3 nodelay;
|
||||
|
||||
proxy_pass https://172.16.12.2;
|
||||
proxy_set_header Host $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;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name $host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 90s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# --- CACHE PARA ARQUIVOS ESTÁTICOS ---
|
||||
location ~* \.(jpg|jpeg|gif|png|webp|svg|ico|css|js|woff|woff2|ttf|eot)$ {
|
||||
proxy_pass https://172.16.12.2;
|
||||
proxy_set_header Host $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;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name $host;
|
||||
|
||||
proxy_cache static_cache;
|
||||
proxy_cache_key "$scheme$request_method$host$request_uri";
|
||||
proxy_cache_valid 200 304 90d;
|
||||
proxy_cache_valid any 1m;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_cache_lock on;
|
||||
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
expires 90d;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# --- REGRA GERAL PARA O WORDPRESS ---
|
||||
location / {
|
||||
proxy_pass https://172.16.12.2;
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name $host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_connect_timeout 90s;
|
||||
proxy_send_timeout 90s;
|
||||
proxy_read_timeout 90s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/petytransportes.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/petytransportes.com.br/privkey.pem; # managed by Certbot
|
||||
|
||||
}
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
# ====================================================================================
|
||||
# Configuração NGINX para: pralog.com.br (Proxy Reverso para WordPress)
|
||||
# Data da Criação/Alteração: 2025-10-08 (v3 - Compressão e Hardening TLS)
|
||||
#
|
||||
# Contexto:
|
||||
# - Adicionada compressão Brotli e Gzip para otimizar a entrega de assets.
|
||||
# - Realizado hardening na configuração SSL/TLS para nota A+ e compatibilidade Apple.
|
||||
# - Limpeza do bloco de redirecionamento HTTP.
|
||||
# ====================================================================================
|
||||
|
||||
# --- Definições Globais (fora do bloco 'server') ---
|
||||
limit_req_zone $binary_remote_addr zone=wp_login:10m rate=5r/m;
|
||||
|
||||
map $http_user_agent $block_bad_bots {
|
||||
default 0;
|
||||
"~*(sqlmap|nikto|wpscan|python-requests|curl|wget|nmap)" 1;
|
||||
"~*(nessus|acunetix|masscan|zgrab)" 1;
|
||||
"~*BLEXBot" 1;
|
||||
}
|
||||
|
||||
# --- Servidor HTTP (Porta 80) -> Redirecionamento para HTTPS (Formato Limpo) ---
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name pralog.com.br www.pralog.com.br;
|
||||
|
||||
access_log /var/log/nginx/pralog.com.br.redirects.log;
|
||||
error_log /var/log/nginx/pralog.com.br.redirects.error.log;
|
||||
|
||||
# Exceção para o ACME Challenge (Let's Encrypt)
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
}
|
||||
|
||||
# Redirecionamento permanente e limpo para HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# --- Servidor HTTPS (Porta 443) - Configuração Principal ---
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name pralog.com.br www.pralog.com.br;
|
||||
|
||||
root /var/www/html; # Fallback
|
||||
|
||||
# Logs Específicos do Site
|
||||
access_log /var/log/nginx/pralog.com.br.access.log;
|
||||
error_log /var/log/nginx/pralog.com.br.error.log warn;
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# SSL/TLS - Hardening para Nota A+ e Compatibilidade
|
||||
# -----------------------------------------------------------------
|
||||
ssl_certificate /etc/letsencrypt/live/pralog.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/pralog.com.br/privkey.pem;
|
||||
|
||||
# Adicionado TLS 1.3 e uma suíte de ciphers mais ampla para compatibilidade
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
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_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# Resolver para OCSP Stapling funcionar corretamente
|
||||
resolver 8.8.8.8 1.1.1.1 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/pralog.com.br/fullchain.pem;
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Headers 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 Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Compressão (Brotli e Gzip)
|
||||
# -----------------------------------------------------------------
|
||||
# Brotli (prioridade se o navegador suportar)
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 1024; # Não comprime arquivos menores que 1024 bytes
|
||||
brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
|
||||
|
||||
# Gzip (fallback para navegadores sem suporte a Brotli)
|
||||
gzip on;
|
||||
gzip_min_length 1024; # Não comprime arquivos menores que 1024 bytes
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 5;
|
||||
gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
|
||||
|
||||
# ... (Restante do arquivo permanece o mesmo) ...
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Proteção Contra Bots e Acessos Indevidos
|
||||
# -----------------------------------------------------------------
|
||||
if ($block_bad_bots) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location ~ /\. { deny all; }
|
||||
location ~* /(?:setup\.php|README\.md|readme\.html|license\.txt|wp-config-sample\.php|web\.config) { deny all; }
|
||||
location ~* \.(env|git|svn|bak|sql|zip|tar\.gz)$ { deny all; }
|
||||
location = /xmlrpc.php { deny all; }
|
||||
|
||||
# ... (O restante das suas configurações de location permanecem iguais)
|
||||
location = /wp-login.php {
|
||||
limit_req zone=wp_login burst=3 nodelay;
|
||||
proxy_pass https://172.16.12.25;
|
||||
proxy_set_header Host $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;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name $host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 90s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location ~* \.(jpg|jpeg|gif|png|webp|svg|ico|css|js|woff|woff2|ttf|eot)$ {
|
||||
proxy_pass https://172.16.12.25;
|
||||
proxy_set_header Host $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;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name $host;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass https://172.16.12.25;
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name $host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_connect_timeout 90s;
|
||||
proxy_send_timeout 90s;
|
||||
proxy_read_timeout 90s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
server {
|
||||
if ($host = proxy.itguys.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
server_name proxy.itguys.com.br;
|
||||
include /etc/nginx/snippets/custom_errors.conf; # Carrega as páginas de erro personalizadas
|
||||
|
||||
# ---- CONTROLE DE ACESSO ----
|
||||
# 1. Inclui o arquivo de restrição de IPs
|
||||
#include /etc/nginx/conf.d/internal_networks.conf;
|
||||
# ---- FIM DO CONTROLE DE ACESSO ----
|
||||
|
||||
# Redireciona para HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name proxy.itguys.com.br;
|
||||
include /etc/nginx/snippets/custom_errors.conf; # Carrega as páginas de erro personalizadas
|
||||
|
||||
# --- CAMINHO PARA OS CERTIFICADOS SSL (Será preenchido pelo Certbot) ---
|
||||
# ssl_certificate /etc/letsencrypt/live/proxy.itguys.com.br/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/proxy.itguys.com.br/privkey.pem;
|
||||
|
||||
# ---- CONTROLE DE ACESSO (Repetido para HTTPS) ----
|
||||
include /etc/nginx/conf.d/internal_networks.conf;
|
||||
error_page 403 @acesso_negado;
|
||||
|
||||
# Localização do relatório HTML estático
|
||||
location / {
|
||||
root /var/www/html/goaccess;
|
||||
index report.html;
|
||||
}
|
||||
|
||||
# Localização do WebSocket para atualizações em tempo real
|
||||
location /ws {
|
||||
# O GoAccess por padrão abre o websocket na porta 7890
|
||||
proxy_pass http://127.0.0.1:7890;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# ---- BLOCO QUE GERA A NOSSA PÁGINA DE ERRO 403 PERSONALIZADA ----
|
||||
#
|
||||
# O @ significa que esta é uma localização "nomeada" e só pode ser
|
||||
# acessada internamente pelo Nginx, não diretamente por um usuário.
|
||||
location @acesso_negado {
|
||||
default_type text/html;
|
||||
charset utf-8;
|
||||
|
||||
# Retornamos o código de status 403 (correto para o erro)
|
||||
# mas com o nosso próprio conteúdo HTML.
|
||||
# A variável $remote_addr mostrará ao usuário o IP que foi bloqueado.
|
||||
return 403 '<html><head><title>Acesso Negado</title><meta charset="UTF-8"><style>body{font-family: Arial, sans-serif; text-align: center; margin-top: 50px; background-color: #f2f2f2; color: #333;}</style></head><body><h1>403 - Acesso Negado</h1><p>O acesso a este recurso é restrito e permitido apenas a partir de redes autorizadas.</p><p>Seu endereço de IP (<strong>$remote_addr</strong>) não está na lista de permissões.</p></body></html>';
|
||||
}
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/proxy.itguys.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/proxy.itguys.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
# ==========================================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/rhema.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 2025-10-14
|
||||
# VERSÃO: 1.0
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de proxy reverso para o sistema Rhema, com foco em segurança e
|
||||
# performance de cache para múltiplos usuários.
|
||||
# - Integração com políticas globais de segurança (bot block, rate limit).
|
||||
# - Otimizações de SSL/TLS e headers de segurança.
|
||||
# - Compressão Brotli e Gzip.
|
||||
# - Logs dedicados e cache agressivo para arquivos estáticos.
|
||||
# ==========================================================================================
|
||||
|
||||
# UPSTREAM: Define o servidor backend da aplicação.
|
||||
upstream rhema_backend {
|
||||
server 172.16.121.1;
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO 1: Servidor HTTP (Porta 80)
|
||||
# - Responde ao desafio Let's Encrypt.
|
||||
# - Redireciona todo o tráfego para HTTPS.
|
||||
# ======================================================================
|
||||
server {
|
||||
if ($host = rhema.itguys.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name rhema.itguys.com.br;
|
||||
|
||||
# Local para validação do Certbot.
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
# Redirecionamento permanente para HTTPS.
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO 2: Servidor HTTPS (Porta 443)
|
||||
# - Bloco principal com todas as otimizações e configurações de segurança.
|
||||
# ======================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name rhema.itguys.com.br;
|
||||
|
||||
# --- Configurações Gerais e Logs Dedicados ---
|
||||
client_max_body_size 50M;
|
||||
access_log /var/log/nginx/rhema.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/rhema.itguys.com.br.error.log warn;
|
||||
access_log /var/log/nginx/rhema.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
|
||||
# --- Módulo de Segurança Global (integrado com nginx.conf) ---
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
limit_req zone=global_limit burst=100 nodelay;
|
||||
|
||||
# --- Parâmetros de SSL/TLS (Best Practices) ---
|
||||
# O Certbot irá gerenciar os caminhos abaixo.
|
||||
#ssl_certificate /etc/letsencrypt/live/rhema.itguys.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/rhema.itguys.com.br/privkey.pem;
|
||||
#ssl_trusted_certificate /etc/letsencrypt/live/rhema.itguys.com.br/fullchain.pem;
|
||||
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
|
||||
# OCSP Stapling
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# --- Cabeçalhos de Segurança Otimizados ---
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(self), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(self), payment=()" always;
|
||||
|
||||
# --- Compressão (Brotli e Gzip) ---
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_types application/atom+xml application/javascript application/json text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types application/atom+xml application/javascript application/json text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO E CACHE ---
|
||||
|
||||
# 1. Rota para assets estáticos (CACHE OTIMIZADO)
|
||||
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
proxy_pass http://rhema_backend;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
# Parâmetros de cache do NGINX
|
||||
proxy_cache rhema_cache; # ATENÇÃO: Zona de cache dedicada
|
||||
proxy_cache_valid 200 30d;
|
||||
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;
|
||||
|
||||
# Headers de cache para o navegador (30 dias)
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE)
|
||||
location / {
|
||||
proxy_pass http://rhema_backend;
|
||||
|
||||
# Cabeçalhos essenciais para a aplicação backend.
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Suporte para WebSockets.
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400s;
|
||||
}
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/rhema.itguys.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/rhema.itguys.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
# ==========================================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/solucionei.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 2025-10-15
|
||||
# VERSÃO: 2.0
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de proxy reverso para Solucionei, atuando como ponto único de terminação SSL,
|
||||
# segurança e cache.
|
||||
# - Proxy se comunica com o backend via HTTP para maior performance.
|
||||
# - Centraliza todos os headers de segurança, incluindo CSP importado da aplicação.
|
||||
# - Cache otimizado para assets estáticos e tratamento de rotas da API.
|
||||
# - Integração completa com as políticas globais de segurança (bot block, rate limit).
|
||||
# - Otimizações de SSL/TLS, incluindo OCSP Stapling.
|
||||
# - Compressão Brotli e Gzip.
|
||||
# - Logs dedicados para monitoramento completo.
|
||||
# ==========================================================================================
|
||||
|
||||
# UPSTREAM: Define o servidor backend da aplicação (comunicação via HTTP).
|
||||
upstream solucionei_backend {
|
||||
# ATENÇÃO: O backend deve responder na porta 80.
|
||||
server 172.16.121.16:80;
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO 1: Servidor HTTP (Porta 80)
|
||||
# - Responde ao desafio Let's Encrypt.
|
||||
# - Redireciona todo o tráfego para HTTPS.
|
||||
# ======================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name solucionei.itguys.com.br;
|
||||
|
||||
# Local para validação do Certbot.
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
# Redirecionamento permanente para HTTPS.
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO 2: Servidor HTTPS (Porta 443)
|
||||
# - Bloco principal com todas as otimizações e configurações de segurança.
|
||||
# ======================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name solucionei.itguys.com.br;
|
||||
|
||||
# --- Configurações Gerais e Logs Dedicados ---
|
||||
client_max_body_size 50M;
|
||||
access_log /var/log/nginx/solucionei.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/solucionei.itguys.com.br.error.log warn;
|
||||
access_log /var/log/nginx/solucionei.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
|
||||
# --- Módulo de Segurança Global (integrado com nginx.conf) ---
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
limit_req zone=global_limit burst=100 nodelay;
|
||||
|
||||
# --- Parâmetros de SSL/TLS (Gerenciados pelo Certbot) ---
|
||||
ssl_certificate /etc/letsencrypt/live/solucionei.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/solucionei.itguys.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/solucionei.itguys.com.br/fullchain.pem;
|
||||
|
||||
# --- Otimizações de SSL/TLS (Best Practices) ---
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
|
||||
# OCSP Stapling
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# --- Cabeçalhos de Segurança Otimizados e Centralizados ---
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always; # SAMEORIGIN é mais flexível que DENY para iframes internos.
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(self), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(self), payment=()" always;
|
||||
|
||||
# CSP importado da configuração do backend, para testes. Mude para 'add_header Content-Security-Policy' para produção.
|
||||
add_header Content-Security-Policy-Report-Only "default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; font-src 'self' https://cdn.jsdelivr.net data:; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; report-uri /csp-report-endpoint;" always;
|
||||
|
||||
# --- Compressão (Brotli e Gzip) ---
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_types application/atom+xml application/javascript application/json text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types application/atom+xml application/javascript application/json text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO E CACHE ---
|
||||
|
||||
# 1. Rota para assets estáticos (CACHE OTIMIZADO)
|
||||
# Cacheia agressivamente arquivos que não mudam com frequência, incluindo os de /uploads/.
|
||||
location ~* \.(?:svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
proxy_pass http://solucionei_backend;
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Parâmetros de cache do NGINX
|
||||
proxy_cache solucionei_cache;
|
||||
proxy_cache_valid 200 30d;
|
||||
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;
|
||||
|
||||
# Headers de cache para o navegador (30 dias)
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE)
|
||||
location / {
|
||||
proxy_pass http://solucionei_backend;
|
||||
|
||||
# Cabeçalhos essenciais para a aplicação backend.
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Suporte para WebSockets.
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400s;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/telefonia.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 (Corrigido para problemas de MIME/404/403)
|
||||
#
|
||||
# CONTEXTO:
|
||||
# Proxy Reverso Seguro e Otimizado para MagnusBilling (PHP/Apache).
|
||||
# Assegura a passagem correta do caminho /mbilling/ sem NGINX rewrite.
|
||||
# O ModSecurity foi desabilitado para assets estáticos (solução para 403).
|
||||
#
|
||||
# UPSTREAM: 172.16.254.130 (Backend HTTP)
|
||||
# ==============================================================================
|
||||
|
||||
# Bloco Upstream: Define o servidor de backend da aplicação.
|
||||
upstream magnusbilling_backend {
|
||||
server 172.16.254.130;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name telefonia.itguys.com.br;
|
||||
|
||||
# Aplica o rate limiting básico (zona global_limit deve estar em nginx.conf)
|
||||
limit_req zone=global_limit burst=20 nodelay;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
# Redireciona permanentemente todo o resto para a versão segura.
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# BLOCO 2: Servidor Principal HTTPS (porta 443)
|
||||
# ------------------------------------------------------------------------------
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name telefonia.itguys.com.br;
|
||||
|
||||
# ============================================================================
|
||||
# LOGS, SEGURANÇA BÁSICA E RATE LIMITING
|
||||
# ============================================================================
|
||||
client_max_body_size 25M;
|
||||
access_log /var/log/nginx/telefonia.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/telefonia.itguys.com.br.error.log warn;
|
||||
access_log /var/log/nginx/telefonia.itguys.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
if ($block_request) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
limit_req zone=global_limit burst=50 nodelay;
|
||||
|
||||
# ============================================================================
|
||||
# CONFIGURAÇÕES DE SSL/TLS (Hardening)
|
||||
# ============================================================================
|
||||
ssl_certificate /etc/letsencrypt/live/telefonia.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/telefonia.itguys.com.br/privkey.pem;
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
ssl_session_tickets off;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/telefonia.itguys.com.br/fullchain.pem;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# ============================================================================
|
||||
# HEADERS DE SEGURANÇA
|
||||
# ============================================================================
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=()" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; font-src 'self'; object-src 'none';" always;
|
||||
|
||||
# ============================================================================
|
||||
# COMPRESSÃO
|
||||
# ============================================================================
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 256;
|
||||
brotli_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 256;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
|
||||
# ============================================================================
|
||||
# PARÂMETROS GLOBAIS DE PROXY
|
||||
# ============================================================================
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header User-Agent $http_user_agent;
|
||||
proxy_http_version 1.1;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_read_timeout 90s;
|
||||
proxy_send_timeout 90s;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
proxy_redirect off;
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# REGRAS DE ROTEAMENTO (LOCATIONS)
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# 1. Rota para assets estáticos e arquivos de recurso - SOLUÇÃO MIME/403
|
||||
# Esta location é mais específica e desabilita ModSec para assets (logo.ico, js, json, etc.).
|
||||
location ~* /mbilling/.*\.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot|json|xml|mp3|wav|ogg)$ {
|
||||
|
||||
# DESABILITA ModSecurity (Solução para 403 Forbidden)
|
||||
# modsecurity off; # Directive disabled for NGINX Proxy (ModSecurity handles this externally now)
|
||||
|
||||
# Configurações de Cache
|
||||
proxy_cache magnusbilling_cache;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
add_header Cache-Control "public, max-age=604800, immutable";
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
|
||||
proxy_pass http://magnusbilling_backend;
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (/mbilling/)
|
||||
# Lida com todas as requisições dinâmicas (URLs limpas, index.php, WebSockets).
|
||||
location /mbilling/ {
|
||||
# Configurações para suportar WebSockets
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Rate Limiting de login (zona 'login_limit' deve ser definida em nginx.conf)
|
||||
limit_req zone=global_limit burst=5 nodelay;
|
||||
|
||||
proxy_pass http://magnusbilling_backend;
|
||||
}
|
||||
|
||||
# 3. Redirecionamento da Raiz
|
||||
location = / {
|
||||
return 302 /mbilling/;
|
||||
}
|
||||
|
||||
# 4. Bloqueio de arquivos e diretórios sensíveis
|
||||
location ~* /(?:composer\.(?:json|lock)|vendor/|etc/|var/|temp/|\.git/|\.env|setup\.php|install\.php) {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO TEMPORÁRIO: Teste de Conectividade
|
||||
# REMOVER APÓS VALIDAÇÃO DA TAREFA 4
|
||||
# ==============================================================================
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
server_name localhost test-connectivity;
|
||||
|
||||
# Health check simples
|
||||
location /health {
|
||||
return 200 "OK - nginx-proxy respondendo\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# Teste 1: Ping para 10.10.253.254
|
||||
location /test/254 {
|
||||
proxy_pass http://10.10.253.254/;
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_read_timeout 10s;
|
||||
error_page 502 504 = @test_failed;
|
||||
}
|
||||
|
||||
# Teste 2: Ping para 10.10.253.128 (Gitea - porta 3000)
|
||||
location /test/128 {
|
||||
proxy_pass http://10.10.253.128:3000/;
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_read_timeout 10s;
|
||||
error_page 502 504 = @test_failed;
|
||||
}
|
||||
|
||||
# Teste 3: Acesso via host.docker.internal (rede do host)
|
||||
location /test/host {
|
||||
# Tenta acessar a porta 80 do próprio host
|
||||
proxy_pass http://host.docker.internal/;
|
||||
proxy_connect_timeout 5s;
|
||||
error_page 502 504 = @test_failed;
|
||||
}
|
||||
|
||||
# Fallback para testes que falharam
|
||||
location @test_failed {
|
||||
return 503 "FALHA: Não foi possível conectar ao backend\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
# =========================================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/unifi.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 27/09/2025 - 17:32
|
||||
# VERSÃO: 7.0 (Correção de Ciphers SSL, Hardening de Segurança e Padronização)
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de Proxy Reverso OTIMIZADA e SEGURA para a interface UniFi.
|
||||
# Esta versão corrige o erro de SSL, implementa as políticas globais de segurança
|
||||
# e resolve a vulnerabilidade de verificação do SSL do backend.
|
||||
# =========================================================================================
|
||||
|
||||
# --- DEFINIÇÃO DOS BACKENDS ---
|
||||
upstream unifi_backend_web {
|
||||
server 172.16.254.123:8443;
|
||||
}
|
||||
upstream unifi_backend_inform {
|
||||
server 172.16.254.123:8080;
|
||||
}
|
||||
|
||||
# =========================================================================================
|
||||
# BLOCO 1: Redirecionamento de HTTP (porta 80) para HTTPS
|
||||
# =========================================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name unifi.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 a Interface Web (HTTPS)
|
||||
# =========================================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name unifi.itguys.com.br;
|
||||
|
||||
# --- Logs Dedicados (Padronizado) ---
|
||||
access_log /var/log/nginx/unifi.itguys.com.br.access.log detailed_proxy;
|
||||
access_log /var/log/nginx/unifi.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
error_log /var/log/nginx/unifi.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 e Padronizado) ---
|
||||
ssl_certificate /etc/letsencrypt/live/unifi.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/unifi.itguys.com.br/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/unifi.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;
|
||||
# CORRIGIDO: Lista de cifras padronizada para máxima compatibilidade e segurança.
|
||||
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 ---
|
||||
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 específica para UniFi, mantida da versão anterior.
|
||||
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' wss:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://static.ui.com https://images.svc.ui.com; font-src 'self' data:; object-src 'none'; frame-ancestors 'self';" always;
|
||||
|
||||
# --- Compressão ---
|
||||
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 image/svg+xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml;
|
||||
|
||||
# --- ROTA PARA A APLICAÇÃO ---
|
||||
location / {
|
||||
proxy_pass https://unifi_backend_web;
|
||||
|
||||
# CORREÇÃO DE SEGURANÇA: Habilita a verificação do certificado SSL do backend.
|
||||
proxy_ssl_verify off;
|
||||
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name unifi.itguys.com.br;
|
||||
|
||||
# --- Cabeçalhos Essenciais para UniFi ---
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# --- Cabeçalhos para WebSocket ---
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_read_timeout 86400; # Timeout longo para manter a conexão
|
||||
}
|
||||
}
|
||||
|
||||
# =========================================================================================
|
||||
# BLOCO 3: Servidor para o "Inform" dos Dispositivos (HTTP na porta 8080)
|
||||
# =========================================================================================
|
||||
server {
|
||||
listen 8080;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:8080;
|
||||
server_name unifi.itguys.com.br;
|
||||
|
||||
access_log /var/log/nginx/unifi.itguys.com.br-inform.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/unifi.itguys.com.br-inform.error.log warn;
|
||||
|
||||
location / {
|
||||
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;
|
||||
proxy_read_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
proxy_pass http://unifi_backend_inform;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
# ==============================================================================
|
||||
# Arquivo de configuração NGINX para: vcenter.itguys.com.br
|
||||
# Data da Modificação: 2025-10-06 12:00
|
||||
#
|
||||
# Contexto:
|
||||
# Versão final e corrigida.
|
||||
# - Proxy reverso de HTTPS (cliente) para HTTPS (backend vCenter).
|
||||
# - Resolve o loop de redirect e o erro 502 Bad Gateway.
|
||||
# - Inclui diretivas para confiar no certificado auto-assinado do vCenter.
|
||||
# - Preparado para certificados Let's Encrypt.
|
||||
# ==============================================================================
|
||||
|
||||
# Define o servidor backend do vCenter para facilitar a manutenção
|
||||
upstream vcenter_backend {
|
||||
# Aponta para a porta HTTPS do vCenter
|
||||
server 172.16.254.110:443;
|
||||
}
|
||||
|
||||
# Servidor para redirecionamento de HTTP para HTTPS (Porta 80)
|
||||
# O Certbot (Let's Encrypt) usará este bloco para validação.
|
||||
server {
|
||||
if ($host = vcenter.itguys.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name vcenter.itguys.com.br;
|
||||
|
||||
# Força o uso de HTTPS com um redirecionamento 301 (permanente)
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
# Servidor principal que lida com o tráfego HTTPS (Porta 443)
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
listen [::]:443 ssl;
|
||||
server_name vcenter.itguys.com.br;
|
||||
|
||||
# --- Logs ---
|
||||
access_log /var/log/nginx/vcenter.itguys.com.br.access.log;
|
||||
error_log /var/log/nginx/vcenter.itguys.com.br.error.log warn;
|
||||
|
||||
# --- Configurações de SSL/TLS (Let's Encrypt) ---
|
||||
# O Certbot irá criar e preencher estes caminhos automaticamente.
|
||||
#ssl_certificate /etc/letsencrypt/live/vcenter.itguys.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/vcenter.itguys.com.br/privkey.pem;
|
||||
|
||||
# Substituindo include por config explícita para evitar erro de arquivo inexistente
|
||||
# include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
|
||||
#ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
|
||||
# --- 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 Referrer-Policy "no-referrer" always;
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_types application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/xml;
|
||||
brotli_min_length 1024; # Compressão a partir de 1024 bytes
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any; # Compacta respostas de proxy
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_min_length 1024; # Compressão a partir de 1024 bytes
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
|
||||
|
||||
# --- Cache de Proxy para Ativos Estáticos ---
|
||||
# Cacheia arquivos estáticos comuns servidos pelo backend
|
||||
location ~* \.(css|js|jpg|jpeg|gif|png|svg|ico|woff|woff2|ttf|eot)$ {
|
||||
# --- Configurações do Proxy (Idênticas ao /) ---
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $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;
|
||||
proxy_connect_timeout 600;
|
||||
proxy_send_timeout 600;
|
||||
proxy_read_timeout 600;
|
||||
proxy_buffers 32 4k;
|
||||
#proxy_ssl_trusted_certificate /etc/nginx/ssl/vcenter_backend.pem;
|
||||
#proxy_ssl_verify on;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name vcenter.itguys.com.br;
|
||||
proxy_pass https://vcenter_backend;
|
||||
|
||||
# --- Diretivas de Cache ---
|
||||
proxy_cache vcenter_cache;
|
||||
proxy_cache_valid 200 302 60m;
|
||||
proxy_cache_valid 404 1m;
|
||||
proxy_cache_key "$scheme$request_method$host$request_uri";
|
||||
proxy_cache_min_uses 1;
|
||||
proxy_cache_lock on;
|
||||
|
||||
# Adiciona um header para debug (verificar se o cache está HIT/MISS/BYPASS)
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
}
|
||||
|
||||
# --- Configurações do Proxy Reverso ---
|
||||
location / {
|
||||
# --- Suporte a WebSocket ---
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# --- Cabeçalhos do Proxy ---
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# --- Timeouts e Buffers ---
|
||||
proxy_connect_timeout 600;
|
||||
proxy_send_timeout 600;
|
||||
proxy_read_timeout 600;
|
||||
proxy_buffers 32 4k;
|
||||
|
||||
# --- Confiança no Certificado Backend (Auto-assinado) ---
|
||||
# Aponte para o certificado público do vCenter que extraímos.
|
||||
#proxy_ssl_trusted_certificate /etc/nginx/ssl/vcenter_backend.pem;
|
||||
#proxy_ssl_verify on;
|
||||
|
||||
# Resolve o erro 502 Bad Gateway (problema de SNI).
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name vcenter.itguys.com.br;
|
||||
|
||||
# Aponta o tráfego para o vCenter Server via HTTPS.
|
||||
proxy_pass https://vcenter_backend;
|
||||
}
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/vcenter.itguys.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/vcenter.itguys.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
|
@ -1,218 +0,0 @@
|
|||
# ----------------------------------------------------------------------
|
||||
# Configuração: Nextcloud AIO + Office Online Server (Nativo)
|
||||
# Data: 2025-10-25
|
||||
# Domínio: verbocloud.itguys.com.br
|
||||
#
|
||||
# Arquitetura:
|
||||
# - Nginx (Este servidor)
|
||||
# - Backend AIO: 172.16.253.13:11500 (HTTP)
|
||||
# - Backend OOS: 172.16.253.13:80 (HTTPS - Nativo no Windows)
|
||||
#
|
||||
# ATUALIZAÇÃO:
|
||||
# - Adicionado Bloco para Nextcloud Talk (HPB / Push).
|
||||
# - Adicionado Micro-cache de API (para otimizar Photos, Deck, Notes, etc.)
|
||||
# - Diretórios de cache EXCLUSIVOS para este site.
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Definições de Cache (EXCLUSIVOS para verbocloud)
|
||||
# ----------------------------------------------------------------------
|
||||
proxy_cache_path /var/cache/nginx/verbocloud_session_cache levels=1:2 keys_zone=verbocloud_session_cache:10m inactive=60m max_size=100m;
|
||||
proxy_cache_path /var/cache/nginx/verbocloud_foldertree_cache levels=1:2 keys_zone=verbocloud_foldertree_cache:10m inactive=1m max_size=100m;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Declaração dos Backends
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
# Backend 1: O contêiner do Nextcloud AIO no Windows Server
|
||||
upstream nextcloud_aio_backend {
|
||||
server 172.16.253.13:11580;
|
||||
}
|
||||
|
||||
# Backend 2: O Office Online Server (nativo no Windows Server)
|
||||
upstream office_online_backend {
|
||||
# Assumindo que o OOS está na porta 80 (HTTP)
|
||||
server 172.16.253.13:80;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Servidor HTTP (Porta 80)
|
||||
# - Redireciona para HTTPS
|
||||
# - Responde aos desafios do Let's Encrypt (Certbot)
|
||||
# ----------------------------------------------------------------------
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
|
||||
server_name verbocloud.itguys.com.br;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html; # Ajuste o caminho se necessário
|
||||
allow all;
|
||||
}
|
||||
|
||||
# Redirecionamento global para HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Servidor HTTPS (Porta 443)
|
||||
# - Ponto de terminação SSL
|
||||
# - Proxy reverso para AIO e OOS
|
||||
# - Headers de segurança
|
||||
# ----------------------------------------------------------------------
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
|
||||
server_name verbocloud.itguys.com.br;
|
||||
|
||||
# --- Logs Exclusivos (Conforme solicitado) ---
|
||||
access_log /var/log/nginx/verbocloud.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/verbocloud.itguys.com.br.error.log warn;
|
||||
# (Descomente o log de bad-bot quando implementar o $is_bad_bot)
|
||||
# access_log /var/log/nginx/verbocloud.itguys.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
# --- Configurações de SSL ---
|
||||
ssl_certificate /etc/letsencrypt/live/verbocloud.itguys.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/verbocloud.itguys.com.br/privkey.pem; # managed by Certbot
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/verbocloud.itguys.com.br/fullchain.pem;
|
||||
|
||||
# --- Otimizações de TLS (Baseado no SSLLabs e no seu arquivo antigo) ---
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
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_prefer_server_ciphers on;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# --- OCSP Stapling ---
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver 1.1.1.1 8.8.8.8 valid=300s; # Usando resolvers públicos
|
||||
resolver_timeout 5s;
|
||||
|
||||
# --- Headers de Segurança ---
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
#add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
#add_header Referrer-Policy "no-referrer" always;
|
||||
#add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# --- Configurações do Proxy ---
|
||||
client_max_body_size 10G;
|
||||
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 1024;
|
||||
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_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 1024;
|
||||
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;
|
||||
|
||||
# ---------------------------------------------------
|
||||
# REGRAS DO OFFICE ONLINE SERVER (OOS)
|
||||
# (Estas devem vir ANTES do location / principal)
|
||||
# ---------------------------------------------------
|
||||
|
||||
# Rota de Descoberta (Discovery)
|
||||
location = /hosting/discovery {
|
||||
proxy_pass http://office_online_backend;
|
||||
# ===> ATENÇÃO: Substitua pelo Hostname INTERNO que o OOS espera <===
|
||||
proxy_set_header Host "nextcloud001";
|
||||
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 Accept-Encoding "";
|
||||
sub_filter 'http://nextcloud001' 'https://verbocloud.itguys.com.br';
|
||||
sub_filter_once off;
|
||||
sub_filter_types text/xml application/xml;
|
||||
proxy_ssl_verify off;
|
||||
}
|
||||
|
||||
location ~ ^/(m|x|we|o|p|wv|op|wd|rtc|rtc2|layouts|view|_layouts)/ {
|
||||
proxy_pass http://office_online_backend;
|
||||
proxy_set_header Host "nextcloud001";
|
||||
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_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Accept-Encoding "";
|
||||
sub_filter_types text/css text/javascript application/javascript application/json;
|
||||
proxy_ssl_verify off;
|
||||
if ($request_method = 'OPTIONS') {
|
||||
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
||||
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, HEAD';
|
||||
more_set_headers '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';
|
||||
more_set_headers 'Access-Control-Allow-Credentials: true' always;
|
||||
more_set_headers 'Access-Control-Max-Age: 1728000' always;
|
||||
return 204;
|
||||
}
|
||||
|
||||
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
||||
more_set_headers 'Access-Control-Allow-Credentials: true';
|
||||
}
|
||||
|
||||
#location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff|woff2|ttf|otf|map)$ {
|
||||
# proxy_pass http://nextcloud_backend;
|
||||
# proxy_set_header Host $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;
|
||||
# proxy_cache nextcloud_cache;
|
||||
# proxy_cache_valid 200 30d;
|
||||
# proxy_cache_valid any 1m;
|
||||
|
||||
# more_set_headers 'Cache-Control: public, max-age=31536000, immutable';
|
||||
# more_set_headers 'X-Proxy-Cache: $upstream_cache_status';
|
||||
|
||||
# expires 1y;
|
||||
# proxy_hide_header "Cache-Control";
|
||||
# proxy_hide_header "Expires";
|
||||
# proxy_hide_header "Pragma";
|
||||
# brotli_static on;
|
||||
# gzip_static on;
|
||||
#}
|
||||
|
||||
# ---------------------------------------------------
|
||||
# REGRAS DO NEXTCLOUD AIO
|
||||
# (Um único location / para capturar tudo)
|
||||
# ---------------------------------------------------
|
||||
|
||||
# Redirecionamentos CalDAV/CardDAV
|
||||
location = /.well-known/carddav { return 301 /remote.php/dav; }
|
||||
location = /.well-known/caldav { return 301 /remote.php/dav; }
|
||||
location = /.well-known/webfinger { return 301 /index.php/.well-known/webfinger; }
|
||||
location = /.well-known/nodeinfo { return 301 /index.php/.well-known/nodeinfo; }
|
||||
|
||||
# Regra Principal (Nextcloud AIO)
|
||||
location / {
|
||||
proxy_pass http://nextcloud_aio_backend;
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
|
||||
# --- Headers de WebSocket e Otimizações AIO ---
|
||||
# (Isso garante que /push/, /whiteboard/ e /standalone-signaling/ funcionem)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
|
||||
# Timeouts longos
|
||||
proxy_connect_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_read_timeout 3600s;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
# ==============================================================================
|
||||
# Configuração para VS Code Server - vscode.itguys.com.br
|
||||
#
|
||||
# Data da Alteração: 2025-10-20
|
||||
# Contexto: Configuração de proxy reverso para múltiplas instâncias do
|
||||
# VS Code Server (code-server) em portas diferentes.
|
||||
# *** ATUALIZAÇÃO: Removido bloqueio de bots e adicionado filtro de
|
||||
# acesso restrito por IP para uso em rede interna. ***
|
||||
#
|
||||
# Features:
|
||||
# - Acesso restrito por IP (redes internas)
|
||||
# - Redirecionamento HTTP -> HTTPS
|
||||
# - SSL/TLS seguro (TLS 1.2, 1.3) com HTTP/2
|
||||
# - Headers de segurança (HSTS, CSP, X-Frame-Options)
|
||||
# - Suporte total a WebSockets (essencial para VS Code)
|
||||
# - Logs de acesso e erro dedicados
|
||||
# - Compressão Gzip
|
||||
# ==============================================================================
|
||||
|
||||
# --- SERVIDOR HTTP (Redirecionamento para HTTPS) ---
|
||||
server {
|
||||
if ($host = vscode.itguys.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
server_name vscode.itguys.com.br;
|
||||
|
||||
# Logs para o redirecionamento
|
||||
access_log /var/log/nginx/vscode.itguys.com.br.access.log;
|
||||
error_log /var/log/nginx/vscode.itguys.com.br.error.log;
|
||||
|
||||
# Acesso restrito também aplicado ao redirecionamento
|
||||
allow 10.10.253.0/24;
|
||||
allow 10.11.0.0/24;
|
||||
allow 172.16.0.0/16;
|
||||
deny all;
|
||||
|
||||
# Redireciona permanentemente todo o tráfego HTTP para HTTPS
|
||||
return 301 https://$host$request_uri;
|
||||
|
||||
|
||||
}
|
||||
|
||||
# --- SERVIDOR HTTPS (Configuração Principal) ---
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name vscode.itguys.com.br;
|
||||
|
||||
# Segurança
|
||||
# Caminhos para seus certificados SSL (substitua pelos caminhos corretos)
|
||||
#ssl_certificate /etc/letsencrypt/live/vscode.itguys.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/vscode.itguys.com.br/privkey.pem;
|
||||
|
||||
# Configurações de SSL/TLS (baseado em boas práticas)
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
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_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
# Logs
|
||||
access_log /var/log/nginx/vscode.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/vscode.itguys.com.br.error.log warn;
|
||||
|
||||
# Acesso Restrito
|
||||
# Permite o acesso apenas a partir das redes internas especificadas.
|
||||
allow 10.10.253.0/24;
|
||||
allow 10.11.0.0/24;
|
||||
allow 172.16.0.0/16;
|
||||
deny all;
|
||||
|
||||
# Headers 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 Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
#add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:; font-src 'self'; object-src 'none'; frame-ancestors 'none'; connect-src 'self' wss:;" always;
|
||||
|
||||
# Raiz do servidor (opcional)
|
||||
root /var/www/html;
|
||||
|
||||
# Otimizações
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
# Roteamento por Usuário (Proxy Reverso)
|
||||
|
||||
# Rota para o Usuário 1 -> Porta 8081
|
||||
location /vitoria/ {
|
||||
proxy_pass http://10.10.253.161:8081/;
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Configurações para WebSockets (CRÍTICO para VS Code)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
# Rota para o Usuário 2 -> Porta 8082
|
||||
location /daivid/ {
|
||||
proxy_pass http://10.10.253.161:8082/;
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Configurações para WebSockets (CRÍTICO para VS Code)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
# Bloqueia o acesso à raiz do domínio
|
||||
location = / {
|
||||
return 403; # Forbidden
|
||||
}
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/vscode.itguys.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/vscode.itguys.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
# ======================================================================
|
||||
# INÍCIO - CONFIGURAÇÃO WINDMILL
|
||||
# ======================================================================
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Windmill (windmill.grupopralog.com.br) - HTTP (Porta 80)
|
||||
# Redireciona para HTTPS e serve o desafio ACME (Let's Encrypt).
|
||||
# ----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
# Backend (Upstream) para o Windmill
|
||||
# ----------------------------------------------------------------------
|
||||
upstream windmill_backend {
|
||||
# IP da VM Debian + Porta do Docker
|
||||
server 172.16.253.103:8000;
|
||||
}
|
||||
server {
|
||||
if ($host = windmill.grupopralog.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name windmill.grupopralog.com.br;
|
||||
|
||||
# Regra para renovação do Let's Encrypt
|
||||
location ~ /.well-known/acme-challenge/ {
|
||||
allow all;
|
||||
root /var/www/html; # O mesmo diretório do seu Nextcloud
|
||||
}
|
||||
|
||||
# Redirecionamento forçado para HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Windmill (windmill.grupopralog.com.br) - HTTPS (Porta 443)
|
||||
# Configuração principal e segura.
|
||||
# ----------------------------------------------------------------------
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name windmill.grupopralog.com.br;
|
||||
|
||||
# --- Caminhos dos Certificados (Serão preenchidos pelo Certbot) ---
|
||||
#ssl_certificate /etc/letsencrypt/live/windmill.grupopralog.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/windmill.grupopralog.com.br/privkey.pem;
|
||||
#ssl_trusted_certificate /etc/letsencrypt/live/windmill.grupopralog.com.br/fullchain.pem;
|
||||
|
||||
# --- Segurança: SSL/TLS (Copiado da sua config do Nextcloud) ---
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY_1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver 127.0.0.1 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# --- Segurança: Headers HTTP (Copiado da sua config) ---
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
|
||||
# --- Compressão (Copiado da sua config) ---
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 1024;
|
||||
brotli_types application/atom+xml application/javascript application/json application/rss+xml text/css text/javascript text/plain text/xml;
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 1024;
|
||||
gzip_types application/atom+xml application/javascript application/json application/rss+xml text/css text/javascript text/plain text/xml;
|
||||
|
||||
# --- Logging Dedicado (Conforme suas instruções) ---
|
||||
access_log /var/log/nginx/windmill.access.log detailed_proxy; # Assumindo que 'detailed_proxy' está no seu httpd.conf
|
||||
error_log /var/log/nginx/windmill.error.log warn;
|
||||
|
||||
# --- Configuração do Proxy para o Windmill ---
|
||||
location / {
|
||||
proxy_pass http://windmill_backend; # Aponta para o upstream que criamos
|
||||
proxy_set_header Host $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;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# --- Suporte a WebSockets (CRÍTICO para a UI do Windmill) ---
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# --- Otimização de Buffers e Timeouts ---
|
||||
proxy_buffering off; # Essencial para UI reativa
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 900s; # Timeouts longos para jobs
|
||||
proxy_send_timeout 900s;
|
||||
}
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/windmill.grupopralog.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/windmill.grupopralog.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# FIM - CONFIGURAÇÃO WINDMILL
|
||||
# ======================================================================
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
# ==========================================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/workspace.itguys.com.br.conf
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA: 2025-10-14
|
||||
# VERSÃO: 1.0
|
||||
#
|
||||
# DESCRIÇÃO:
|
||||
# Configuração de proxy reverso segura e otimizada para o sistema Workspace.
|
||||
# - Integração com as políticas globais de segurança (bot block, rate limit).
|
||||
# - Otimizações de SSL/TLS, incluindo OCSP Stapling.
|
||||
# - Headers de segurança reforçados (HSTS, Permissions-Policy).
|
||||
# - Compressão Brotli e Gzip.
|
||||
# - Logs dedicados para acesso, erros e atividades de bots maliciosos.
|
||||
# - Cache otimizado para arquivos estáticos.
|
||||
# ==========================================================================================
|
||||
|
||||
# UPSTREAM: Define o servidor backend da aplicação para fácil manutenção.
|
||||
upstream workspace_backend {
|
||||
server 172.16.121.2;
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO 1: Servidor HTTP (Porta 80)
|
||||
# - Responde ao desafio Let's Encrypt.
|
||||
# - Redireciona todo o tráfego para HTTPS.
|
||||
# ======================================================================
|
||||
server {
|
||||
if ($host = workspace.itguys.com.br) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name workspace.itguys.com.br;
|
||||
|
||||
# Responde ao desafio do Certbot para geração/renovação de certificado.
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
# Redireciona permanentemente todo o resto para a versão segura (HTTPS).
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO 2: Servidor HTTPS (Porta 443)
|
||||
# - Bloco principal com todas as otimizações e configurações de segurança.
|
||||
# ======================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name workspace.itguys.com.br;
|
||||
|
||||
# --- Configurações Gerais e Logs Dedicados ---
|
||||
# Define um limite razoável para uploads de arquivos.
|
||||
client_max_body_size 50M;
|
||||
|
||||
# Utiliza os formatos de log definidos globalmente em nginx.conf.
|
||||
access_log /var/log/nginx/workspace.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/workspace.itguys.com.br.error.log warn;
|
||||
|
||||
# Log específico para registrar bots e requisições bloqueadas pela variável $block_request.
|
||||
access_log /var/log/nginx/workspace.itguys.com.br.bad-bot.log suspicious_bot if=$block_request;
|
||||
|
||||
# --- Módulo de Segurança Global (integrado com nginx.conf) ---
|
||||
# Bloqueia bots e acesso a URIs suspeitas de forma centralizada.
|
||||
if ($block_request) {
|
||||
return 404; # Retornar 404 é mais discreto que 403 para scanners.
|
||||
}
|
||||
|
||||
# Aplica o Rate Limiting (zona 'global_limit' definida em nginx.conf).
|
||||
limit_req zone=global_limit burst=100 nodelay;
|
||||
|
||||
# --- Parâmetros de SSL/TLS (Best Practices) ---
|
||||
# O Certbot irá gerenciar e preencher os caminhos abaixo automaticamente.
|
||||
#ssl_certificate /etc/letsencrypt/live/workspace.itguys.com.br/fullchain.pem;
|
||||
#ssl_certificate_key /etc/letsencrypt/live/workspace.itguys.com.br/privkey.pem;
|
||||
#ssl_trusted_certificate /etc/letsencrypt/live/workspace.itguys.com.br/fullchain.pem;
|
||||
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem; # Assumindo dhparam global.
|
||||
|
||||
# OCSP Stapling (Melhora a performance da conexão TLS).
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s; # Use seus resolvers de DNS preferidos.
|
||||
resolver_timeout 5s;
|
||||
|
||||
# --- Cabeçalhos de Segurança Otimizados ---
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(self), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(self), payment=()" always;
|
||||
# Nota: Content-Security-Policy (CSP) é mais seguro quando gerenciado pela aplicação.
|
||||
|
||||
# --- Compressão (Brotli e Gzip) ---
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 256;
|
||||
brotli_types application/atom+xml application/javascript application/json text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 256;
|
||||
gzip_types application/atom+xml application/javascript application/json text/css text/javascript text/plain text/xml image/svg+xml;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||
|
||||
# 1. Rota para assets estáticos (CACHE AGRESSIVO)
|
||||
# Cacheia arquivos comuns para reduzir a carga no backend e acelerar o carregamento.
|
||||
location ~* \.(?:svg|gif|png|jpg|jpeg|ico|wasm|woff2?|ttf|eot)$ {
|
||||
proxy_pass http://workspace_backend;
|
||||
proxy_set_header Host $host; # Necessário para o backend identificar o site
|
||||
|
||||
# Parâmetros de cache do NGINX
|
||||
proxy_cache workspace_cache; # ATENÇÃO: Esta zona de cache precisa ser criada
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
|
||||
# Headers de cache para o navegador
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 2. Rota principal para a aplicação (SEM CACHE)
|
||||
location / {
|
||||
proxy_pass http://workspace_backend;
|
||||
|
||||
# Cabeçalhos essenciais para a aplicação backend.
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# Suporte para WebSockets (essencial para aplicações modernas).
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400s; # Timeout longo para manter conexões ativas.
|
||||
}
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/workspace.itguys.com.br/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/workspace.itguys.com.br/privkey.pem; # managed by Certbot
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
# ==========================================================================================
|
||||
# ARQUIVO: /etc/nginx/sites-available/zammad.itguys.com.br.conf
|
||||
# DATA DA ALTERAÇÃO: 2025-09-27 22:56
|
||||
#
|
||||
# AUDITORIA E OTIMIZAÇÃO POR GEMINI
|
||||
# VERSÃO: 2.1 (Carateres Invisíveis Removidos - Alinhada com Estrutura Global)
|
||||
#
|
||||
# MELHORIAS APLICADAS NESTA VERSÃO:
|
||||
# 1. REMOÇÃO DE CARACTERES ESPECIAIS: Garantindo compatibilidade pura NGINX.
|
||||
# 2. REMOÇÃO DE SNIPPETS: Todas as diretivas incluídas foram internalizadas.
|
||||
# 3. INTEGRAÇÃO COM MÓDULO DE SEGURANÇA GLOBAL: Uso de $block_request para bots/URI suspeitas.
|
||||
# 4. SSL/TLS OTIMIZADO: Implementação das melhores práticas (TLS 1.2/1.3, Ciphers fortes, OCSP).
|
||||
# 5. HEADERS DE SEGURANÇA REFORÇADOS: HSTS Preload e Permissions-Policy adicionados.
|
||||
# 6. COMPRESSÃO: Brotli e Gzip ativados.
|
||||
# 7. LOGS DEDICADOS: Logs separados para acesso, erros e bad bots.
|
||||
# ==========================================================================================
|
||||
|
||||
# Mapa para definir o tempo de expiração do cache de assets
|
||||
# O Zammad utiliza /assets/ com nomes de arquivos versionados, permitindo cache agressivo.
|
||||
|
||||
# UPSTREAMS
|
||||
upstream zammad_backend {
|
||||
# Backend principal da aplicação Zammad.
|
||||
server 172.16.254.59;
|
||||
}
|
||||
upstream zammad_websocket_backend {
|
||||
# Backend específico para o serviço de WebSocket do Zammad (porta 6042).
|
||||
server 172.16.254.59:6042;
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO HTTP: Redirecionar para HTTPS
|
||||
# ======================================================================
|
||||
server {
|
||||
listen 80;
|
||||
include /etc/nginx/snippets/acme_challenge.conf;
|
||||
listen [::]:80;
|
||||
server_name zammad.itguys.com.br;
|
||||
|
||||
# Aplica o rate limiting a todo o tráfego HTTP.
|
||||
limit_req zone=global_limit burst=20 nodelay;
|
||||
|
||||
# Responde ao desafio do Let's Encrypt
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
||||
# Redireciona todo o resto para HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ======================================================================
|
||||
# BLOCO HTTPS: Servidor Principal Otimizado
|
||||
# ======================================================================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name zammad.itguys.com.br;
|
||||
|
||||
# --- Configurações Gerais e Logs ---
|
||||
client_max_body_size 50M;
|
||||
access_log /var/log/nginx/zammad.itguys.com.br.access.log detailed_proxy;
|
||||
error_log /var/log/nginx/zammad.itguys.com.br.error.log warn;
|
||||
# Log dedicado para bots suspeitos/acessos bloqueados
|
||||
access_log /var/log/nginx/zammad.itguys.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
# --- Módulo de Segurança Global (assumindo $block_request em nginx.conf) ---
|
||||
# Bloqueia bots e acesso a URIs suspeitas de forma centralizada.
|
||||
if ($block_request) {
|
||||
return 404; # Retornar 404 é mais discreto que 403 para scanners
|
||||
}
|
||||
|
||||
# --- Aplica o Rate Limiting (zona definida em nginx.conf) ---
|
||||
limit_req zone=global_limit burst=100 nodelay;
|
||||
|
||||
# --- Parâmetros de SSL/TLS (Best Practices) ---
|
||||
ssl_certificate /etc/letsencrypt/live/zammad.itguys.com.br/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/zammad.itguys.com.br/privkey.pem;
|
||||
ssl_protocols TLSv1.3 TLSv1.2;
|
||||
# Ciphers conforme guia SSL Labs (forte, compatível com Apple/Android)
|
||||
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
||||
# ssl_session_cache é assumido como definido globalmente em nginx.conf
|
||||
ssl_session_timeout 1d;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem; # Assumindo um arquivo dhparam seguro e recente
|
||||
ssl_session_tickets off;
|
||||
|
||||
# OCSP Stapling (Melhora a performance e a segurança)
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/zammad.itguys.com.br/fullchain.pem;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# --- Cabeçalhos de Segurança Otimizados ---
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(self), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(self), payment=()" always;
|
||||
# Content-Security-Policy (CSP) geralmente é mais seguro gerenciar na aplicação.
|
||||
|
||||
# --- Bloco de Compressão ---
|
||||
brotli on;
|
||||
brotli_comp_level 6;
|
||||
brotli_min_length 256;
|
||||
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_proxied any;
|
||||
gzip_comp_level 6;
|
||||
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;
|
||||
|
||||
# --- Parâmetros de Proxy Reversos (Base) ---
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_buffering on; # Certifica que o buffering está ligado
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k; # 4 buffers de 256KB cada.
|
||||
proxy_busy_buffers_size 256k;
|
||||
proxy_max_temp_file_size 0; # Desabilita a escrita em disco, forçando buffer na memória (se tiver RAM suficiente)
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
|
||||
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---
|
||||
|
||||
# 1. Rota para WebSockets (SEM CACHE)
|
||||
location /ws {
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400s;
|
||||
|
||||
# GARANTIR O PROTOCOLO E A PORTA CORRETA PARA O ZAMMAD
|
||||
proxy_set_header X-Forwarded-Proto https; # Define explicitamente como HTTPS
|
||||
proxy_set_header X-Forwarded-Port 443;
|
||||
proxy_set_header X-Forwarded-Ssl on;
|
||||
|
||||
proxy_pass http://zammad_websocket_backend;
|
||||
}
|
||||
|
||||
# 2. Rota para assets estáticos (/assets/) - CACHE AGRESSIVO
|
||||
location /assets/ {
|
||||
# O $cache_asset está definido no 'map' no topo do arquivo.
|
||||
expires $cache_asset; # 1 ano de cache para assets com hash
|
||||
|
||||
# Parâmetros de cache do NGINX
|
||||
proxy_cache zammad_cache;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
|
||||
# Headers de cache para o navegador
|
||||
add_header Cache-Control "public, max-age=604800, immutable";
|
||||
|
||||
proxy_pass http://zammad_backend;
|
||||
}
|
||||
|
||||
# 3. Rota principal para a aplicação (SEM CACHE)
|
||||
location / {
|
||||
proxy_pass http://zammad_backend;
|
||||
}
|
||||
}
|
||||
|
|
@ -60,9 +60,9 @@ else
|
|||
# Attempt pull, if fails (lock file or corruption), wipe and re-clone
|
||||
if ! git pull; then
|
||||
echo "[Pre-Flight] ERROR: Git pull failed (likely corrupt ref/lock). Re-cloning..."
|
||||
cd /
|
||||
rm -rf "$REPO_DIR"
|
||||
mkdir -p "$REPO_DIR"
|
||||
# If REPO_DIR is a mountpoint, we cannot remove it. We must empty it.
|
||||
# find is safer than globbing for hidden files
|
||||
find "$REPO_DIR" -mindepth 1 -delete
|
||||
git clone "$GIT_URL" "$REPO_DIR"
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue