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连接。
视觉智能开放平台操作报错合集之服务部署在pdd的服务器,调用报错:The SSL connection could not be established,该如何解决
在使用视觉智能开放平台时,可能会遇到各种错误和问题。虽然具体的错误代码和消息会因平台而异,但以下是一些常见错误类型及其可能的原因和解决策略的概述,包括但不限于:1. 认证错误、2. 请求参数错误、3. 资源超限、4. 图像质量问题、5. 服务不可用、6. 模型不支持的场景、7. 网络连接问题,这有助于快速定位和解决问题。
177 0
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
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
203 0
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER(上海蓝云阻断页)
在Azure App Service上部署的应用遇到`SSL: WRONG_VERSION_NUMBER`错误。问题可能由不兼容的TLS版本引起,但即使将最小入站TLS版本改为1.2,问题仍存在。实际原因是上海蓝云的阻断页面,表明网站未完成ICP备案或有安全规定限制。解决方案包括:1) 对App Service绑定自定义域名并进行ICP备案,或2) 使用Application Gateway处理公网请求。在复杂环境中,需仔细排查和适配规则。
219 11
|
7月前
|
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
612 0
解決pod install报错:unable to access: LibreSSL SSL_read: error:Operation timed out, errno 60
解決pod install报错:unable to access: LibreSSL SSL_read: error:Operation timed out, errno 60
133 0
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
766 0

热门文章

最新文章