您好我不知道如何制定问题而我找不到任何相关内容。
我有4个域名:foo.eu,foo.net,bar.eu,bar.de。我有一个虚拟服务器,运行Ubuntu 12.04 LTS和Appache2。
我想托管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是simliar,只调整了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是simliar,只调整了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的查询与上述相同。
答案 0 :(得分:0)
虽然我不是DNS专家,但我会提出一些建议。
如果您的foo.eu和sub.foo.eu都指向同一个IP地址,只需删除您的sub.foo.eu DNS信息即可。完全摆脱它。让Apache处理这些请求。非常肯定您也可以使用Apache来处理服务器外部的请求。长话短说......不要使用DNS记录来设置子域。
如果出现问题,请查看子域名的CNAME。您应该能够将foo.eu重定向到www.foo.eu,这同样适用于var.eu。
您在大多数记录中没有使用ServerAlias。您改为使用两个ServerNames。第二个会覆盖。这可能是您问题的焦点。如果Apache没有设置ServerAlias,那么它将被迫猜测。如果这反映了您的配置,那么它将执行反向DNS查找。您可以在ServerAlias上查看Apache文档以获取更多信息。