当前位置:   article > 正文

[emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:35_nginx: [emerg] the "ssl" parameter requires ngx_ht

nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/loca

这个错误提示表明在Nginx配置文件(通常是nginx.conf)中使用了SSL(Secure Sockets Layer)相关的配置,但是Nginx没有加载相应的SSL模块。

1.检查Nginx是否编译了SSL模块:

/usr/local/nginx/sbin/nginx -V 2>&1 | grep --color=auto ssl
/usr/local/nginx/sbin/nginx:安装nginx的绝对路径
输出以下结果 则为安装已加载SSL模块:
configure arguments: --with-openssl=/XXX/openssl-1.1.1l --with-http_ssl_module
/XXX/openssl-1.1.1l:openssl安装位置
有这个就是安装了--with-http_ssl_module

2.如果已编译安装SSL模块,配置有问题:

1.打开Nginx配置文件(通常是nginx.conf)。
2.确保在配置文件中的server块中有正确的SSL配置,如listen 443 ssl;和证书路径等,这个在证书配置的官网有具体的所需配置。
3.nginx.conf配置举例:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    map $http_upgrade $connection_upgrade {
		default upgrade;
		''      close;
    }
    sendfile        on;
    keepalive_timeout  65;

    	server {
	     #HTTPS的默认访问端口443。
	     listen 443 ssl;
	     
	     #填写证书绑定的域名
	     server_name XXX;
	 
	     #填写证书文件名称
	     ssl_certificate cert/XXX.pem;
     	 #填写证书私钥文件名称
	     ssl_certificate_key cert/XXX.key;
	 
	     ssl_session_cache shared:SSL:1m;
	     ssl_session_timeout 5m;
		 
	     #自定义设置使用的TLS协议的类型以及加密套件(以下为配置示例,请您自行评估是否需要配置)
	     #TLS协议版本越高,HTTPS通信的安全性越高,但是相较于低版本TLS协议,高版本TLS协议对浏览器的兼容性较差。
	     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	     ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
	
	     #表示优先使用服务端加密套件。默认开启
	     ssl_prefer_server_ciphers on;
	     
	    location / {
           root   html/XXX;
           index  index.html index.htm;
            try_files $uri $uri/ /index.html; 
	    }
	    location /prod-api/{
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://XXX:XXX/;
        }
		
		location /prod-system/{
			proxy_pass http://XXX:XXX/;  #修改为需要被反向代理的WebSocket的IP和端口号
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection $connection_upgrade;
       }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61

4.重新验证Nginx配置:
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
如果没有语法错误,启动Nginx

3.如果未编译安装SSL模块(OpenSSL安装):

# 进入您希望存放 OpenSSL 源代码的目录
cd /XXX

# 下载 OpenSSL 源代码,浏览器也能访问
https://www.openssl.org/source/openssl-1.1.1l.tar.gz

# 解压 OpenSSL 源代码
tar -zxvf openssl-x.x.x.tar.gz

make
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

如果出现报错:
Operating system: x86_64-whatever-linux2 You need Perl 5.
访问:https://www.cpan.org/src/5.0/离线下载也可以

wget https://www.cpan.org/src/5.0/perl-5.30.1.tar.gz
tar -xzf perl-5.30.1.tar.gz
cd perl-5.30.1
./Configure -des -Dprefix=$HOME/localperl
make
make test
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

4.安装成功OpenSSL后,进入Nginx源代码目录,(解压出来的那个地方,安装一般都是在/usr/local/nginx)。

./configure --with-openssl=/usr/local/openssl --with-http_ssl_module
make
make install
  • 1
  • 2
  • 3

验证配置
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
启动:/usr/local/nginx/sbin目录执行./nginx
重新加载配置:/usr/local/nginx/sbin目录执行./nginx -s reload

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/320556
推荐阅读
相关标签
  

闽ICP备14008679号