You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Zhen Zhou <zh...@gmail.com> on 2008/10/23 09:54:22 UTC

[users@httpd] vhosts problem

Hi, all,

I met a strange problem for vhosts config.

System information:
Fedora 9 X86_64
httpd: 2.2.9

my httpd.conf which related with vhost:

NameVirtualHost 61.153.33.a:80


<VirtualHost 61.153.33.a:80>
        DocumentRoot    /var/www/html/abcorg
        ServerName      www.abc.org
</VirtualHost>

<VirtualHost 61.153.33.a:80>
    ServerAdmin abc@def.com
    DocumentRoot /var/www/html/abccom
    ServerName www.abc.com
        ServerAlias abc.com *.abc.com
    ErrorLog logs/www.abc.com-error_log
    CustomLog logs/www.abc.com-access_log common
</VirtualHost>


NameVirtualHost 192.168.0.190:80
<VirtualHost 192.168.0.190:80>
        DocumentRoot    /var/www/html
        ServerName      192.168.0.190
</VirtualHost>

httpd -t -D DUMP_VHOSTS:

VirtualHost configuration:
192.168.0.190:80      is a NameVirtualHost
         default server 192.168.0.190 (/etc/httpd/conf/httpd.conf:1017)
         port 80 namevhost 192.168.0.190 (/etc/httpd/conf/httpd.conf:1017)
61.153.33.a:80        is a NameVirtualHost
         default server www.abc.org (/etc/httpd/conf/httpd.conf:1000)
         port 80 namevhost www.abc.org (/etc/httpd/conf/httpd.conf:1000)
         port 80 namevhost www.abc.com (/etc/httpd/conf/httpd.conf:1005)
wildcard NameVirtualHosts and _default_ servers:
_default_:443          127.0.0.1 (/etc/httpd/conf.d/ssl.conf:81)

Now the result is not I needed, for instance, when I access
www.abc.org, the browser will
feedback from /var/www/html/index.htm, but I need content from
/var/www/html/abcorg/index.htm.

error in error.log:
[Thu Oct 23 15:50:50 2008] [error] [client 192.168.0.150]
(13)Permission denied: access to /abcorg/index.htm denied

How could I solve this problem?

TIA

Zhou

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] vhosts problem

Posted by Eric Covener <co...@gmail.com>.
On Thu, Oct 23, 2008 at 10:22 PM, Zhen Zhou <zh...@gmail.com> wrote:

> meanwhile I checked with selinux config, it is enforced, I tried
> setenforce 0, now all the problem is gone.
> but now I doubt that, selinux enforced will conflicted with normal
> httpd? if selinux enforced, how to config
> httpd run well?
>

Read your RHEL documentation and see ls -lZ output of a directory/file
that can be served (likely in the default docrot.  There's
httpd-specific SELlinux policy, if you want httpd to serve files you
have to mark them properly with chcon.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] vhosts problem

Posted by Zhen Zhou <zh...@gmail.com>.
On Thu, Oct 23, 2008 at 11:40 PM, Eric Covener <co...@gmail.com> wrote:
>>
>> but I still got error when I access www.abc.org:
>> [Thu Oct 23 22:37:33 2008] [error] [client 123.115.174.137]
>> (13)Permission denied: access to /abcorg/index.htm denied.
>>
>> Is there any folder permission I need to set in /var/www/html/abcorg ?
>
> On linux, namei -m /var/www/html/abcorg gives you a nice  concise view.
>
> Every dir has to be readable by the apache user (usually the "other"
> permissions), and the final directory also must be executable.  This
> could also be SELinux, if that's possible on your system.
>
> http://wiki.apache.org/httpd/13PermissionDenied
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Thanks very much for your help.

Here is folder permission status:
 namei -m /var/www/html/abcorg/
f: /var/www/html/abcorg/
 drwxr-xr-x /
 drwxr-xr-x var
 drwxr-xr-x www
 drwxr-xr-x html
 drwxr-xr-x abcorg

meanwhile I checked with selinux config, it is enforced, I tried
setenforce 0, now all the problem is gone.
but now I doubt that, selinux enforced will conflicted with normal
httpd? if selinux enforced, how to config
httpd run well?

