AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 393159
Accepted
Constantine Loukas
Constantine Loukas
Asked: 2012-05-28 10:45:36 +0800 CST2012-05-28 10:45:36 +0800 CST 2012-05-28 10:45:36 +0800 CST

通配符 dns,不存在的子域指向主网站

  • 772

在开始之前,我想说我已经阅读了有关 serverfault 的相关问题,但我找不到解决方案。

这是我的问题。我正在使用第三方 DNS,并且添加了通配符 A 记录 *.biglle.com,它指向我服务器的 IP 地址。我遇到的问题是每个不存在的子域都指向 biglle.com(那些确实存在的可以正常工作)。我想指出,biglle.com 的 apache 网站配置不是默认配置 (000-default.conf),而是一个单独的配置 (biglle.com.conf)。这就是我无法理解的。不存在的子域应该指向默认配置文件,不是吗?

这是 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 错误,但这显然不是永久的解决方案。此外,此 hack 仅适用于每个子域的索引页面。

由于我的代表不超过 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
domain-name-system subdomain wildcard
  • 2 2 个回答
  • 1427 Views

2 个回答

  • Voted
  1. Best Answer
    mgorven
    2012-05-28T12:30:02+08:002012-05-28T12:30:02+08:00

    Apache 将按以下顺序查找 VirtualHosts:

    1. 首先用匹配的 IP、端口和 ServerName 定义 VirtualHost
    2. 首先定义具有匹配 IP 和端口的 VirtualHost
    3. _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 的虚拟主机,否则我建议您将所有 VirtualHosts 更改为不指定 IP 地址(<VirtualHost *:80>即000-默认文件应该做)。

    • 4
  2. Druvision
    2012-12-21T09:38:44+08:002012-12-21T09:38:44+08:00

    附加提示:

    1. 在某些浏览器(例如 google chrome)上,您将只能在重新启动浏览器后浏览并查看 apache 配置更改的结果。
    2. 在配置文件中搜索重定向指令 - 它们也可能会导致问题。

    阿姆农

    • 0

相关问题

  • Solaris DNS

  • resolv.conf 在经过一段时间后被更改

  • 为什么有些网站的网址中没有“www”就无法显示?[关闭]

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve