How to configure lighttpd display custom 500 error page? - linux

When my php works not correctly, server sends 500 error to browser by default. I want to see my custom error page. I tried to use servererror-file prefix, but not work with 500 error.

In lighttpd 1.4.46 (not yet released), you can choose to intercept errors from dynamic handlers using server.error-intercept = "enable". See https://redmine.lighttpd.net/issues/974
However, a better solution is to trap the errors in your PHP script and issue an appropriate error page, rather than crashing.

Related

Very strange api throws status 404 due to several features

Well. Exists something api, and I try get file, but I get 404 status code - why?
I don't know what is, but I found several features.
If use browser and going to path for download file - always ok, him download.
But if use modules(I use superagent) you are get 404 status code.
Ok. I watch on headers request - I copy all headers from firefox and set up in request - anyway 404.
I use Google chrome, and always ok! Him too download file.
I use Sphere(~anonymous browser) - 404.
I go on linux, and try again.
All browsers drop 404. superagent too.
And it's as far as I know work on nginx. (message "404 not found. nginx.")
I search any ideas why it happens.
I use API from bazon.cc
There are several reasons why this might be happening: Cookies, User-Agent based filtering, HTTP-Referrer Header checking and so on. You should use a packet capture tool to make sure the requests are really exactly the same.

Forcing internal server errors in IIS

Might seem like a strange question. But I want to be able to force 500 internal server errors (not errors with my code, but error 500 IIS).
Any sure bet way to do this?
I need to be able to test how other systems react that are connecting when the server returns Internal Server error 500.
I saw this question:
How to force IIS to throw an exception
Problem with this is I can already do this. If I do it this way, I have more control than with the IIS internal errors. Or at least I think I have more control.
I don't want to mimic a 500 error. I need to be able to see all the aspects of the 500 error IIS returns (content, headers, etc).
The purpose is that I need to be able to CHANGE those things if possible. And know I changed them.
One example of what I need to do is set a short cache time for these internal 500 errors (without affecting other responses).
This worked for me, I configured IIS limits to zero connections. Any requests gives
HTTP/1.1 503 Service Unavailable\r\n
Not exactly what you asked for, but perhaps close enough?

ColdFusion 10 Update 11 404 handler not firing

I know CF 10 has a number of issues surrounding 404 handling. This seems to be different from the other reports. Details:
Win2k8 R2/64 and IIS7.5
Upgrading from identical config on separate server. Only difference is CF9 -> CF 10. All works fine on CF9. Adobe CF9 Lockdown implemented on original server, CF10 Lockdown implemented on this server.
missing template handler set in CF Admin as /404.cfm, which should translate to the Cfusion root (c:\ColdFusion10\cfusion\wwwroot).
IIS has been config'd to trace failed 404 requests
IIS 404 handling is default (originally executed a CF URL but removed to simplify debug).
Coldfusion webroot where missing template handler resides is default install location
IIS site root is entirely different: c:\Other\Place\SiteRoot\
A sitewide error handler is also set in CF Admin in the same ColdFusion webroot and works as expected.
404.cfm is very simple:
<cfheader
statuscode="404"
statustext="Not Found">
<h1>404</h1><p>Page not found</p>
<cfoutput>#now()#</cfoutput>
Inputting the bad url [domain]/foo.cfm should display the above template. Instead I get an IIS error screen. The CF missing template handler is ignored. The IIS failed request trace says the url is
http://[mydomain]:80/jakarta/isapi_redirect.dll
and a detail view shows at Step 1
RequestURL="http://[mydomain]:80/foo.cfm
I've seen plenty of issues surrounding CF10 and 404's, but never that the missing template handler assignment is completely ignored. In CF9 this will generate output as expected. Anyone seen anything like this?
EDIT:
I have also tried config'ing this to match a different CF9 server I have running: Added a CF mapping to the web root of the site. Then placed the missing template handler in the web site's root rather than the CF default web root, lastly in cfadmin pointed to the missing template handler in the web site's root using the mapped folder. Same problem. Works fine in CF9 and not at all using CF10.
EDIT2:
As Miguel F pointed out in the comments, you can shut off HTML error codes in CF Admin and this will let the Missing Template Handler fire... BUT you get a 200 header to go with it. Apparently cfheader statements are ignored as I have tried placing the cfheader at the beginning and end of the template... still yields a 200. Visually fine but insofar as SEO is concerned thats a disaster. Just looked and my CF9 servers do not require this setting to be unchecked for their handlers to work.
EDIT3
Dana Kowalski's solution displays detailed IIS errors to the public, so for a 404 on, say, a made-up extension (foo.xyz), the screen will show file paths. Default behavior is to NOT display detailed errors except when running templates locally, and display custom error pages to visitors. The CF error template should work fine with that setting.
POSSIBLE SOLUTION
I stepped back to ColdFusion 9 as part of debugging this problem, and may have discovered the solution while debugging a separate related issue.
In the IIS Manager, click on the site in question. Select the Error Pages option. Select the 'Edit Feature Settings' link on the right side. Check that the 'Detailed Errors' option is selected.
If you have either of the other two selected, there are times IIS 7.x will take over and not let ColdFusion handle it.

Make IIS7.5 use custom error page

I have a custom error page. It works on my production server, but not on my dev machine. It's Windows 7, IIS 7.5.
I cannot get it to actually execute my custom page, although I can get it to respect detailed-local vs custom always. It just doesn't actually hand over to my custom error page and instead gives me the generic "Runtime Error" page for the remote mode.
Facts that might be relevant: it's an application mounted under a different app pool and web.config, this one is .NET 4.0, Integrated.
I was able to get it working, once, with "Response.TrySkipIisCustomErrors = true;" - but it did a redirect instead of an execute so I lost the error context which of course is the whole point - and in trying to change the redirect mode I was unable to get it to work again.
I've tried using both customErrors and httpErrors in all the documented/standard ways, but no combination works. Again, I have had this working correctly elsewhere.
The above is a normal response - if your error page is itself generating an exception.
It turned out the same code causing the original error was in the execution of the error page.

How to test a 503 custom error page.

A rather strange question:
How can I test a custom 503 error page without restarting the service.
(Struts application on tomcat with apache front loading)
"What I really want is some how SIMULATE that the tomcat crashed, and apache as the front end will grab the error page, and redirect to the custom error page"
You could create a Servlet which you exclude from production builds. This Servlet examines a parameter (e.g. errorCode) and sets it using the HTTP Servlet Response object: javax/servlet/http/HttpServletResponse.html#sendError(int, java.lang.String).
Then you are able to test all kinds of error codes, e.g.:
http://myapp.com/webapp/errorServlet?503
Not nice, but should work... if you want to unit test your Apache Web Server only you could create a separate WAR file (depends on your test scope).
Have you tried to use curl?
curl -H http://your/path/to/503page

Resources