Welcome! Log In Create A New Profile

Advanced

fastcgi_pass / error page /error code in HTTP rsp

June 08, 2015 03:14PM
Hi, I would like nginx to map a fastcgi error response a static error page, and include the HTTP error code in its HTTP response header; e.g.
1. have nginx return the proper error code in its header to the client.
2. have nginx return the proper error page based on the fastcgi_pass server's response error code.
For example, if the fastcgi server returns '400 Bad Request', I would like NGINX to return "Status code: 400" along with the bad request html static error page.

Is #2 feasible when fastcgi_pass is used? I was not able to do it, unless I used error code 302, a redirect. In other words, the only way I got nginx to return a specific error page was to have the fastcgi server respond with a redirect
"Status: 302 Found\r\n"
"Location: /<path>/badRequest.html\r\n"
The problem with this method was that the error code (400 for example) did not appear in the HTTP response of the error page (requirement #1 was not met).

How can I have nginx/fastcgi_pass return an error page with the HTTP error code (400 for example) appear in the HTTP header? My fastcgi server response did include 'Status' in the fastcgi response.
I tried not using the redirect 302 method but my attempts failed; I had the following inside the server block or inside the location/fastcgi_pass block of nginx.conf:

error_page 400 = /bad_request.html;

location = /bad_request.html {
try_files /<path>/bad_request.html 50x.html;
}
I tried the 'internal' directive also though I was not sure of its usage as the path of the html error page was not specified.
Any help on how to get nginx to return the error code in the HTTP header response and an error page when fastcgi is used would be greatly appreciated, thank you!
Subject Author Posted

fastcgi_pass / error page /error code in HTTP rsp

nginxuser100 June 08, 2015 03:14PM

Re: fastcgi_pass / error page /error code in HTTP rsp

Maxim Dounin June 08, 2015 03:26PM

Re: fastcgi_pass / error page /error code in HTTP rsp

nginxuser100 June 08, 2015 05:52PM

Re: fastcgi_pass / error page /error code in HTTP rsp

nginxuser100 June 08, 2015 08:13PM

Re: fastcgi_pass / error page /error code in HTTP rsp

nginxuser100 June 09, 2015 12:29AM

Re: fastcgi_pass / error page /error code in HTTP rsp

Francis Daly June 09, 2015 03:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 46
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready