Forum Moderators: phranque
Please help me in solving this mystery!
- CentOS 4.2
- Linux 2.6.18
To use custom error 503 page, I was told to look for the line:
# ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
in httpd.conf file, and uncomment it
The line was uncommented and apache restarted, but it has not worked.
Where is apache reading the error messages from?
on my virtual server, "httpd.conf" is in /etc/httpd/conf/ and
"HTTP_SERVICE_UNAVAILABLE.html.var" is in /var/www/errors
The part of httpd.conf dealing with this is as follows:-
Alias /error/ "/var/www/error/"
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
<Directory "/var/www/error">
AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en es de fr
ForceLanguagePriority Prefer Fallback
</Directory>
# several commented lines like the following one
# ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
</IfModule>
</IfModule>
I noticed that in httpd.conf file, neither "mod_negotiation.c" nor "mod_include.c" were acyuallu mentioned in the LoadModule section. (not sure if it is relevant)
Your help would be greatly appreciated.
Ababeel
Let's back up: What are you trying to do?
If you just want to define a custom error document, then you can put any DocumentRoot-relative filepath you like into the ErrorDocument directive. Just make an HTML page, put it into the filesystem area where your site's pages, images, and files are stored, and use ErrorDocument to point to it.
If, on the other hand, you are trying to serve multiple (variant) 503 error pages, each in a different language, and you want to use content-negotiation to 'pick one of them' based on language, then you need to get the mod_negotiation and mod_include modules installed. This may require a re-build of Apache if the .so files not already available.
Jim
Actually there are these 2 lines:
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule include_module modules/mod_include.so
But the 'extension' is ".so" and not ".c". I am a complete novice when it comes to apache, and I am not sure if the rfequired modules are considered available?
And:
" if you just want to define a custom error document, then you can put any DocumentRoot-relative filepath you like into the ErrorDocument directive. Just make an HTML page, put it into the filesystem area where your site's pages, images, and files are stored, and use ErrorDocument to point to it.
"
What I want to do:
Yes, I'd like to a custom error 503 document because the virtual server is frequently down, and I have to restart the container.
You say: " .. Just make an HTML page, put it into the filesystem area where your site's pages, images, and files are stored, and use ErrorDocument to point to it.."
How is it done, please? If the container is down (i.e. has stopped), apache would not be able to read the files placed in the filesystem of that container. I may be totally wrong, but I think it has to be placed outside the filesystem, somewhere?
Thank you for your help.
What I want to do:
Yes, I'd like to a custom error 503 document because the virtual server is frequently down, and I have to restart the container.
A 503 is really intended for a pre-planned outage. For example, if you had to restore your entire site from a backup, and you knew it was going to take two hours, you could add code to httpd.conf to rewrite all requested URLs to a blank (or very short) page with a 503 response status. You could also use mod_headers to send a "Retry-After" response header with a two-hour time specified.
If your server is frequently down, then fix that problem. A 503 won't fix that problem, and so is rather a waste of your time.
Jim
But, let me explain it a bit more: most visitors to the site don't speak English. When the container has stopped and until it gets restarted again, the following message appears:
ERROR
Service Unavailable
---------------------------------
The requested service is unavailable.
Please try again later.
Now I assumed that it is the 503 "Service Unavailable" message. And I am trying to replace it with a custom page.
I have read somewhere on apache website, but I could not find it again, that when an error is encountered, apache can be made to read pages OUTSIDE the /vhosts/ directory. The website (including its files, images, etc)is inside the vhosts folder.
The aim is, if possible, to use httpd.conf to get apache to display a certain html page located, say in "/var/www/error".
Is this possible, do you think?
Would it do the job (and be safe) to have something like:
Alias /error/ "/var/www/custom_error/"
instead of:
Alias /error/ "/var/www/error/"
and somehow direct apache to read a certain html page placed in the custom_error folder? Perhaps like so:
ErrorDocument 500 /var/www/custom_error/my_500.html
ErrorDocument 404 /var/www/custom_error/my_missing.html
ErrorDocument 503 /var/www/custom_error/my_service_unavailable.html
I wonder if that would be safe to try?
Thank you!
ErrorDocument 500 /var/www/custom_error/my_500.html
Alias /error/ "/var/www/custom_error/"
ErrorDocument 500 /error/my_500.html
would be correct.
But the 'extension' is ".so" and not ".c".But thy were compiled from foo.c, which is the name to referrer in an <IfModule>-directive.
Where is apache reading the error messages from?
To use custom error 503 page, I was told to look for the line:
But on the other hand the message you posted is not the default one of the official httpd distribution. It should read
"The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later."
If the container is down (i.e. has stopped)Reads like something else (a connector?), but not the httpd core itself issues the message. May be the handler returns with it's own message?
apache would not be able to read the files placed in the filesystem of that containerIf you're talking about application servers like tomcat, apache (as a frontend server) won't map the request to the filesystem nor read within the filesystem of a such a container. That is done by the application server.
To be honest, I am totally confused now. As I said, I am acomplete novice and just trying to follow basic rules in httpd.conf, manuals, etc.
Now just to exclude the "server down" issue, I have tried the 404 error - that is easy to test.
- The server is running alright
- edited httpd.conf file like this
1. uncommented the line:
# ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
2. edited the content of the file "HTTP_NOT_FOUND.html.var" to change the message to: TESTING 404
3. left everything else in httpd.conf as is and restarted Apache
When a non-existent page is called, the error message:
Not Found
The requested document was not found on this server
was displayed, which is not what the test message is.
It seems to that the whole section contained in:
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
in httpd.conf file is being ignored.
Also, I tried to uncomment a line above that section, where it says:
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
I uncommented the 404 line above, placed a test "missing.html" in the ServerRoot, i.e. "/etc/httpd
and restarted apache. That didn't work either.
I think if just forcused on a test 404 error and get that to work as intended. Then perhaps try to sort the 503 side.
Any suggestions as to why the above didn't work?
Thank you!
Not Found
The requested document was not found on this server
Which version do you use? The default in 2.2 is
"The requested URL [url-path] was not found on this server."
It seems to that the whole section contained in:<IfModule mod_negotiation.c>
<IfModule mod_include.c>in httpd.conf file is being ignored.
Can you describe how a request is being served at your server? You were talking about a container which crashes and is leading to the 503 message?
I don't know how to quote your answers in the way you did it(i.e. in rectangles). So I will just mention the three answers as follows:-
1. Which version do you use?
Apache/2.0.52 (CentOS)
2. Remove the <IfModule>...</IfModule>-containers:
I have removed them, saved httpd.conf and restarted apache.
The messages are still the same as reported before.
(This is really driving me crazy ! At least the 404 message should work?)
3. Can you describe how a request is being served at your server? You were talking about a container which crashes and is leading to the 503 message?
Yes, I was using the terms used in plesk 8.6 (Stop Container, Restart Container, etc).
Having googled and asked, now I believe that a container is simply the Virtual Personal Server. Have the following on the subject:
"Each virtual private server (VPS) "container" is completely partitioned from one another. A crash or lock up on one VPS has no impact on other virtual servers. The VPS container is also insulated from the physical hardware, making it possible to move a VPS container from one physical server to another with no downtime. "
----------
I wonder if the error messages displayed on the screen are actually the explorer's own version of these error messages. I am not sure about this but they are completely different to the ones in "html.var" files.
Now this could explain why the 503 error is not displayed as in the HTTP_SERVICE_UNAVAILABLE.html.var file. Because the server is down and httpd.conf is not being read. Maybe? But, why is it not reading the 404 file when the server is running? I wonder if that helps in diagnosing the problem?
There's an easy way to find out if the error messages are coming from Explorer, and that is, don't use Explorer. You will find that many Webmasters use Firefox because of the many Firefox add-ons that are available for Webmasters: Thinks like user-agent switchers, browser preference toolbars, the "Live HTTP Headers" add-on I'm constantly recommending here because it's so useful for checking HTTP browser requests and server responses...
And, if you've missed the news, the latest Internet Explorer security flaw is a big one, and is making mainstream news globally.
Internet Explorer will show its own 'friendly' error messages if the user has not de-selected the "Show friendly HTTP error messages" option in IE's Advanced settings (which is selected by default) and if the size of the server's error response is less than 256 or 512 bytes, depending on which error it is. It's easy to make your custom error documents at least 512 bytes long -- and actually pretty hard to make them smaller than that!
Jim
Thank you for your reply and the advice on Windows explorer (+ the security flaw).
I have excluded friendly messages on IE, ensured that the error message is larger than 512 and used firefox (which is my favourite browser). The error messages (404 + 503) are still the same - and they are identical in both IE + FF.
But, I have found something that might be a clue - not really sure:
I found another httpd.conf file in the folder /etc/httpd/conf.d/ and it is called zz010_psa_httpd.conf
There is a readme note in the "conf.d" folder which reads:
"This directory holds Apache 2.0 module-specific configuration files;
any files in this directory which have the ".conf" extension will be
processed as Apache configuration files."
The file "zz010_psa_httpd.conf" is long but there is no mention of error documents.
The following is an example of its content
==
<Directory "/var/www/vhosts">
AllowOverride All
Options SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
==
Is it advisable / safe to add/amend something in that file to see if it makes a flipping diifference :)
Would appreciate your opinions. Many thanks.
I still have the nagging feeling that you're fighting content-negotiation here. If you don't plan to have a multi-lingual site with automatic content-delivery in different languages, then turn all that extra complication off.
Even if you do plan to have a multi-lingual site, the nature of the world today has made automatic language selection passe -- It is far better to simply put a row of flags across the top of the site's home page, and let the user pick which country/language he wants. For example, just because I've traveled to Japan and I'm sitting in a Japanese internet cafe checking my e-mail and browsing the Web using a browser whose default Accept-Language header setting is "jp" does not mean that I can suddenly speak Japanese!
Jim