系统相关
首页 > 系统相关> > nginx.conf思考

nginx.conf思考

作者:互联网

同一个端口但是不同的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

标签:8080,conf,name,server,nginx,思考,test,ysm,cool
来源: https://www.cnblogs.com/MyUniverse/p/15242268.html