标签:style http io os sp on bs tt line
server
{
listen 80;
server_name a.cjl.com;
location /
{
echo $http_user_agent;
}
}
server
{
listen 80;
server_name cjl.com;
location /
{
echo $time_local;
}
}
curl -H "Host: b.cjl.com" http://127.0.0.1 输出了curl/7.29.0,也就是user-agent的值
原因是,server_name做了全字匹配,搜索不到,就执行了第一个listen 80的server下的location
如果这里想输出$time_local的值,应该把第二个server_name改写成server_name *.cjl.com
标签:style http io os sp on bs tt line
原文地址:http://www.cnblogs.com/jimichen/p/4155515.html