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
Related
I install directadmin with CB2 + Apache + MariaDB 10.1.31 + PHP 5.6.34.
When I upload OpenCart and enable maintenance mode, Apache shows the 503 error page instead of maintenance.tpl.
I checked the catalog/controller/common/maintenance.php and found the following code:
if ($this->request->server['SERVER_PROTOCOL'] == 'HTTP/1.1') {
$this->response->addHeader('HTTP/1.1 503 Service Unavailable');
} else {
$this->response->addHeader('HTTP/1.0 503 Service Unavailable');
}
$this->response->addHeader('Retry-After: 3600');
I think the problem is that Apache does not handle the 503 Header correctly. When I change the web server to LiteSpeed, it is ok.
To check you can compare these two versions of the site. Both of them have the maintenance mode enabled, but:
The first is OK - http://takjens.com/
The second is not - http://server3.lammer.ir/
Please let me know how to fix this problem.
Here LiteSpeed has custom error page configured, while Apache shows default 503 error page, as defined in the response header.
To make Apache display the custom error page, do the following:
Add the custom error page directive to the Apache configuration or into the .htaccess file for the domain. Specify the path to the maintenance.tpl file relatively to the configured ServerRoot:
ErrorDocument 503 /path/to/maintenance.tpl
.tpl file extension is not something that Apache can serve by default. I order to process it properly, the correct file type should be specified for this extension either in Apache configuration or via .htaccess file:
AddType text/html tpl
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
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.
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'm having a problem implementing custom 404 error pages. my setup is a front-end apache 2.2.6 proxy request other than static file to the backend app server(apache 1.3.36)
i send 404 header back along with error page when user request a non-existing page to the backend server. I do get the error page back but somehow the backend apache server injects its own 404 not found page in the error page as well.
here is what injected to the not found page by apache:
Not Found
The requested URL /product/8jd4776 was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.36 Server at www.example.com Port 8888
any idea why this is happening?
set "ProxyErrorOverride On" with ErrorDocument in the front-end apache server solve the problem.
The content length of your custom 404 message must be 512 bytes or more.