|
|
|
|
||||||
| comp.info.servers.unix Web servers for UNIX platforms. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have namevirtualhost defined but for some reason it's just not working.
I'm using wildcards in the form of XXX.com.site.com and XXX.img.site.com. It appears only the first virtualhost works. The second one keeps routing to the document root defined in the first virtualhost (/www/imgsite/htdocs/com). Wha am I doing wrong here? Does namevirtualhost not support wildcard subdomains? NameVirtualHost 1.2.3.4:80 <VirtualHost 1.2.3.4> ServerName com.site.com DocumentRoot /www/imgsite/htdocs/com </VirtualHost> <VirtualHost 1.2.3.4> ServerName img.site.com DocumentRoot /www/imgsite/htdocs </VirtualHost> |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"Shabam" <chalupa@yomama-nospam.com> wrote in
news:hbidndAmjfw-t8_fRVn-rQ@adelphia.com: > Does namevirtualhost not support wildcard subdomains? It does with mass virtual hosting feature: http://httpd.apache.org/docs-2.0/vhosts/mass.html > NameVirtualHost 1.2.3.4:80 > > <VirtualHost 1.2.3.4> > ServerName com.site.com > DocumentRoot /www/imgsite/htdocs/com > </VirtualHost> This will only serve HTTP 1.1 requests for com.site.com, and it will be the default for any other requests directed to unconfigured hosts on IP 1.2.3.4 because it is the first one listed. > <VirtualHost 1.2.3.4> > ServerName img.site.com > DocumentRoot /www/imgsite/htdocs > </VirtualHost> This will only serve HTTP 1.1 requests for img.site.com. If you don't like mass virtual hosting, you'll need to add a ServerAlias for every host you expect via your wildcards: <VirtualHost 1.2.3.4> ServerName com.site.com ServerAlias www.com.site.com ServerAlias foo.com.site.com DocumentRoot /www/imgsite/htdocs/com </VirtualHost> I use mass virtual hosting with mod_vhost_alias, myself. Configuration looks like this (note the absence of ServerName or ServerAlias): <VirtualHost *> ServerAdmin admin@example.net # turn on mass virtual hosting # apache will look for DocumentRoot using name of requested host (%0) VirtualDocumentRoot /var/www/vhosts/%0/site # make reconstructed self-referential URLs use hostname sent by client UseCanonicalName Off </VirtualHost> Some tips: Use %V, not %v in your custom LogFormat directive. LogFormat "%V %h %l %u %t \"%!414r\" %>s %b" vcommon CustomLog /var/log/apache/vcombined_log vcommon Open proxy hunters will create unusual entries in your log. When they try "GET http://www.yahoo.com/ HTTP/1.1", your server will look for /var/www/vhosts/www.yahoo.com/site/, which, of course, doesn't exist. It will return a 404 error (no harm done). It will also use www.yahoo.com as the virtual host in the log entry (if you use the LogFormat above), so don't freak out when your log analysis program claims you have a virtual host named www.yahoo.com. |
|
![]() |
| Outils de la discussion | |
|
|