Difference between revisions of "Apache2 VirtualHost 403 error"
m |
|||
Line 1: | Line 1: | ||
== error 403 with virtual hosts == | == error 403 with virtual hosts == | ||
+ | |||
+ | Working with virtual hosts under Apache2 is pretty easy, but I had some trouble | ||
+ | getting started due to some unclear docs and lack of examples. | ||
+ | My biggest problem was the "HTTP 403 / client denied by server configuration error". | ||
The browser reports 403 errors for all documents in the virtual host root path. | The browser reports 403 errors for all documents in the virtual host root path. | ||
Line 11: | Line 15: | ||
Allow access by adding a <directory> section inside the <vhost> section. | Allow access by adding a <directory> section inside the <vhost> section. | ||
− | + | <pre> | |
<directory /vhost_document_root> | <directory /vhost_document_root> | ||
allow from all | allow from all | ||
<directory> | <directory> | ||
+ | </pre> | ||
The following should give a better idea of how this should work: | The following should give a better idea of how this should work: | ||
Line 22: | Line 27: | ||
ServerAlias palermo.example.com | ServerAlias palermo.example.com | ||
DocumentRoot /var/www/vhosts/palermo | DocumentRoot /var/www/vhosts/palermo | ||
− | |||
<directory /var/www/vhosts/palermo> | <directory /var/www/vhosts/palermo> | ||
allow from all | allow from all | ||
</directory> | </directory> | ||
− | |||
</VirtualHost> | </VirtualHost> | ||
</pre> | </pre> | ||
− | It is strange that neither the sample httpd-vhosts.conf file nor the Apache2 | + | It is strange that neither the sample httpd-vhosts.conf file that comes with Apache2 |
− | documentation on VirtualHost gives a example that could work. | + | nor the Apache2 documentation on VirtualHost gives a example that could work. |
Revision as of 16:33, 25 July 2006
error 403 with virtual hosts
Working with virtual hosts under Apache2 is pretty easy, but I had some trouble getting started due to some unclear docs and lack of examples. My biggest problem was the "HTTP 403 / client denied by server configuration error".
The browser reports 403 errors for all documents in the virtual host root path. A tail of the error.log gives a message like this for each access attempt:
[Tue Jul 25 17:58:17 2006] [error] [client 192.168.1.1] client denied by server configuration: /var/www/vhosts/palermo/
The problem is that the extra/httpd-vhosts.conf is missing the directive to allow access to the directory.
Allow access by adding a <directory> section inside the <vhost> section.
<directory /vhost_document_root> allow from all <directory>
The following should give a better idea of how this should work:
<VirtualHost *> ServerName palermo.example.com ServerAlias palermo.example.com DocumentRoot /var/www/vhosts/palermo <directory /var/www/vhosts/palermo> allow from all </directory> </VirtualHost>
It is strange that neither the sample httpd-vhosts.conf file that comes with Apache2 nor the Apache2 documentation on VirtualHost gives a example that could work.