【问题标题】:How to Correct 'nginx: [emerg] "stream" directive is not allowed here'如何更正'nginx:[emerg]“流”指令在这里不允许'
【发布时间】:2021-09-10 23:28:21
【问题描述】:

问题

为什么下面的 Nginx 配置返回nginx: [emerg] "stream" directive is not allowed here in /etc/nginx/sites-enabled/default:1

Nginx 配置...

stream {
  map $ssl_preread_server_name $upstream {
    example.com 1051;
  }
  upstream 1051 {
    server 127.0.0.1:1051;
  }
  server {
    listen 443;
    proxy_pass $upstream;
    ssl_preread on;
  }
}

版本/构建信息...

操作系统:Debian 10

这是精简的nginx -V 输出,确认存在我理解我需要的模块...

nginx version: nginx/1.14.2
TLS SNI support enabled
configure arguments: ... --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module ...

背景

我有一个静态 IP 地址。在静态 IP 地址上,我设置了一个反向代理 Nginx 服务器,将流量转发到各种后端服务。其中一些服务是具有唯一域名的网站。

+-----+        +----------------------+        +---------+
| WAN | <----> | Nginx Reverse Proxy  | <----> | Service |
+-----+        +----------------------+        +---------+

在启动时,服务使用 systemd 运行此端口转发ssh 命令以连接到反向代理:ssh -N -R 1051:localhost:443 tunnel@example.com(运行良好。)

我希望证书驻留在服务上 - 而不是反向代理。据我了解,我需要利用 Nginx 上的 SNI 来通过基于域名的 SSL 连接。但我无法让 Nginx 反向代理通过 SSL。

资源

这是我研究过的一些资源...

【问题讨论】:

    标签: ssl nginx-reverse-proxy nginx-config debian-buster pass-through


    【解决方案1】:

    问题是我试图将stream 块嵌入http 块中。我没有正确考虑 /etc/nginx/nignx.conf 文件中的 include

    【讨论】:

    • 你是怎么解决的?
    猜你喜欢
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-09
    • 1970-01-01
    • 1970-01-01
    • 2021-08-06
    • 2021-11-17
    相关资源
    最近更新 更多