在开始之前,我想说我已经在serverfault上读到了相关的问题,但是我找不到解决scheme。
这是我的问题。 我正在使用第三方DNS,并添加了一个通配符logging* .biglle.com,它指向我的服务器的IP地址。 我遇到的问题是每个不存在的子域指向biglle.com(那些存在的工作正常)。 我想要指出的是,biglle.com的apache网站configuration不是默认的(000-default.conf),而是一个单独的(biglle.com.conf)。 这是我无法理解的。 不存在的子域名应该指向默认configuration文件,不是吗?
这里是biglle.com.conf的一部分
<VirtualHost 192.168.1.54:80> SuexecUserGroup "#1003" "#1004" ServerName biglle.com ServerAlias www.biglle.com ServerAlias webmail.biglle.com ServerAlias admin.biglle.com DocumentRoot /home/biglle/public_html ErrorLog /var/log/virtualmin/biglle.com_error_log CustomLog /var/log/virtualmin/biglle.com_access_log combined ScriptAlias /cgi-bin/ /home/biglle/cgi-bin/ ScriptAlias /awstats/ /home/biglle/cgi-bin/ DirectoryIndex index.html index.htm index.php index.php4 index.php5 <Directory /home/biglle/public_html> Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI allow from all AllowOverride All AddHandler fcgid-script .php AddHandler fcgid-script .php5 FCGIWrapper /home/biglle/fcgi-bin/php5.fcgi .php FCGIWrapper /home/biglle/fcgi-bin/php5.fcgi .php5 </Directory> <Directory /home/biglle/cgi-bin> allow from all </Directory> RewriteEngine on RewriteCond %{HTTP_HOST} =webmail.biglle.com RewriteRule ^(.*) https://biglle.com:20000/ [R] RewriteCond %{HTTP_HOST} =admin.biglle.com RewriteRule ^(.*) https://biglle.com:10000/ [R] RemoveHandler .php RemoveHandler .php5 IPCCommTimeout 31 FcgidMaxRequestLen 1073741824 <Files awstats.pl> AuthName "biglle.com statistics" AuthType Basic AuthUserFile /home/biglle/.awstats-htpasswd require valid-user </Files> Alias /dav /home/biglle/public_html Alias /pipermail /var/lib/mailman/archives/public <Location /dav> DAV on AuthType Basic AuthName "biglle.com" AuthUserFile /home/biglle/etc/dav.digest.passwd Require valid-user ForceType text/plain Satisfy All RemoveHandler .php RemoveHandler .php5 RewriteEngine off </Location> RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://biglle.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://biglle.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 php_value memory_limit 32M </VirtualHost>
目前我正在使用php hack检查域名在/ etc / apache2 / sites-enabled /中是否有相应的.conf文件,如果没有,它会显示404错误,但这显然不是永久的解决scheme。 此外,这个黑客只适用于每个子域的索引页面。
由于我没有超过10代表我不能在这里发表的例子。 你可以在这里看到他们粘贴在这里:
http://pastebin.com/cYY3ffYz
编辑:apache2ctl -S输出
root@biglle:/# apache2ctl -S [Sun May 27 22:00:11 2012] [warn] NameVirtualHost 91.132.57.179:80 has no VirtualHosts VirtualHost configuration: 192.168.1.54:80 is a NameVirtualHost default server biglle.com (/etc/apache2/sites-enabled/biglle.com.conf:1) port 80 namevhost biglle.com (/etc/apache2/sites-enabled/biglle.com.conf:1) port 80 namevhost fwnh.biglle.com (/etc/apache2/sites-enabled/fwnh.biglle.com.conf:1) port 80 namevhost itemlist.biglle.com (/etc/apache2/sites-enabled/itemlist.biglle.com.conf:1) port 80 namevhost lithisdoma.gr (/etc/apache2/sites-enabled/lithisdoma.gr.conf:1) port 80 namevhost think.biglle.com (/etc/apache2/sites-enabled/think.biglle.com.conf:1) port 80 namevhost topirouni.biglle.com (/etc/apache2/sites-enabled/topirouni.biglle.com.conf:1) port 80 namevhost videos.biglle.com (/etc/apache2/sites-enabled/videos.biglle.com.conf:1) 192.168.1.54:443 is a NameVirtualHost default server biglle.com (/etc/apache2/sites-enabled/biglle.com.conf:58) port 443 namevhost biglle.com (/etc/apache2/sites-enabled/biglle.com.conf:58) wildcard NameVirtualHosts and _default_ servers: *:80 biglle.com (/etc/apache2/sites-enabled/000-default:1) Syntax OK
Apache将按以下顺序查找VirtualHosts:
_default_ )IP和匹配的端口定义VirtualHost 我假设服务器只有一个IP地址,即192.168.1.54。
192.168.1.54:80 is a NameVirtualHost default server biglle.com (/etc/apache2/sites-enabled/biglle.com.conf:1) wildcard NameVirtualHosts and _default_ servers: *:80 biglle.com (/etc/apache2/sites-enabled/000-default:1)
因此,与192.168.1.54:80不匹配ServerName的传入请求将使用biglle.com.conf中定义的biglle.com VirtualHost(因为这是与IP和端口相匹配的第一个VirtualHost)。 000-default中的biglle.com VirtualHost只能用于在192.168.1.54以外的IP上接收到的请求。
除非你真的在做基于IP的虚拟主机,否则我build议你将所有的虚拟主机改为不指定IP地址(即<VirtualHost *:80> ),并确保你想成为默认<VirtualHost *:80>在configuration中(000-默认文件应该这样做)。
其他提示:
阿姆农