Portfolio_pero/deploy/nginx-security.conf.example
2026-09-03 13:27:06 +02:00

52 lines
1.5 KiB
Text

# Exemple de configuration Nginx a adapter a ton vhost.
# Important : l'audit detecte Nginx, donc .htaccess seul ne te protege pas.
server {
listen 80;
server_name tony-averty.dev www.tony-averty.dev;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name tony-averty.dev www.tony-averty.dev;
root /var/www/tony-averty.dev;
index index.php;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "accelerometer=(), autoplay=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), microphone=(), payment=(), usb=()" always;
location ~ /\.(?!well-known/) {
deny all;
}
location ~* ^/(?:config|sql|includes|cron)/ {
deny all;
}
location ~* ^/(?:setup\.php|server-status)$ {
deny all;
}
location ~* \.(?:env|ini|log|sql|bak|old|tmp|swp|md|zip|tar|gz|7z|yml|yaml|dist|example)$ {
deny all;
}
location ~* ^/assets/img/projects/.*\.(?:php|phtml|phar|php\d*)$ {
deny all;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}