Someone said that Apache Shows 503 details in the error log, but my nginx logs 503 errors in access.log.
Are 503 errors supposed to be logged as access or error?
Apache logs 503 errors in the access log, just like nginx.
There's an easy way to test it. Just add this rewrite rule to a temporary website, monitor the access log, and you'll see the 503 request.
RewriteRule .* - [R=503,L]
Actually, 503 errors mean something wrong happened between the server handling the request and the final destination of the request.
Typical scenarios are load balancing or proxy servers. In case you use Apache or nginx to proxy requests to another server and this second server isn't available, a 503 could happen, but there's no error per se on the Apache or nginx side, hence the error being logged as an access.
Related
I am trying to find a solution to Automatically redirect Apache to maintenance page when the backend application server goes down.
I have manual solution (RewriteCond) in place when the backend WebLogic server is shutdown for patching/deployment, I add the RewriteCond in the Apache configuration file. This manual method is working fine.
I also tried the .htaccess with
ErrorDocument 500 /maintenance/MaintenancePage.html
ErrorDocument 404 /maintenance/MaintenancePage.html
ErrorDocument 401 /maintenance/PortalMaintenancePage.html
ErrorDocument 503 /maintenance/PortalMaintenancePage.html
But Apache does not redirect to maintenance page with the above ErrorDocument when the weblogic server is down.
Apache show the following error when WebLogic is shutdown -
Failure of Web Server bridge:
No backend server available for connection: timed out after 10 seconds or idempotent set to OFF or method not idempotent.
Is there any way to tell Apache to AUTOMATICALLY redirect to maintenance page when the backend application or the WebLogic server is down.
I welcome any other solutions or alternatives to address this issue.
Thanks for your help
Use the ErrorPage parameter in the WebLogic Web Server Plugin to redirect to the desired page.
https://docs.oracle.com/middleware/1212/webtier/PLGWL/plugin_params.htm#PLGWL473
I know what HTML 500 errors are and I know how to research solving them,
I run a server with apache 2 and admin control is through cPanel and WHM.
What I am looking for is some guidance on how to feed back a useful and informative HTML 500 error page to the end user, after it has occurred on my website.
I have read: PHP: 500 Error to error page
and https://ux.stackexchange.com/questions/15955/how-to-create-a-useful-500-internal-server-error-page
but these don't seem to be what I'm looking for, for example http://www.smashingmagazine.com/2011/05/27/getting-started-with-defensive-web-design/ (referenced from one of the above links) tells me how to design the art work for the 500 error page but no indication as to how to deploy this page when the error occurs.
My most common point of the rare times I do have a few moments of HTML 500 errors, is with errors in the .htaccess file, for the website, this website may only be down for a few minutes but with ~50k visitors a month, this down time, even if momentary, will be seen by dozens of people and really should be presented well, nicely, informative and not the current standard which is:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
I have a server error page for 500 errors already set up and created and loadable in my server admin (cPanel), but the error page example (above) claims not to be able to find it, I also have an errorDocument handle in .htaccess which directs to this same page.
So my question is:
What processes do I need to set up to deploy a coherent and informative error 500 page when I get these errors?
specifically when I have .htaccess errors
I have a feeling that due to the nature of the error (server) it means that error pages can not be deployed from the same server as the error occurs, so the server can not work asynchronously?
Does the above mean that HTML 500 errors are only really deployable from multi-server situations or CDNs?
I have a feeling that due to the nature of the error (server) it means that error pages can not be deployed from the same server as the error occurs, so the server can not work asynchronously?
Does the above mean that HTML 500 errors are only really deployable from multi-server situations or CDNs?
I'd say they are only reliably deployable from a multi-server configuration.
The math is really simple:
An error page is itself a request to the server.
If the server is unable to complete requests due to misconfiguration or faulty code, there is no way to guarantee that the same will not happen to an error page.
But ultimately, it depends on your config.
If, for example, you make a mistake in a .htaccess file in some subfolder, causing infinite recursion, the error page will load just fine, provided it is not served from that directory.
If, however, you cause infinite redirection on all URLs, then the request to the error document will be affected by this too, which is precisely what happens when the server tells you:
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
This is like reporting a bug reporter bug - depending on its severity, this might or might not be possible.
If there is another server with a separate configuration, it will not be affected by the failures of server 1.
It doesn't need to be a physical server, simply launching a second web server will do as long as
one acts as a proxy or load balancer for the other
that proxy is configured to redirect responses from the other server with status code 500
that proxy is itself not misconfigured
For apache, using mod_proxy_balancer, such a configuration could look like
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot /var/www/errorpages/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
ServerAlias *.example.com
ServerAlias example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / balancer://whatever/
ProxyPassReverse / balancer://whatever/
<Proxy balancer://whatever/>
ProxySet failonstatus=500
BalancerMember http://127.0.0.1:42 retry=1
BalancerMember http://127.0.0.1:80 status=+H
</Proxy>
</VirtualHost>
This server would need to be started on port 80, and would pass all incoming requests to port 42 (hence the other server would need to listen to port 42, advisably only on 127.0.0.1). If any of the responses returned by the server running on port 42 were to have a status code of 500, the server on port 80 would resend the request to port 80 on 127.0.0.1, thus passing the request to itself, but with a different Host header, so that it wouldn't hit the load balancer again.
I have site using cloudflare.com's free plan as reverse proxy.
I had one script which took more than 60 seconds to execute , and server threw 504 Gateway time-out , but i didnt get my web servers page, instead i got the custom page setup by cloudflare,
I have double checked and my Smart-errors application in cloudflare is turned OFF , so why cloudflare is still giving their custom made page ?
How can i switch off cloudflare's all custom pages and just use as reverse proxy.?
So my question is how can i turn off all the custom error pages from cloudflare ?
I am using nginx latest server on cent os 7. 64 bit.
with php-fpm latest.
update :
This is what i got , when i go the 504 error.
Error 504 Ray ID: 1fb6a3feef7c17c8 • 2015-06-24 07:16:17 UTC
Gateway time-out
You
Browser
Working
Singapore
CloudFlare
Working
mydomain.com
Host
Error
What happened?
The web server reported a gateway time-out error.
What can I do?
Please try again in a few minutes.
CloudFlare Ray ID: 1fb6a3feef7c17c8 • Your IP: myip • Performance & security by CloudFlare
Update : as suggested by damoncloudflare, i would like to add more details.,
its a dedicated server, with linux cent os 7, 64 bit , latest nginx , php-fpm,
in nginx conf i have already specified how to handle 504 errors by
error_page 500 502 503 504 /50x.html;
How to replicate it .
code
<?php
http_response_code(504);
?>
or
<?php
sleep(61);
echo 'i am done sleeping';
?>
where 61 is more than max_execution_time which is 60
More details , as why originally this happened.
i was downloading huge file and the download took more than 60 seconds which is max_execution_time set in php.ini file.
So i received the cloudflare error.,
i would like to add there is nothing wrong with my server.
i have one more query , will i be able to disable cloudlfare 504 error and show my web servers custom page, if i upgrade from free to pro ?
update 2
i guess , now i understand the issue .,
Error 504
Gateway time-out
is triggered when server is not reachable and thats where cloudflare shows their page,
obviously if server not reachable then , its not possible for server to show 504 page.
thanks for your reply.
You need a premium Cloudflare plan to customize error pages for certain response codes. From the Cloudflare dashboard (domain name > Custom Pages tab):
500 Class Errors [...] Upgrade to Pro [...] Once you publish your custom page, Cloudflare will use your customized page instead of serving our standard 500 Class Errors page to your visitors on 502, 504, and 52x errors.
Even if NGINX sends your error page to Cloudflare, Cloudflare will see the 5xx response code being sent back along with your error page and will respond with their error page instead of yours.
There exists a workaround. From the NGINX documentation on the error_page directive:
Furthermore, it is possible to change the response code to another using the “=response” syntax, for example:
error_page 404 =200 /empty.gif;
In NGINX, before responding to Cloudflare we map the 'offending' 5xx error to a different response code. That is, instead of sending the offending 5xx response code along with our error page we change the response code to one for which Cloudflare will not override our pages. It is a good idea to map the offending 5xx error to another 5xx class error (500). Although less information is conveyed, this preserves the general meaning of the 5xx class error.
error_page 500 503 /50x.html;
error_page 502 504 =500 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
internal;
}
I should add - if you are getting your error page for the 504 error, then NGINX is being reached. This error would then mean, in the reverse proxy context, that NGINX passed the request on successfully but the upstream service (web server) took too long to respond.
A 504 or 502 Gateway error is actually indicative of an issue with your back end server & I would recommend contacting your hosting provider/checking your server logs.
"So my question is how can i turn off all the custom error pages from cloudflare ?"
Customers on a paid plan (Pro or above) can customize error pages.
"I have double checked and my Smart-errors application in cloudflare is turned OFF , so why cloudflare is still giving their custom made page ?"
SmartErrors is an entirely different feature. It is designed to only trigger when we get a 404 on a URL on your site.
I've been dealing with this whole day and still can't figure it out.
I've setup Zabbix on one machine, and I want to monitor the Apache server on another machine.
I've completed all the steps described in the docs: http://www.zabbix.com/wiki/templates/apache
and still I get no data in the Apache Template. When checking the logs on the Apache server, I can see in access.log:
IPADDR - - [16/Jul/2012:13:29:08 +0000] "GET /server-status?auto HTTP/1.0" 404 13826 "-" "Python-urllib/1.17"
I think it might has something to do with Virtual Servers and additional sites I have on that machine, but I can't figure it out, and nothing mentioned in the docs...
The Apache checks are not as clever as you may think.
Can Zabbix communicate with your apache server? Link it to a template with something simple like "uptime" and verify that it indeed gets data.
Next, verify that there aren't any firewall rules prevent the zabbix server from communicating with your web server. Can you curl your homepage from the zabbix host without problems?
Are the apache checks active checks? If so you'll need to make sure active checks are enabled in the /etc/zabbix/zabbix-agentd.conf file and that the "Hostname" within the conf is unique and matching up correctly with what you have in the zabbix server.
If that fails, change the DebugLevel to 4 in /etc/zabbix-agentd.conf and tail the zabbix log. Look and see if it is having trouble with any checks.
This is an apache configuration problem, zabbix can't do anything if /server-status yields a 404 error.
Maybe the <Location /server-status>...</Location> directive is not at the right place in apache's configuration.
Try to move it inside the <VirtualHost> section of the specific virtual server to which the GET /server-status is routed.
Also make sure that mod_status is enabled.
I am using jetty as my app server and apache as webserver to proxy requests to jetty. In some cases jetty throws 500 internal server error with stack trace. I want to handle this 500 error on apache i.e. i want to configure apache to suppress this 500 error and show an html page.
I configured apache with
ErrorDocument 500 http://abc.com/errorpage.html
but still i am getting 500 error from jetty with HTTP ERROR 500 followed by stack trace and footer as
"Powered by Jetty://"
How can i suppress this error at apache.
The ProxyErrorOverride directive should work for you:
# Let mod_proxy serve error pages.
ProxyErrorOverride On
# This also allows for SSI, so you can trap the error code and act accordingly.
ErrorDocument 500 /static/500.shtml