main/default.conf

91 lines
3 KiB
Text

server {
listen 80 default_server;
listen [::]:80 default_server;
root /app;
index index.php index.html index.htm;
server_name _;
# Hide NGINX version to reduce exposed information
# Oculta a versão do NGINX para reduzir informações expostas
server_tokens off;
# Security Headers / Cabeçalhos de Segurança
# Enable HSTS (HTTP Strict Transport Security) to force HTTPS connections
# Habilita HSTS (HTTP Strict Transport Security) para forçar conexões HTTPS
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# Prevent clickjacking attacks by allowing the site to be displayed only in its own domain
# Previne ataques de clickjacking, permitindo que o site seja exibido apenas em seu próprio domínio
add_header X-Frame-Options "SAMEORIGIN" always;
# Enable protection against Cross-Site Scripting (XSS) attacks
# Ativa proteção contra ataques de Cross-Site Scripting (XSS)
add_header X-XSS-Protection "1; mode=block" always;
# Prevent browsers from MIME-type sniffing
# Impede que navegadores tentem adivinhar (sniff) o tipo MIME dos arquivos
add_header X-Content-Type-Options "nosniff" always;
# Control how referrer headers are sent
# Controla como os cabeçalhos de referência são enviados
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Limit upload size to prevent denial of service attacks
# Limita o tamanho de uploads para prevenir ataques de negação de serviço
client_max_body_size 10M;
client_body_buffer_size 128k;
# Disable directory listing to prevent structure exposure
# Desativa listagem de diretórios para evitar exposição de estrutura
autoindex off;
# Block access to sensitive directories
# Bloqueia acesso a diretórios sensíveis
location ~ ^/(logs|cache|inc|data|cli)/ {
return 301 /;
}
location / {
try_files $uri $uri/ $uri/index.php?$args;
}
location ~ ^/(api|p)/ {
try_files $uri $uri/ /$1.php;
}
# Serve manifest.json from manifest.php
# Serve manifest.json a partir do manifest.php
location = /manifest.json {
rewrite ^ /manifest.php last;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
# Hide header that reveals PHP version
# Oculta cabeçalho que revela a versão do PHP
fastcgi_hide_header X-Powered-By;
}
# Block access to hidden files and directories
# Bloqueia acesso a arquivos e diretórios ocultos
location ~ /\. {
deny all;
return 404;
}
# Block access to configuration and database files
# Bloqueia acesso a arquivos de configuração e banco de dados
location ~ \.(sql|conf|ini)$ {
deny all;
return 404;
}
# Minimize logs to reduce information exposure
# Minimiza logs para reduzir exposição de informações
access_log /dev/null;
error_log /dev/stderr warn;
}