0
這個配置正常工作按預期:爲什麼使用通配符能指一秒鐘「服務器名稱」確實打破我的nginx的配置
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。
什麼會導致在示例二中使用通配符的意外行爲?
如果你想顯示爲http://domain2.com您的網站中刪除星號。這意味着你需要有'server_name .domain1.com'和'server_name .domain2.com;' – foibs