PassioniInformaticaLinux

Guida: Nginx — web server ad alte prestazioni

16/02/2026

Installare e configurare Nginx su Debian 12

1. Installazione

apt install -y nginx php8.2-fpm
systemctl enable nginx

2. Server block

server {
    listen 80;
    server_name miosito.it;
    root /var/www/miosito;
    index index.html index.php;

    location / { try_files $uri $uri/ =404; }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~* \.(css|js|jpg|png|webp)$ {
        expires 30d;
        add_header Cache-Control "public, immutable";
    }
}

3. Reverse proxy

location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

4. Performance

worker_processes auto;
worker_connections 2048;
gzip on;
gzip_types text/plain text/css application/json application/javascript;

Risultato: Nginx configurato come web server e reverse proxy con SSL, PHP-FPM e ottimizzazioni.

← Guida: Cron e Systemd Timers — schedulare task ... Guida: Fail2Ban — proteggere SSH e servizi dagl... →
← Torna all'elenco