nginx:[emerg] 未知的“name”变量,nginx:[emerg] 未知的“ssl_preread_server_name”变量

nginx:[emerg] 未知的“name”变量,nginx:[emerg] 未知的“ssl_preread_server_name”变量

我正在尝试使用 Debian 11 中的 NGINX 1.18 设置自己的 Stealth VPN 服务器。我遵循本指南但许多指令不起作用。问题是当我发出nginx -t测试命令时输出是:

 - nginx: [emerg] unknown "ssl_preread_server_name" variable

我将此变量从 更改$ssl_preread_server_name$server_name如果问题仅出在这个特定变量上,并查看是否还有其他错误,则测试通过,但发现另一个变量错误,即这个:

 - nginx: [emerg] unknown "name" variable`

这是文件 os 中我最后一个服务器代码块nginx.conf,我不希望它再发现任何错误。我检查了 Nginx 变量的原始数据集,变量$name$ssl_preread_server_name是官方的并且存在。我遵循的指南说它们应该像这样分配,但互联网上没有其他指南,所以我有点卡住了。

到目前为止,我只对这两个变量有问题。它们位于map块和最后server一个块中。非常感谢您的帮助

这是我的全部代码:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

        ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
        ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

        ##
        # Servers
        ##
        
        server {
            # server_name 206.189.21.228;
              listen 127.0.0.1:8000;
        }

        ##
        # map
        ##

        map $ssl_preread_server_name $name {
            default https;
            206.189.21.228 vpn;
        }

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

stream { 
     ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
     ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
    
     upstream https {
         server unix:/etc/nginx/nginx_writing;
         }
    
     upstream vpn {
         server unix:/etc/openvpn/openvpn_writing;
     }
    
     server {
         listen unix:/etc/nginx/nginx_writing ssl;
         # openvpn doesn't support unix-sockets
         proxy_pass 127.0.0.1:1194;
     }
    
     server {
         listen unix:/etc/nginx/nginx_writing2 ssl;
         # could also use a unix-socket here
         proxy_pass 127.0.0.1:8000;
     }
    
    server { 
        listen [::]:443 ipv6only=off;
        proxy_protocol on;
        proxy_pass $name;
    }

}

答案1

问题是您的 nginx 没有所需的ngx_stream_ssl_preread模块。您需要找到包含此模块的 nginx 版本。

相关内容