How to debug a 404 error on apache server ( lamp )? - apache

I came across 404 error a few times and i have difficulties in debugging this kind of problem.
What is the strategy and tools available to analyse such problems (firebug, logs...).
How to differentiate and fix the cause ?
page not existing ,wrong path , redirection and rewriting ,server problem ...

404 error code means that a file is not found for whatever reason.
Just check that the file exists and that the path you use is right.
You can analyse sent requests and received responses headers and body in your browser's developper console if you want more details about why some request failed.

Related

How To Retrieve Information About Error When Shopify Throws 404

Sometimes my dev server throws a 404 and I believe this is connected to my index.json, like also described here. But the dev server doesn't output any errors in such a case (it only does when there is an error related to the JSON inside the section schemas). Hence my question, is there any possibility to track down a index.json related error leading to a 404 page from the local dev server?

The CGI application did not return a valid set of HTTP errors. 502.3 - Bad Gateway: Forwarder Connection Error (ARR) on Azure ASP.NET Core App

All of a sudden we are seeing this random error / exception in our web application.
Failed to load resource: the server responded with a status of 502 (Bad Gateway).
In the Log Stream, we are seeing the following details, with specific error code as 502.3 - Bad Gateway: Forwarder Connection Error (ARR).
Also, sometimes in the browser itself we see "The CGI application did not return a valid set of HTTP errors." getting displayed.
Most of the searches for these error codes refer to "IIS / Proxy Server" configuration. But, we haven't changed any such settings.
The error happens very randomly and not specific to any user action/function. Same functionality works first and on second execution immediately after first one throws this error.
How to figure out what is causing this and how to fix?
I google this question, because the program was normal at the beginning, and the subsequent 502.3 error. After I checked the information on the Internet, I feel that it can only give us an inspiration, and it cannot solve your problem immediately.
So my suggestion is that first you browse post1 and post2 I provided.
Next, proceed to Troubleshoot according to the steps of the official documentation. Specific errors require specific analysis.

Apache does not intercept JBOSS HTTP Error Code

I have an Apache Web Server in front of a JBOSS app server. I have configured the ErrorDocument (with all the HTTP error codes) in Apache to return a fixed string of "There is an error".
Accessing the application is via the Apache Web Server, to the JBOSS app server.
However, when an error code of 404 throws from the JBOSS server, this Apache server did not catch the error and did not display the "There is an error", instead, the error page of JBOSS is served to the end user.
I have checked the log of Apache and can see the HTTP error code.
Can someone advise me what am I doing wrong or any additional config is needed?
Thanks and regards,
Jacky
There are three ways to display the custom HTTP error messages.
output a customized message
ErrorDocument 403 "There is an error"
internally redirect to a local URL-path to handle the error
ErrorDocument 404 /errorDocs/404.html
redirect to an external URL to handle the problem/error
ErrorDocument 404 http://example.com/cgi-bin/server-error.cgi
Please check if it is happening on all 404 scenarios and on all browsers.
I hope you are trying the method 1 and it is very straightforward one, scope of this directive is server config, virtual host, directory, .htaccess. If the configuration file is updated as mentioned, it must work.
These could be the situations,
ensure the text to be displayed is wrapped in quotes (") if it consists of more than one word.
Microsoft Internet Explorer (MSIE) will by default ignore server-generated error messages when they are "too small" and substitute its own "friendly" error messages. The size threshold varies depending on the type of error, but in general, if you make your error document greater than 512 bytes, then MSIE will show the server-generated error rather than masking it.
Although most error messages can be overridden, there are certain circumstances where the internal messages are used regardless of the setting of ErrorDocument. In particular, if a malformed request is detected, normal request processing will be immediately halted and the internal error message returned. This is necessary to guard against security problems caused by bad requests.
Reference

How can you include http://foo.local in CORS Access-Control-Allow-Origin?

I'm using *, but apparently that's not enough. I'm trying to upload a file from a client browser. It works when the client's URL is localhost:3000 or foo.com. It's not working when the URL is http://meteor.local. I've tried changing the third line to <AllowedOrigin>http://meteor.local</AllowedOrigin>, but get the same error.
The browser error:
The error text was misleading – error was not due to the header sent by s3. Adding an access rule to Cordova fixed it. (In meteor, add it with App.accessRule('http://meteor.local'); in mobile-config.js.)

Apache custom dynamic error response

I've seen hundreds of pages explaining how to create custom error pages in Apache 2 server. My question is different. I have a web application running in Apache (it is a ISAPI DLL, but it could also be a CGI executable). My application can handle internal server errors and generate a detailed error message (for instance, include a full stack trace), included in the response together with error code 500. AFAIK, Apache just let me use redirection in order to display custom error messages: http://httpd.apache.org/docs/2.2/custom-error.html
HTTP spec (RFC 2616 - section 10), not only allows but also recommend that detailed error message should be included in the BODY section of the response in case of error code > 500.
Link: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5
Seems that Apache won't let my custom error message go to the browser, and always replace it with its own internal error message and I believe that it is not the correct behavior, based on RFC 2616.
So my question is: Is there any setting in Apache server that will let my custom message go to the browser? Or, is there anything that can be done in my application that will instruct Apache to send my custom error message (something like some specific header field in the response)?
More on the subject:
When my ISAPI application returns error code 500, with other error information in the response body, Apache replaces it with its standard "500 Internal Server Error" message/HTML content, and inside Error.log file I can see the "useless" "Premature end of script headers" message. I'm deeply sure that my headers are fine, including the Content-Type field.
If I replace the 500 error code with any other server error code (e.g. 501) it works flawlessly and my response goes to the browser as is. The same header is sent to the Apache server, only the error code is different (501, instead of 500). With this test result in mind, one of these two must be true:
1- Apache requires some specific header field when status code is 500
2- Apache won't let custom error messages with status code 500 go to the browser.
I don't see any other alternative.
I think you're conflating two questions. You can generate a 500 response with a CGI script and include your custom body. Or you can override any 500 with any resource you want.
If you're failing to do the former, it's likely because of some subtle thing in the ISAPI interface between Apache and your module. Desk-checking the code says you should be able either set the pseudo
Status: 500
Header, or basically return any ISAPI error and end up with a 500 and your custom body.
Apache has two notions of a status code -- the one in the status line (r->status) and an error code returned separately from the module that handles the request (return HTTP_INTERNAL_SERVER_ERROR, return r->status).
When the former is used as the latter is when the custom error messages get lost. All of that happens in./modules/arch/win32/mod_isapi.c in Apache. Whatever is going on, it is ISAPI unique.