使用名称服务器设置多域Apache,但每个请求都由默认configuration处理

我之前已经解决了这个问题,但现在我不得不清除我的VPS,显然我不能正确地configuration东西了,所以..

我已经build立了一个Debian VPS并在其上安装了Virtualmin,我买了一个testing域用于该VPS,并将其主DNS服务器指向我的VPS IP。我用Virtualmin为根域创build了一个虚拟服务器。 org,但是每当我打开URL,我会得到默认的虚拟主机页面,我继续删除默认的VH(不是实际的默认,只有一个Virtualmin创build),我仍然指向/ var / www而不是/ home /例如/ public_html忽略这个,我试图创build一个子域,希望至less这个会指出正确的directoy,但没有任何工作(我创build了*。example.org CNAME DNS以及所有指向example.org,那是对的吗?)

这是Virtualmin创build的VH文件:

<VirtualHost 127.0.0.2:80> SuexecUserGroup "#1001" "#1001" ServerName example.org ServerAlias www.example.org ServerAlias webmail.example.org ServerAlias admin.example.org DocumentRoot /home/example/public_html ErrorLog /var/log/virtualmin/example.org_error_log CustomLog /var/log/virtualmin/example.org_access_log combined ScriptAlias /cgi-bin/ /home/example/cgi-bin/ DirectoryIndex index.html index.htm index.php index.php4 index.php5 <Directory /home/example/public_html> Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch AddType application/x-httpd-php .php AddHandler fcgid-script .php AddHandler fcgid-script .php5 FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php5 </Directory> <Directory /home/example/cgi-bin> allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch </Directory> RewriteEngine on RewriteCond %{HTTP_HOST} =webmail.example.org RewriteRule ^(.*) https://example.org:20000/ [R] RewriteCond %{HTTP_HOST} =admin.example.org RewriteRule ^(.*) https://example.org:10000/ [R] RemoveHandler .php RemoveHandler .php5 php_admin_value engine Off IPCCommTimeout 31 FcgidMaxRequestLen 1073741824 Alias /pipermail /var/lib/mailman/archives/public RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://example.org:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://example.org:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 </VirtualHost> 

实际上,默认的ss.confconfiguration用于任何types的请求,但我不明白为什么,因为它开始于“VirtualHost 默认 :443”,我要求在默认的80端口

我发现这个问题,以防其他人以类似的情况结束:

 <VirtualHost 127.0.0.2:80> 

我不得不改变这个实际的服务器的IP,因为出于某种原因,在设置过程中,Virtualmin没有自己select它

正如你在回答中所指出的那样,问题在于你将虚拟主机设置为侦听你的访问者没有使用的IP 127.0.0.2 (他们正在使用服务器的公共IP)。

然后,您将其更改为服务器的公共IP地址,以便现在可以正常工作,但IP更改的那一天您将停止工作(迁移到新服务器,主机迁移到另一个networking上的其他区域,将其复制到新服务器等)

基于名称的虚拟主机的一个更好的解决scheme是定义没有IP,并使用通配符代替:

 <VirtualHost *:80>