【发布时间】:2015-08-26 06:04:40
【问题描述】:
我正在尝试使用带有 Acrylic DNS 代理的 Windows 8.1 上的 Apache 2.4 设置动态 VirtualHosts 子域,但我遇到了 Server Not Found 错误的问题。我已经阅读了很多答案,比如this one,但我不知道出了什么问题或如何解决它。
我的目标是设置一个本地域 (http://localhost.pc) 以从 /htdocs 中的文件夹动态服务所有子域,因此 http://test.localhost.pc/ 来自 /htdocs/test/ 等。我的 VirtualHost 配置设置为
<VirtualHost *:80>
UseCanonicalName Off
ServerName localhost.pc
ServerAlias localhost.pc www.localhost.pc
DocumentRoot C:/dev/apache/htdocs/
<Directory />
Options FollowSymLinks Includes ExecCGI Indexes
IndexOptions FancyIndexing HTMLTable FoldersFirst
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
UseCanonicalName Off
ServerName localhost.pc
ServerAlias *.localhost.pc
VirtualDocumentRoot C:/dev/apache/htdocs/%1/
<Directory />
Options FollowSymLinks Includes ExecCGI
IndexOptions FancyIndexing HTMLTable FoldersFirst
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我已经安装了 Acrylic DNS 代理,我已经将我的 WiFi 和(断开的)以太网的 IPv4 DNS 服务器更改为 127.0.0.1,并且我已经编辑了 AcrylicHosts.txt 以包含该行
127.0.0.1 localhost.pc *.localhost.pc
Acrylic 似乎工作正常,我已启用调试日志和点击日志,并且常规互联网浏览工作正常。但是,如果我访问我的本地域或子域,尽管 Acrylic 的调试日志显示,我会收到未找到服务器的错误
TResolver.Execute: Request ID 34019 received from client 127.0.0.1:55587 [Q=localhost.pc;T=AAAA;Z=84E301000001000000000000096C6F63616C686F737403706D6100001C0001].
TResolver.Execute: Response ID 34019 sent to client 127.0.0.1:55587 directly from hosts cache.
命中日志说
127.0.0.1 H Q=localhost.pc;T=A
127.0.0.1 H Q=localhost.pc;T=AAAA
从命令行 ping localhost.pc 失败(找不到主机),但 nslookup 看起来正确
C:\>nslookup localhost.pc
Server: UnKnown
Address: 127.0.0.1
Name: localhost.pc
Addresses: 127.0.0.1
127.0.0.1
如果我随后将127.0.0.1 localhost.pc 添加到C:\Windows\System32\drivers\etc\hosts 并刷新DNS 缓存,我至少可以让http://localhost.pc/ 加载。 Acrylic 的全部意义在于能够使用通配符,但 http://test.localhost.pc 仅在我手动将其和任何其他子域/文件夹添加到 Windows 主机文件时才有效。
所以我猜如果手动将条目添加到 Windows 主机文件可以让事情正常工作,那么 Acrylic 就是问题所在。有谁知道出了什么问题以及如何解决它?
【问题讨论】:
标签: windows apache dns virtualhost wildcard-subdomain