同一个端口但是不同的server_name是否可以
验证方式
配置nginx.conf
http {
keepalive_timeout 0;
etag off;
server {
listen 8080;
server_name ysm.cool;
location /test {
content_by_lua '
ngx.say("ysm")
';
}
}
server {
listen 8080;
server_name test.cool;
location /test {
content_by_lua '
ngx.say("test")
';
}
}
}
验证
curl "127.0.0.1:8080/test" -H "Host:test.cool"
# 输出ysm
curl "127.0.0.1:8080/test" -H "Host:test.cool"
# 输出test