微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

流块内的nginx server_name可能吗?

目前的设置如下:

stream {
    server {
        listen 9987 udp;

        server_name  subdomain.EXAMPLE.com; # this line is resulting in an error

        proxy_pass localhost:9987;
        proxy_timeout 1s;
        proxy_responses 1;
        error_log logs/dns.log;
    }
}

server_name subdomain.EXAMPLE.com;

这可能吗?

$Nginx -t

$Nginx: [emerg] "server_name" directive is not allowed here in /etc/Nginx/Nginx.conf:15

没有server_name工作正常,但我想尽可能使用子域. (我使用带有–with-stream的构建,这不是我的问题.)

解决方法:

TCP has no concept of server names, so this is not possible. It only works
in HTTP because the client sends the hostname it is trying to access as
part of the request, allowing Nginx to match it to a specific server block.

资料来源:https://forum.nginx.org/read.php?2,263208,263217#msg-263217

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