[emerg] "stream" directive is not allowed 怎么解哈,已经安装了模块

2022-12-21 11:09:09 +08:00
 jsjcjsjc

安装的是 oneinstack, 在 nginx.conf 插入 stream 代码的时候报错, 显示的是nginx: [emerg] "stream" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:86

stream {
    map $ssl_preread_server_name $backend_name {
        test.domain.net trojan;
        test1.domain.net web;
        test2.domain.net web;
    }

    upstream trojan {
        server 127.0.0.1:50443;
    }

    upstream web {
        server 127.0.0.1:445;
    }

    server {
        listen 443 reuseport;
        listen [::]:443 reuseport;
        proxy_pass  $backend_name;
        ssl_preread on;
    }
}

网上普遍反应是没有安装模块,但似乎是装了的哈

nginx version: nginx/1.22.1
built by gcc 8.3.0 (Debian 8.3.0-6)
built with OpenSSL 1.1.1s  1 Nov 2022
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-1.1.1s --with-pcre=../pcre-8.45 --with-pcre-jit --with-ld-opt=-ljemalloc

感谢

1755 次点击
所在节点    NGINX
4 条回复
julyclyde
2022-12-21 11:20:48 +08:00
你的 stream 是不是放到 http 内了?
msg7086
2022-12-21 11:52:31 +08:00
stream 段插错地方了。
zhoudaiyu
2022-12-21 20:04:29 +08:00
stream 是在根这一层的,和什么 http 、events 是一个层级的,检查下配置文件吧
jsjcjsjc
2022-12-22 16:05:34 +08:00
@julyclyde
@msg7086
@zhoudaiyu 感谢,是我眼瞎了,笔记上都写了还是忘了~~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/903876

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX