[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-16 23:14:38
This commit is contained in:
parent
24deeddebd
commit
c6b7ad670a
|
|
@ -1,13 +1,15 @@
|
||||||
# Ficheiro: /etc/nginx/sites-available/itguys.com.br.conf
|
# Ficheiro: /etc/nginx/sites-available/itguys.com.br.conf
|
||||||
#
|
#
|
||||||
# Configuração de Proxy Reverso com Cache Inteligente, otimizada para
|
# Configuração de Proxy Reverso com Cache Inteligente e Otimizado,
|
||||||
# um site maioritariamente estático com um formulário de contacto dinâmico.
|
# para um site maioritariamente estático com um formulário de contacto dinâmico.
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# BLOCO HTTP: Redirecionar todo o tráfego para a versão segura e canónica (www)
|
# BLOCO HTTP: Redirecionar todo o tráfego para a versão segura e canónica (www)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
server {
|
server {
|
||||||
# Escuta por ambos os domínios, com e sem 'www'.
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
# Escuta por ambos os domínios, com e sem 'www', para apanhar todos os pedidos.
|
||||||
server_name itguys.com.br www.itguys.com.br;
|
server_name itguys.com.br www.itguys.com.br;
|
||||||
|
|
||||||
# Regra especial para a validação do Let's Encrypt funcionar corretamente.
|
# Regra especial para a validação do Let's Encrypt funcionar corretamente.
|
||||||
|
|
@ -15,20 +17,11 @@ server {
|
||||||
root /var/www/html;
|
root /var/www/html;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Para todas as outras requisições, envia um redirecionamento permanente (301) para a versão segura e com 'www'.
|
# Para todas as outras requisições, envia um redirecionamento permanente (301)
|
||||||
|
# para a versão segura (https) e com 'www'.
|
||||||
location / {
|
location / {
|
||||||
return 301 https://www.itguys.com.br$request_uri;
|
return 301 https://www.itguys.com.br$request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
listen [::]:443 ssl ipv6only=on; # managed by Certbot
|
|
||||||
listen 443 ssl; # managed by Certbot
|
|
||||||
ssl_certificate /etc/letsencrypt/live/www.itguys.com.br/fullchain.pem; # managed by Certbot
|
|
||||||
ssl_certificate_key /etc/letsencrypt/live/www.itguys.com.br/privkey.pem; # managed by Certbot
|
|
||||||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
|
||||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
@ -37,14 +30,15 @@ server {
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2;
|
listen 443 ssl http2;
|
||||||
listen [::]:443 ssl http2;
|
listen [::]:443 ssl http2;
|
||||||
# Define o nome canónico do servidor. A outra versão será redirecionada aqui.
|
|
||||||
server_name www.itguys.com.br;
|
# Define ambos os nomes de servidor para que o Nginx use o certificado correto.
|
||||||
|
# O primeiro nome é considerado o principal.
|
||||||
|
server_name www.itguys.com.br itguys.com.br;
|
||||||
|
|
||||||
# Adicionamos um redirecionamento para o tráfego que chega a 'itguys.com.br' na porta 443.
|
# --- Certificados SSL (Geridos pelo Certbot) ---
|
||||||
# Isto garante que os utilizadores usem sempre a versão 'www'.
|
# O Certbot irá preencher estas linhas.
|
||||||
if ($host = 'itguys.com.br') {
|
ssl_certificate /etc/letsencrypt/live/www.itguys.com.br/fullchain.pem;
|
||||||
return 301 https://www.itguys.com.br$request_uri;
|
ssl_certificate_key /etc/letsencrypt/live/www.itguys.com.br/privkey.pem;
|
||||||
}
|
|
||||||
|
|
||||||
# --- Cabeçalhos de Segurança Padrão ---
|
# --- Cabeçalhos de Segurança Padrão ---
|
||||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||||
|
|
@ -52,6 +46,7 @@ server {
|
||||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
|
||||||
# --- Configurações de Log ---
|
# --- Configurações de Log ---
|
||||||
|
# Usa o nosso formato de log JSON detalhado que já configurámos globalmente no nginx.conf.
|
||||||
access_log /var/log/nginx/access.log detailed_proxy;
|
access_log /var/log/nginx/access.log detailed_proxy;
|
||||||
error_log /var/log/nginx/error.log;
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
|
@ -64,23 +59,26 @@ server {
|
||||||
proxy_no_cache 1;
|
proxy_no_cache 1;
|
||||||
proxy_cache_bypass 1;
|
proxy_cache_bypass 1;
|
||||||
|
|
||||||
|
# --- CABEÇALHOS DE PROXY GLOBAIS ---
|
||||||
|
# Estes cabeçalhos serão herdados por todas as 'location' 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;
|
||||||
|
|
||||||
# --- LOCALIZAÇÃO PARA O FORMULÁRIO DE CONTACTO (SEM CACHE) ---
|
# --- LOCALIZAÇÃO PARA O FORMULÁRIO DE CONTACTO (SEM CACHE) ---
|
||||||
# O '=' indica uma correspondência exata da URI, o que é mais eficiente.
|
# O '=' indica uma correspondência exata da URI, o que é mais eficiente.
|
||||||
location = /php/enviar.php {
|
location = /php/enviar.php {
|
||||||
# Desativa o cache completamente para esta localização.
|
# Desativa o cache completamente para esta localização.
|
||||||
proxy_no_cache 1;
|
proxy_no_cache 1;
|
||||||
proxy_cache_bypass 1;
|
proxy_cache_bypass 1;
|
||||||
|
|
||||||
proxy_pass http://172.16.12.17:80;
|
proxy_pass http://172.16.12.17:80;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- LOCALIZAÇÃO PARA FICHEIROS ESTÁTICOS (CACHE LONGO) ---
|
# --- LOCALIZAÇÃO PARA FICHEIROS ESTÁTICOS (CACHE LONGO) ---
|
||||||
# Esta regra apanha os ficheiros que são seguros para cachear.
|
# Esta regra apanha os ficheiros que são seguros para cachear.
|
||||||
location ~* \.(jpg|jpeg|gif|png|webp|svg|css|js|ico|woff2|ttf|json|otf)$ {
|
location ~* \.(jpg|jpeg|gif|png|webp|svg|css|js|ico|woff2|ttf|json)$ {
|
||||||
# Ativa o cache para estes ficheiros.
|
# Ativa o cache para estes ficheiros.
|
||||||
proxy_no_cache 0;
|
proxy_no_cache 0;
|
||||||
proxy_cache_bypass 0;
|
proxy_cache_bypass 0;
|
||||||
|
|
@ -90,10 +88,9 @@ server {
|
||||||
expires 7d;
|
expires 7d;
|
||||||
|
|
||||||
proxy_pass http://172.16.12.17:80;
|
proxy_pass http://172.16.12.17:80;
|
||||||
proxy_set_header Host $host;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- NOVA LOCALIZAÇÃO PARA PÁGINAS HTML ESTÁTICAS (CACHE LONGO) ---
|
# --- LOCALIZAÇÃO PARA PÁGINAS HTML ESTÁTICAS (CACHE LONGO) ---
|
||||||
# Esta regra apanha especificamente as páginas Sobre.html e Serviços.html.
|
# Esta regra apanha especificamente as páginas Sobre.html e Serviços.html.
|
||||||
location ~* ^/(Sobre|Serviços)\.html$ {
|
location ~* ^/(Sobre|Serviços)\.html$ {
|
||||||
# Ativa o cache para estas páginas.
|
# Ativa o cache para estas páginas.
|
||||||
|
|
@ -103,10 +100,6 @@ server {
|
||||||
proxy_cache_valid 200 1h;
|
proxy_cache_valid 200 1h;
|
||||||
|
|
||||||
proxy_pass http://172.16.12.17:80;
|
proxy_pass http://172.16.12.17:80;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- LOCALIZAÇÃO PRINCIPAL PARA O RESTO DO SITE (CACHE CURTO) ---
|
# --- LOCALIZAÇÃO PRINCIPAL PARA O RESTO DO SITE (CACHE CURTO) ---
|
||||||
|
|
@ -119,30 +112,6 @@ server {
|
||||||
proxy_cache_valid 200 5m;
|
proxy_cache_valid 200 5m;
|
||||||
|
|
||||||
proxy_pass http://172.16.12.17:80;
|
proxy_pass http://172.16.12.17:80;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl_certificate /etc/letsencrypt/live/www.itguys.com.br/fullchain.pem; # managed by Certbot
|
|
||||||
ssl_certificate_key /etc/letsencrypt/live/www.itguys.com.br/privkey.pem; # managed by Certbot
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
server {
|
|
||||||
if ($host = itguys.com.br) {
|
|
||||||
return 301 https://$host$request_uri;
|
|
||||||
} # managed by Certbot
|
|
||||||
|
|
||||||
|
|
||||||
if ($host = www.itguys.com.br) {
|
|
||||||
return 301 https://$host$request_uri;
|
|
||||||
} # managed by Certbot
|
|
||||||
|
|
||||||
|
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
server_name itguys.com.br www.itguys.com.br;
|
|
||||||
return 404; # managed by Certbot
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue