この構成は期待どおりに正しく機能します。
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;
}
}
どちらの場合も、ドキュメントを正しくフォローしているように感じます。
例 2 でワイルドカードを使用すると、予期しない動作が発生する原因は何ですか?