# Global error pages error_page 403 /403.html; error_page 404 /404.html; error_page 500 502 504 /50x.html; error_page 503 /503.html; # Global error handler locations location = /403.html { internal; try_files $document_root/403.php $document_root/403.html /var/www/error-pages/403.php /var/www/error-pages/403.html =403; fastcgi_intercept_errors on; } location = /404.html { internal; try_files $document_root/404.php $document_root/404.html /var/www/error-pages/404.php /var/www/error-pages/404.html =404; fastcgi_intercept_errors on; } location = /503.html { internal; try_files $document_root/503.php $document_root/503.html /var/www/error-pages/503.php /var/www/error-pages/503.html =503; fastcgi_intercept_errors on; } location = /50x.html { internal; try_files $document_root/50x.php $document_root/50x.html /var/www/error-pages/50x.php /var/www/error-pages/50x.html =500; fastcgi_intercept_errors on; } # PHP handling for error pages location ~ ^/(?:403|404|503|50x)\.php$ { internal; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass unix:/var/run/php/php-fpm.sock; # Adjust this path as needed }