此配置按预期正常工作:
server {
listen 80;
server_name www.domain1.com domain1.com;
access_log /srv/www/domain1.com/logs/access.log;
location / {
root /srv/www/domain1.com/public_html;
index index.html index.htm;
}
}
server {
listen 80;
server_name domain2.com www.domain2.com;
access_log /srv/www/domain2.com/logs/access.log;
location / {
root /srv/www/domain2.com/public_html;
index index.html index.htm;
}
}
此配置在访问http://domain2.com时显示来自domain1的内容:
server {
listen 80;
server_name *.domain1.com;
access_log /srv/www/domain1.com/logs/access.log;
location / {
root /srv/www/domain1.com/public_html;
index index.html index.htm;
}
}
server {
listen 80;
server_name *.domain2.com;
access_log /srv/www/domain2.com/logs/access.log;
location / {
root /srv/www/domain2.com/public_html;
index index.html index.htm;
}
}
我觉得我在两种情况下都正确地遵循docs。
在示例二中使用通配符会导致意外行为的原因是什么?
答案 0 :(得分:0)
*.domain2.com
与domain2.com
不符。做:
server_name domain2.com *.domain2.com;
代替