【问题标题】:"ssl_preread" is not working in NGINX“ssl_preread”在 NGINX 中不起作用
【发布时间】:2018-01-09 15:22:21
【问题描述】:

我正在尝试在我的 nginx 中实现“ssl_preread”。我的nginx是用“--with-stream_ssl_preread_module”这个模块编译的。

我提到了“ssl_preread on;”在 nginx.conf 的服务器指令中。但我遇到了错误。

nginx: [emerg] "ssl_preread" 指令在 /opt/nginx/conf/nginx.conf:43 中是不允许的

我正在关注下面的文档。

http://nginx.org/en/docs/stream/ngx_stream_ssl_preread_module.html

【问题讨论】:

  • 我猜你尝试在http 部分而不是stream 中使用它。
  • @AlexeyTen,我只在服务器标签中使用了这个。
  • 你的 server 块在 http 块内
  • @AlexeyTen,是的。它在 http 块内。
  • 你能显示你的配置吗?

标签: nginx webserver


【解决方案1】:
  1. 用两个模块编译

--with-stream

--with-stream_ssl_preread_module

  1. 在 http 块之外创建一个流块
stream {
    upstream app {
        server IP1:Port;
      server IP2:Port;
    }

    map $ssl_preread_server_name $upstream {
        default app;
    }

    server {
        listen PORT;

        ssl_preread on;
        proxy_pass $upstream;
    }
}

这对我有用。让我知道这是否也适合你

【讨论】:

    【解决方案2】:

    也许你需要将 Nginx 更新到最新版本。 1.10我也遇到这个错误,但是1.18配置OK。

    【讨论】:

      【解决方案3】:

      也许这是一个迟到的答案。从 CentOS 8.3 repo 安装 nginx 1.14 时遇到以下问题。

      The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] unknown "ssl_preread_server_name" variable\nnginx: configuration file /etc/nginx/nginx.conf test failed\n',)
      The nginx plugin is not working; there may be problems with your existing configuration.
      The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] unknown "ssl_preread_server_name" variable\nnginx: configuration file /etc/nginx/
      nginx.conf test failed\n',)
      

      我通过升级最新的nginx-1:1.20.0-1.el8.ngx.x86_64 来修复它,遵循这个 URL

      http://nginx.org/en/linux_packages.html#RHEL-CentOS

      【讨论】:

        猜你喜欢
        • 2018-02-09
        • 2020-08-19
        • 1970-01-01
        • 1970-01-01
        • 2016-09-10
        • 2013-10-03
        • 2022-01-23
        • 2012-01-31
        • 1970-01-01
        相关资源
        最近更新 更多