TIA
Zhou

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] vhosts problem

Posted by Eric Covener <co...@gmail.com>.
>
> but I still got error when I access www.abc.org:
> [Thu Oct 23 22:37:33 2008] [error] [client 123.115.174.137]
> (13)Permission denied: access to /abcorg/index.htm denied.
>
> Is there any folder permission I need to set in /var/www/html/abcorg ?

On linux, namei -m /var/www/html/abcorg gives you a nice  concise view.

Every dir has to be readable by the apache user (usually the "other"
permissions), and the final directory also must be executable.  This
could also be SELinux, if that's possible on your system.

http://wiki.apache.org/httpd/13PermissionDenied

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] vhosts problem

Posted by Zhen Zhou <zh...@gmail.com>.
On Thu, Oct 23, 2008 at 7:25 PM, Eric Covener <co...@gmail.com> wrote:
> On Thu, Oct 23, 2008 at 3:54 AM, Zhen Zhou <zh...@gmail.com> wrote:
>> Hi, all,
>>
>> I met a strange problem for vhosts config.
>>
>> System information:
>> Fedora 9 X86_64
>> httpd: 2.2.9
>>
>> my httpd.conf which related with vhost:
>>
>> NameVirtualHost 61.153.33.a:80
>>
>>
>> <VirtualHost 61.153.33.a:80>
>>        DocumentRoot    /var/www/html/abcorg
>>        ServerName      www.abc.org
>> </VirtualHost>
>>
>> <VirtualHost 61.153.33.a:80>
>>    ServerAdmin abc@def.com
>>    DocumentRoot /var/www/html/abccom
>>    ServerName www.abc.com
>>        ServerAlias abc.com *.abc.com
>>    ErrorLog logs/www.abc.com-error_log
>>    CustomLog logs/www.abc.com-access_log common
>> </VirtualHost>
>>
>>
>> NameVirtualHost 192.168.0.190:80
>> <VirtualHost 192.168.0.190:80>
>>        DocumentRoot    /var/www/html
>>        ServerName      192.168.0.190
>> </VirtualHost>
>>
>> httpd -t -D DUMP_VHOSTS:
>>
>> VirtualHost configuration:
>> 192.168.0.190:80      is a NameVirtualHost
>>         default server 192.168.0.190 (/etc/httpd/conf/httpd.conf:1017)
>>         port 80 namevhost 192.168.0.190 (/etc/httpd/conf/httpd.conf:1017)
>> 61.153.33.a:80        is a NameVirtualHost
>>         default server www.abc.org (/etc/httpd/conf/httpd.conf:1000)
>>         port 80 namevhost www.abc.org (/etc/httpd/conf/httpd.conf:1000)
>>         port 80 namevhost www.abc.com (/etc/httpd/conf/httpd.conf:1005)
>> wildcard NameVirtualHosts and _default_ servers:
>> _default_:443          127.0.0.1 (/etc/httpd/conf.d/ssl.conf:81)
>>
>> Now the result is not I needed, for instance, when I access
>> www.abc.org, the browser will
>> feedback from /var/www/html/index.htm, but I need content from
>> /var/www/html/abcorg/index.htm.
>>
>> error in error.log:
>> [Thu Oct 23 15:50:50 2008] [error] [client 192.168.0.150]
>> (13)Permission denied: access to /abcorg/index.htm denied
>>
>> How could I solve this problem?
>
> When you use an IP address in the VirtualHost tag, Apache checks if
> that interface is the one associated with the request before checking
> anything else.  In your conf, if the local sideof the conection is
> your 192.168.0.190, it can then only choose between the 192.168.0.190
> vhosts and not the other ones with the external IP address.
>
> You can use a single NameVirtualHost *:80 and make all your
> VirtualHost containers *:80, and then the ServerName/ServerAlias will
> "just work", or you can duplicate the settings for www.abc.org in a
> 192.168.0.190 vhost.
>
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Thanks for your kindly help, now I modified httpd.conf:

NameVirtualHost *:80

