72 lines
2.8 KiB
Plaintext
72 lines
2.8 KiB
Plaintext
server {
|
|
if ($host = proxy.itguys.com.br) {
|
|
return 301 https://$host$request_uri;
|
|
} # managed by Certbot
|
|
|
|
|
|
listen 80;
|
|
server_name proxy.itguys.com.br;
|
|
add_header Alt-Svc 'h3=":443"; ma=86400';
|
|
|
|
# ---- 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;
|
|
listen 443 quic reuseport;
|
|
server_name proxy.itguys.com.br;
|
|
add_header Alt-Svc 'h3=":443"; ma=86400';
|
|
|
|
# --- 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
|
|
}
|