server { listen 80; listen [::]:80; root /home/user/www/domain; index index.php index.html index.htm; server_name domain.com www.domain.com; location / { try_files $uri $uri/ /index.php; } location ~* /(?:uploads|files)/.*\.php$ { deny all; } # Deny access to hidden files location ~* /\. { deny all; access_log off; log_not_found off; } location ~ \.php$ { try_files $uri =404; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_pass unix:/home/user/www/run/domain.php5-fpm.sock; fastcgi_read_timeout 300; } }