设置带有名称服务器的多域 apache,但每个请求都由默认配置处理

设置带有名称服务器的多域 apache,但每个请求都由默认配置处理

我之前已经解决了这个问题,但是现在我不得不清除我的 VPS,而且显然我无法再正确配置东西了,所以......

我已经设置了一个 Debian VPS 并在其上安装了 Virtualmin 我购买了一个测试域与该 VPS 一起使用并将其主 A DNS 指向我的 VPS IP 我使用 Virtualmin 为根域创建一个虚拟服务器,假设为 example.org,但每当我打开 URL 时,我都会得到默认的虚拟主机页面 我继续删除默认 VH(不是实际的默认值,只是 Virtualmin 创建的 VH)并且我仍然指向 /var/www 而不是 /home/example/public_html 忽略这一点,我尝试创建一个子域,希望至少这个子域会指向正确的目录,但没有任何效果(我也创建了 *.example.org CNAME DNS,全部指向 example.org,对吗?)

这是 Virtualmin 创建的 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>

显然,default-ss.conf 配置可用于任何类型的请求,但我不知道为什么,因为它以“VirtualHost默认:443”,我正在默认的 80 端口上进行请求

答案1

我发现了这个问题,以防其他人遇到类似的情况:

<VirtualHost 127.0.0.2:80>

我必须将其更改为实际服务器的 IP,因为出于某种原因,Virtualmin 在设置过程中没有自行获取它

答案2

正如您在回答中指出的那样,问题在于您正在设置虚拟主机来监听 IP 127.0.0.2,而您的访问者并没有使用该 IP(他们使用的是服务器的公共 IP)。

然后,您将其更改为服务器的公共 IP,因此它现在可以正常工作,但是在您的 IP 更改之日它将停止工作(您迁移到新服务器,您的主机迁移到不同网络上的其他区域,您将其复制到新服务器等)

对于基于名称的虚拟主机,更好的解决方案是不定义 IP,而是使用通配符:

<VirtualHost *:80>

相关内容