<VirtualHost *:80>
       DocumentRoot    /var/www/html/abcorg
       ServerName      www.abc.org
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin abc@def.com
   DocumentRoot /var/www/html/abccom
   ServerName www.abc.com
       ServerAlias abc.com *.abc.com
   ErrorLog logs/www.abc.com-error_log
   CustomLog logs/www.abc.com-access_log common
</VirtualHost>

but I still got error when I access www.abc.org:
[Thu Oct 23 22:37:33 2008] [error] [client 123.115.174.137]
(13)Permission denied: access to /abcorg/index.htm denied.

Meanwhile I could access www.abc.com without any problem.That make me
very confused.

httpd -S:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          127.0.0.1 (/etc/httpd/conf.d/ssl.conf:81)
*:80                   is a NameVirtualHost
         default server www.abc.org (/etc/httpd/conf/httpd.conf:1000)
         port 80 namevhost www.abc.org (/etc/httpd/conf/httpd.conf:1000)
         port 80 namevhost www.abc.com (/etc/httpd/conf/httpd.conf:1005)
Syntax OK


Is there any folder permission I need to set in /var/www/html/abcorg ?

TIA

Zhou

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] vhosts problem

Posted by Eric Covener <co...@gmail.com>.
On Thu, Oct 23, 2008 at 3:54 AM, Zhen Zhou <zh...@gmail.com> wrote:
> Hi, all,
>
> I met a strange problem for vhosts config.
>
> System information:
> Fedora 9 X86_64
> httpd: 2.2.9
>
> my httpd.conf which related with vhost:
>
> NameVirtualHost 61.153.33.a:80
>
>
> <VirtualHost 61.153.33.a:80>
>        DocumentRoot    /var/www/html/abcorg
>        ServerName      www.abc.org
> </VirtualHost>
>
> <VirtualHost 61.153.33.a:80>
>    ServerAdmin abc@def.com
>    DocumentRoot /var/www/html/abccom
>    ServerName www.abc.com
>        ServerAlias abc.com *.abc.com
>    ErrorLog logs/www.abc.com-error_log
>    CustomLog logs/www.abc.com-access_log common
> </VirtualHost>
>
>
> NameVirtualHost 192.168.0.190:80
> <VirtualHost 192.168.0.190:80>
>        DocumentRoot    /var/www/html
>        ServerName      192.168.0.190
> </VirtualHost>
>
> httpd -t -D DUMP_VHOSTS:
>
> VirtualHost configuration:
> 192.168.0.190:80      is a NameVirtualHost
>         default server 192.168.0.190 (/etc/httpd/conf/httpd.conf:1017)
>         port 80 namevhost 192.168.0.190 (/etc/httpd/conf/httpd.conf:1017)
> 61.153.33.a:80        is a NameVirtualHost
>         default server www.abc.org (/etc/httpd/conf/httpd.conf:1000)
>         port 80 namevhost www.abc.org (/etc/httpd/conf/httpd.conf:1000)
>         port 80 namevhost www.abc.com (/etc/httpd/conf/httpd.conf:1005)
> wildcard NameVirtualHosts and _default_ servers:
> _default_:443          127.0.0.1 (/etc/httpd/conf.d/ssl.conf:81)
>
> Now the result is not I needed, for instance, when I access
> www.abc.org, the browser will
> feedback from /var/www/html/index.htm, but I need content from
> /var/www/html/abcorg/index.htm.
>
> error in error.log:
> [Thu Oct 23 15:50:50 2008] [error] [client 192.168.0.150]
> (13)Permission denied: access to /abcorg/index.htm denied
>
> How could I solve this problem?

When you use an IP address in the VirtualHost tag, Apache checks if
that interface is the one associated with the request before checking
anything else.  In your conf, if the local sideof the conection is
your 192.168.0.190, it can then only choose between the 192.168.0.190
vhosts and not the other ones with the external IP address.

You can use a single NameVirtualHost *:80 and make all your
VirtualHost containers *:80, and then the ServerName/ServerAlias will
"just work", or you can duplicate the settings for www.abc.org in a
192.168.0.190 vhost.


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org