60 lines
2.0 KiB
Plaintext
60 lines
2.0 KiB
Plaintext
# Bloco para redirecionar todo o tráfego HTTP para HTTPS
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name dns-primario.itguys.com.br;
|
|
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name dns-primario.itguys.com.br;
|
|
|
|
# O Certbot irá gerenciar estas linhas
|
|
# ssl_certificate /etc/letsencrypt/live/ns1.itguys.com.br/fullchain.pem;
|
|
# ssl_certificate_key /etc/letsencrypt/live/ns1.itguys.com.br/privkey.pem;
|
|
include /etc/nginx/conf.d/global_robots.conf;
|
|
include /etc/nginx/conf.d/internal_networks.conf;
|
|
|
|
access_log /var/log/nginx/access.log detailed_proxy;
|
|
error_log /var/log/nginx/error.log;
|
|
|
|
# --- CABEÇALHOS DE PROXY GLOBAIS ---
|
|
# Colocados aqui, eles serão herdados por TODAS as localizações abaixo.
|
|
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_ssl_verify off;
|
|
|
|
# --- ESTRATÉGIA DE CACHE HÍBRIDA ---
|
|
proxy_cache zabbix_cache;
|
|
add_header X-Proxy-Cache $upstream_cache_status;
|
|
proxy_no_cache 1; # Regra geral: NÃO cachear
|
|
proxy_cache_bypass 1;
|
|
|
|
# --- LOCALIZAÇÃO PARA ARQUIVOS ESTÁTICOS (CACHE ATIVADO) ---
|
|
# Este é o primeiro bloco "irmão"
|
|
location ~* \.(css|js|jpg|jpeg|gif|png|ico|svg|webp|ttf|woff2)$ {
|
|
proxy_no_cache 0; # Ativa o cache para esta localização
|
|
proxy_cache_bypass 0;
|
|
proxy_cache_valid 200 60m;
|
|
|
|
proxy_pass https://172.16.254.252:53443;
|
|
}
|
|
|
|
# --- LOCALIZAÇÃO PRINCIPAL (SEM CACHE) ---
|
|
# Este é o segundo bloco "irmão", ele pega todo o resto.
|
|
location / {
|
|
# O cache permanece desativado aqui por herdar da regra geral
|
|
proxy_pass https://172.16.254.252:53443;
|
|
}
|
|
}
|