Skip to content

Instantly share code, notes, and snippets.

@obriat
Last active September 8, 2017 09:11
Show Gist options
  • Save obriat/86f0e3b772bcf55e80aa2e01468f5b3a to your computer and use it in GitHub Desktop.
Save obriat/86f0e3b772bcf55e80aa2e01468f5b3a to your computer and use it in GitHub Desktop.
Error 500 handling with PHP-FPM
Config Apache PHP-FPM
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:5555"
# Catch backend errors
ProxyErrorOverride On
# Return a custom error
ErrorDocument 500 "==== hoho ====="
</FilesMatch>
===============================================
Fichier de test
<?php
/*
* @file
* 500.php
* Test page: trigerring error 500.
*/
echo '<pre>';
//error_reporting(E_ALL);
// If enable return a 200 page with printed errors.
//ini_set('display_errors', 1);
// Synthax Error
// thisisanerror
// exception
throw new Exception('Nooooooooooooooo!');
@obriat
Copy link
Author

obriat commented Sep 8, 2017

If you want to catch errors on a frontend apache (with proxy pass) use this:

`
ProxyPass http://drupal-backend:80/

    # Catch backend errors
    ProxyErrorOverride On

    # Return a custom error
    ErrorDocument 500 "==== hoho ====="

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment