nginx开启ssl报错: [emerg] "server" directive is not allowed here ...

简介: nginx开启ssl报错: [emerg] "server" directive is not allowed here ...

报错信息如下:

root@localhost conf]# /usr/local/nginx/sbin/nginx -t
nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:106
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

使用的Nginx版本:

root@localhost conf]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled

SSL配置如下:

[root@localhost conf]# vim /usr/local/nginx/conf/nginx.conf
......
server {
        listen       443 ssl;
        server_name  localhost;
        ssl_certificate      cert.pem;
        ssl_certificate_key  cert.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}

出现上面的问题,首先要排查ssl的模块有没有装,没有装则需要装上。

[root@localhost conf]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.16.1
...
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module

全部都检查了,没有问题,又从最基础的地方检查,后面原来是一个 } 的问题,删了就好了。

[root@localhost conf]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost conf]# /usr/local/nginx/sbin/nginx -s reload

1.png2.png

成功,所以细节还是挺重要的。❤

目录
打赏
0
0
0
0
12
分享
相关文章
记录解决一个小错误:Establishing SSL connection without server‘s identity verification is not recommended
本文记录了解决Spring Boot连接MySQL时出现的SSL连接警告问题的步骤,通过在数据源配置中添加`useSSL=false`来禁用SSL连接。
nginx配置证书和私钥进行SSL通信验证
nginx配置证书和私钥进行SSL通信验证
71 4
如何测试Nginx反向代理实现SSL加密访问的配置是否正确?
如何测试Nginx反向代理实现SSL加密访问的配置是否正确?
255 60
配置Nginx反向代理实现SSL加密访问的步骤是什么?
我们可以成功地配置 Nginx 反向代理实现 SSL 加密访问,为用户提供更安全、可靠的网络服务。同时,在实际应用中,还需要根据具体情况进行进一步的优化和调整,以满足不同的需求。SSL 加密是网络安全的重要保障,合理配置和维护是确保系统安全稳定运行的关键。
336 60
nginx安装部署ssl证书,同时支持http与https方式访问
为了使HTTP服务支持HTTPS访问,需生成并安装SSL证书,并确保Nginx支持SSL模块。首先,在`/usr/local/nginx`目录下生成RSA密钥、证书申请文件及自签名证书。接着,确认Nginx已安装SSL模块,若未安装则重新编译Nginx加入该模块。最后,编辑`nginx.conf`配置文件,启用并配置HTTPS服务器部分,指定证书路径和监听端口(如20000),保存后重启Nginx完成部署。
912 8
FFmpeg错误笔记(一):nginx-rtmp-module推流出现 Server error: Already publishing
这篇文章讨论了在使用nginx-rtmp-module进行RTMP推流时遇到的“Server error: Already publishing”错误,分析了错误原因,并提供了详细的解决办法,包括修改nginx配置文件和终止异常的TCP连接。
314 0
FFmpeg错误笔记(一):nginx-rtmp-module推流出现 Server error: Already publishing
Python使用urllib或者urllib2模块打开网页遇到ssl报错
Python使用urllib或者urllib2模块打开网页遇到ssl报错
59 0
java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version
java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等