How to Create A Custom Apache 503 Error Page - apache

I created an HTML document that will display that the server is not ready yet, and then redirect to another page. I want this to be the 503 error page.
What file do I need to edit in Apache to get this custom HTML to be my new 503 error page? I have tried following the instructions on multiple websites, but it still points to the original Apache one.
This is the code that I have in my "httpd-vhosts.conf" file.
<VirtualHost *:80>
ServerAdmin blah#blah.com
ServerName blah.blah.com
ServerAlias blah blah.blah.local
ErrorLog "logs/blah-error.log"
CustomLog "logs/blah-access.log" common
ErrorDocument 503 "D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/blah/error.html"
LogLevel warn
RewriteEngine On
JkMount /* worker5
DocumentRoot "D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/blah"
<Directory "D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/blah">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
In the "httpd.conf" file, it is including the "httpd-vhosts.conf" file, so I don't know why it is not working. Any help would be appreciated. Thanks.

ErrorDocument takes in a absolute URL path instead of a file path. So it should be:
ErrorDocument 503 /blah/error.html
Assuming under your document root is a /blah/error.html file.

Related

apache 2.4 - deny direct ip access and show custom error page

I want requests to http://example.com to serve my website, and requests to http://123.123.123.123 to show a customized 403 error page.
I have Apache/2.4.29 running on my Ubuntu server.
/etc/apache2/sites-available/vhosts.conf
<VirtualHost *:80>
ServerName default
<Location />
Require all denied
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
/etc/apache2/conf-available/security.conf
Alias /errors/ "/var/www/html/error-pages/"
ErrorDocument 401 /errors/401.php
ErrorDocument 403 /errors/403.php
ErrorDocument 404 /errors/404.php
ErrorDocument 500 /errors/500.php
<Directory /var/www/html/error-pages>
Require all granted
</Directory>
With the above setup direct-ip access is blocked, however it is not showing my custom error page.
Forbidden You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to
use an ErrorDocument to handle the request.
Then I tried using the directive instead of :
<VirtualHost *:80>
ServerName default
<Directory />
Require all denied
</Directory>
</VirtualHost>
Now all subdirectories (e.g. http://123.123.123.123/sub) show my error page, but unfortunately the root is not blocked at all and showing my index.php page.
My next guess was to experiment with wilcards:
<VirtualHost *:80>
ServerName default
<Location "/*">
Require all denied
</Location>
<Location "/*/">
Require all denied
</Location>
</VirtualHost>
This code works, and shows my own 403 error page on the root aswell all the subdirectories.
All this got me confused!
Is the how it should be done, or am I doing something wrong in the first two examples?
<VirtualHost _default_:80>
<Directory "${SRVROOT}/htdocs">
Require all denied
</Directory>
ErrorDocument 403 "Sorry, direct IP access not allowed."
ErrorLog "${SRVROOT}/logs/default-http-error.log"
CustomLog "${SRVROOT}/logs/default-http-access.log" combined
</VirtualHost>
This is what I have setup in my server where the directory directive is to denied access to all files in this virtualhost. And the errordocument 403 serving as a message. Other syntax are for error logging. Make sure this virtual host is before any other virtualhost. Something similar for the HTTPS scheme if you support HTTPS on your server.

Symfony - Use Apache ErrorDocument

I want to replace symfony's Error template with apache ErrorDocument.
I have following conf:
<VirtualHost *:80>
ServerName localhost-de
ServerAdmin me#mydomain.com
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
ErrorDocument 404 /staticErrorPage.html
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /kontakt "/var/www/html/contact/web"
Alias /skin "/var/www/html/skin"
RewriteEngine on
RewriteRule ^/skin/(.{7})/(.*) /skin/$2
SetEnv locale de_DE
</VirtualHost>
My Symfony application is under "/var/www/html/contact/". When i enter a not existing page like "localhost-de/foo" i am getting the content of my html page.
But when i enter a not existing page like "localhost-de/kontakt/foo" i am always getting the content of symfony/twig page.
I know that i can override twig template but i dont want it this way. Any ideas how to handle this?
The ErrorDocument is used only for the Directory you specified. You should enclose ErrorDocument in a Location or LocationMatch directive. Read apache documentation for more details.

404 Not Found in incorrect Apache configuration

I have a problem that apache configuration. Here my virtual host setting.
<VirtualHost *:80>
ServerName orocrm.75cl.sg
DirectoryIndex app.php
DocumentRoot /var/www/html/oro/web
<Directory /var/www/html/oro/web>
# enable the .htaccess rewrites
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
But, when I access to other menus, http://orocrm.75cl.sg/oro/web/app.php/ is always shown in front of the my targeted menu. So, it was shown 404 page. e.g http://orocrm.75cl.sg/oro/web/app.php/magento/cart/. It should be like that http://orocrm.75cl.sg/app.php/magento/cart/
May I know how do I fix this issue.
I recall that some versions of Apache come with a pre-configured vhost to point to the welcome.conf and such.
So I would suggest commenting the welcome.conf which is at /etc/httpd or on some distros /etc/apache2 and in those same directories find and remove any installation virtual hosts.
After that you should be free of conflicts as the pre defined virtualhost is like follows:
<VirtualHost *:80>
DocumentRoot "/var/www/welcome"
And that is all I can remember from last time looking at the file.
Enjoy

Adding blog to an existing website with the same domain name

I have a working website in Yii frame work with domainename.fr
Now i want to add a wordpress blog to be accessible in : domainename.fr/wp
I have tried to add a rewrite rule in the .htaccess file but it overrided by another rule that redirect every unknown path to the root (domainename.fr).
How can i do that with just alias, i mean to point /wp to /path_of_my_blog
my .conf file
<VirtualHost *:80>
ServerName domainename.fr
DocumentRoot /var/www/path/htdocs/src/web
<Directory /var/www/path/htdocs/src/web>
Options +Indexes
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
my blog path is /var/www/path/htdocs/wp

httpd subdomain 404 error

I have a working site at on the Top level of a domain, I now want to add a subdomain on the same domain and the same server.
The files for this site are located in the public html folder (/var/www/html)
I have the following virtualhosts/directory config in httpd.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin support.portal#somesite.com
DocumentRoot /var/www/html/joomla3
ServerName support.somesite.com
ErrorLog logs/support.somesite.com_error.log
CustomLog logs/support.somesite.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin support.portal#somesite.com
DocumentRoot /var/www/html/moodle
ServerName support.somesite.com/moodle
ErrorLog logs/moodle.error.log
CustomLog logs/moodle.access.log common
</VirtualHost>
<Directory "/var/www/html/moodle">
DirectoryIndex index.php
AcceptPathInfo on
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
No errors are reported on the start/restart of httpd
Nothing is reported in the httpd error log. The below entry is shown in the Access log so the request is reaching the webserver but appears to be not being handled properly by the webserver.
192.168.4.202 - - [05/Jan/2015:12:49:14 +0000] "GET /moodle HTTP/1.1" 404 290
I have configured something similar before but I can't figure out the problem here. I might have missed something obvious, Can you see where the problem is, Thanks?
I am running CentOS 6.5 for reference.