title: PHP-FPM + nginx 1.1.15 Custom error pages
body: <p>I have a PHP-FPM configured as backend for nginx 1.1.15.
  I need to customize 40x, 50x error pages for errors coming from PPH-FPM.</p>
  
  <p>For example, I send 403 header from php script and want nginx to show custom page.
  nginx configured as follows:
  <code></p>
  
  <pre><code>    error_page  403 /403.html;
      location = /403.html {
          root   html;
          allow  all;
      }
  </code></pre>
  
  <p></code></p>
  
  <p>But when I send 403 header from php, nginx shows it's native "403 Forbidden" page, not my custom.</p>
  
  <p>Upd: I'm sorry. I didn't give full config of nginx.
  I handle 404 in nginx and pass all queries to a single script. This script sends 403 headers. So nginx not display custom 403 page. When I request an existing script, to bypass the 404 rule in nginx conf, then custom error page is returned. Here is a part of my nginx.conf</p>
  
  <pre><code>    error_page 404 = @myhandler;
  
      location @myhandler {
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_param SCRIPT_FILENAME script.php;
          include fastcgi_params;
      }
  
      error_page  403 /403.html;
      location = /403.html {
          root   html;
          allow  all;
      }
  
      location ~ \.php$ {
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name;
          include        fastcgi_params;
      }
  </code></pre>
  
  <p>UPD: I've found a solution.</p>
  
  <pre><code>**recursive_error_pages on;**
  error_page 404 = @myhandler;
  
  location @myhandler {
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_param SCRIPT_FILENAME script.php;
      include fastcgi_params;
      **error_page  403 /403.html;**
  }
  </code></pre>