BastionGuard/data/vhosts/nginx-default.conf
specialworld83 d34e319fbe Public release
2026-02-27 21:37:06 +01:00

100 lines
3.1 KiB
Text

server {
listen 80;
listen [::]:80;
server_name _;
root /srv/http;
index index.php index.html index.htm;
# Se non hai questi file, evita di loggare errori inutili
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
# Fix header grandi (wp-admin / cookie / plugin)
fastcgi_buffer_size 64k;
fastcgi_buffers 16 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
# Cache asset statici
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff2?)$ {
expires 30d;
access_log off;
log_not_found off;
try_files $uri =404;
}
# Proteggi dotfiles (lascia .well-known)
location ~ /\.(?!well-known) {
deny all;
access_log off;
log_not_found off;
}
# ----------------------------------------------------------
# WordPress in /wordpress
# FIX: forza lo slash finale
# ----------------------------------------------------------
location = /wordpress {
return 301 /wordpress/;
}
location /wordpress/ {
# WordPress standard in sottocartella:
index index.php;
# evita che /wordpress/index.php venga trattato “strano” e stabilizza i permalink
try_files $uri $uri/ /wordpress/index.php?$query_string;
}
# opzionale ma spesso utile: nega accesso a file sensibili WP
location ~* ^/wordpress/(?:wp-config\.php|readme\.html|license\.txt) { deny all; }
location ~* ^/wordpress/(?:xmlrpc\.php) { deny all; } # solo se non lo usi
# ----------------------------------------------------------
# Joomla (o altro) in /joomla
# FIX: front controller coerente con la cartella
# ----------------------------------------------------------
location = /joomla {
return 301 /joomla/;
}
location ^~ /joomla/ {
index index.php;
try_files $uri $uri/ /joomla/index.php?$query_string;
}
# ----------------------------------------------------------
# Root (catch-all)
# Se NON usi nulla in /, puoi anche redirigere a wordpress
# ----------------------------------------------------------
location / {
try_files $uri $uri/ /index.php?$args;
}
# ----------------------------------------------------------
# PHP handler: esegue SOLO file PHP esistenti
# (questa riga evita "download" di PHP)
# ----------------------------------------------------------
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_index index.php;
# --- Sockets comuni: attiva solo quello corretto per la tua distro ---
# Debian / Ubuntu (es. PHP 8.4)
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
# Fedora / openSUSE / Arch (default)
# fastcgi_pass unix:/run/php/php-fpm.sock;
# Slackware / Arch vecchio path
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
}
}