nginx开启ssl报错: [emerg] “server“ directive is not allowed here in /usr/local/nginx/conf/nginx.conf:106

wx60c1f94c784b4

nginx开启ssl报错: [emerg] “server“ directive is not allowed here in /usr/local/nginx/conf/nginx.conf:106

报错信息如下:

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

nginx开启ssl报错: [emerg] “server“ directive is not allowed here in /usr/local/nginx/conf/nginx.conf:106_html

nginx开启ssl报错: [emerg] “server“ directive is not allowed here in /usr/local/nginx/conf/nginx.conf:106_html_02

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

↓↓↓↓↓↓

最近刚申请了个微信公众号,上面也会分享一些运维知识,大家点点发财手关注一波,感谢大家。 ​【原创公众号】:非著名运维 【福利】:公众号回复 “资料” 送运维自学资料大礼包哦!​

nginx开启ssl报错: [emerg] “server“ directive is not allowed here in /usr/local/nginx/conf/nginx.conf:106_nginx_03

如果你觉得这篇文章还不错,就请动动你的 发财手 为本文 留个言 ,或者 转发一下 吧,因为 这将是我持续输出更多优质文章的最强动力



nginx: [emerg] unknown directive "if($remote_addr" in /usr/local/tools/nginx/conf/nginx.conf:57

一句话if 和 ( 缺一个空格 ,如果没有空格他把if($request_uri当成一个指令了,没有这个指令自己玩去吧

nginx: [emerg] directive “server_name“ is not terminated by “;“ in /usr/local/openresty/nginx/conf..

[root@c7 sbin]# ./nginx -tnginx: [emerg] directive "server_name" is

nginx: [emerg] invalid number of arguments in “proxy_pass“ directive in /usr/local/nginx/conf

1.出现的问题 在修改nginx 配置文件的时候 修改了http处 重新启动就报错。nginx: [emerg] invalid number of arguments in "proxy_pass" directive in /usr/local/nginx/conf/nginx.conf:462.问题分析估计是文件写错了 一搜就找到了解决方案。3.问题解决缺少了分号。加上就可以了。...

【nginx】nginx: [emerg] invalid number of arguments in "proxy_pass" directive in /usr/local/nginx/conf

1.出现的问题 在修改nginx 配置文件的时候 修改了http处 重新启动就报错。nginx: [emerg] invalid number of arguments in "proxy_pass" directive in /usr/local/nginx/conf/nginx.conf:462.问题分析估计是文件写错了 一搜就找到了解决方案。3.问题解决缺...

nginx反向代理: [emerg] invalid number of arguments in "root" directive in nginx/nginx.conf:57

server { listen 80; server_name localhost:8080; #charset koi8-r; #access_log logs/host.access.log main; location / { #root html; ...