【发布时间】:2014-08-12 09:38:00
【问题描述】:
我有 4 个域:foo.eu、foo.net、bar.eu、bar.de。我有一台虚拟服务器,运行 Ubuntu 12.04 LTS 和 Apache2。
我想托管 3 个不同的网页,映射如下:
- 第 1 页:foo.eu 和 foo.net
- 第 2 页:bar.eu 和 bar.de
- 第 3 页:sub.foo.eu
问题是当我访问“www.foo.eu”、“sub.foo.eu”或“www.bar.eu”时,我会显示正确的页面,但是如果我访问“foo.eu”的“ bar.eu”我看到了“sub.foo.eu”的页面。
为什么“foo.eu”/“bar.eu”没有向我显示与“www.foo.eu”/“www.bar.eu”相同的内容?
我的 /etc/apache2/sites-available/ 中有以下文件:
foo.eu:
<VirtualHost *:80>
DocumentRoot /var/www/foo
ServerName foo.eu
ServerName www.foo.eu
ServerAdmin webmaster@foo.eu
<Directory /var/wwww/foo >
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/foo_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/foo_access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
foo.net 类似,只是调整了 SeverName 行。
sub.foo.eu:
<VirtualHost *:80>
ServerName sub.foo.eu
ServerAlias sub.foo.eu
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
DocumentRoot /var/www/sub/
ErrorLog ${APACHE_LOG_DIR}/sub_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/sub_access.log combined
<Directory /var/www/owncloud>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName sub.steiler.eu
ServerAlias sub.steiler.eu
SSLEngine on
SSLCertificateFile /etc/ssl/crt/sub-cert.pem
SSLCACertificateFile /etc/ssl/crt/caCert.pem
SSLCertificateKeyFile /etc/ssl/key/sub-key.pem
DocumentRoot /var/www/sub/
ErrorLog ${APACHE_LOG_DIR}/sub_ssl_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/sub_ssl_access.log combined
<Directory /var/www/sub>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
order allow,deny
allow from all
</Directory>
</VirtualHost>
bar.eu:
<VirtualHost *:80>
DocumentRoot /var/www/bar
ServerName bar.de
ServerName www.bar.de
ServerAdmin webmaster@bar.de
<Directory /var/wwww/bar >
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/bar_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/bar_access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
bar.de 类似,只是调整了 SeverName 行。
更新:以下是域的 DNS 查询:
其中一个域(foo.eu;foo.net 类似):
~dig foo.eu A
; <<>> DiG 9.9.3-rl.156.01-P1-RedHat-9.9.3-3.P1.fc19 <<>> steiler.eu A
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2157
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
foo.eu. IN A
;; ANSWER SECTION:
foo.eu. 86306 IN A 192.168.178.1
;; AUTHORITY SECTION:
steiler.eu. 86306 IN NS ns-de.1and1-dns.biz.
steiler.eu. 86306 IN NS ns-de.1and1-dns.de.
steiler.eu. 86306 IN NS ns-de.1and1-dns.com.
steiler.eu. 86306 IN NS ns-de.1and1-dns.org.
;; Query time: 3 msec
;; SERVER: 15.8.243.101#53(15.8.243.101)
;; WHEN: Thu Jun 26 09:05:52 PDT 2014
;; MSG SIZE rcvd: 186
子域(sub.foo.eu):
~ dig sub.foo.eu A
; <<>> DiG 9.9.3-rl.156.01-P1-RedHat-9.9.3-3.P1.fc19 <<>> owncloud.steiler.eu
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7371
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 7
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;owncloud.steiler.eu. IN A
;; ANSWER SECTION:
sub.foo.eu. 86400 IN A 192.168.178.1
;; AUTHORITY SECTION:
foo.eu. 86004 IN NS ns-de.1and1-dns.biz.
foo.eu. 86004 IN NS ns-de.1and1-dns.org.
foo.eu. 86004 IN NS ns-de.1and1-dns.com.
foo.eu. 86004 IN NS ns-de.1and1-dns.de.
;; ADDITIONAL SECTION:
ns-de.1and1-dns.de. 3204 IN A 217.160.80.1
ns-de.1and1-dns.de. 3600 IN AAAA 2001:8d8:fe:53:0:d9a0:5001:100
ns-de.1and1-dns.biz. 3204 IN A 217.160.81.1
ns-de.1and1-dns.biz. 3600 IN AAAA 2001:8d8:fe:53:0:d9a0:5101:100
ns-de.1and1-dns.com. 3204 IN A 217.160.82.1
ns-de.1and1-dns.org. 3204 IN A 217.160.83.1
;; Query time: 101 msec
;; SERVER: 15.8.243.101#53(15.8.243.101)
;; WHEN: Thu Jun 26 09:10:54 PDT 2014
;; MSG SIZE rcvd: 315
另一个域(bar.de;bar.eu 类似):
~dig bar.de A
; <<>> DiG 9.9.3-rl.156.01-P1-RedHat-9.9.3-3.P1.fc19 <<>> steilerdev.de A
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13963
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 9
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;bar.de. IN A
;; ANSWER SECTION:
bar.de. 86393 IN A 192.168.178.1
;; AUTHORITY SECTION:
bar.de. 86393 IN NS ns-de.1and1-dns.de.
bar.de. 86393 IN NS ns-de.1and1-dns.org.
bar.de. 86393 IN NS ns-de.1and1-dns.biz.
bar.de. 86393 IN NS ns-de.1and1-dns.com.
;; ADDITIONAL SECTION:
ns-de.1and1-dns.de. 2943 IN A 217.160.80.1
ns-de.1and1-dns.de. 3339 IN AAAA 2001:8d8:fe:53:0:d9a0:5001:100
ns-de.1and1-dns.biz. 2943 IN A 217.160.81.1
ns-de.1and1-dns.biz. 3339 IN AAAA 2001:8d8:fe:53:0:d9a0:5101:100
ns-de.1and1-dns.com. 2943 IN A 217.160.82.1
ns-de.1and1-dns.com. 3339 IN AAAA 2001:8d8:fe:53:0:d9a0:5201:100
ns-de.1and1-dns.org. 2943 IN A 217.160.83.1
ns-de.1and1-dns.org. 3339 IN AAAA 2001:8d8:fe:53:0:d9a0:5301:100
;; Query time: 2 msec
;; SERVER: 15.8.243.101#53(15.8.243.101)
;; WHEN: Thu Jun 26 09:15:15 PDT 2014
;; MSG SIZE rcvd: 363
P.S.:我换了IP。
P.P.S.:www.foo.eu 和 www.bar.de 的查询与上述相同。
【问题讨论】:
-
您是否检查过您的域名的 A 记录?
-
5条A记录都指向同一个IP。或者我还应该在那里检查什么?
-
您能粘贴您的列吗?您可以审查 IP 地址,但查看您的配置会有所帮助。
-
我编辑了原始帖子并添加了我的 DNS 配置。
标签: ubuntu apache2 virtualhost vps subdomain