136,709
社区成员
发帖
与我相关
我的任务
分享一、问题描述:
某次用户权限切换过程中,使用普通用户重启nginx过程中报错:
[warn] 11984#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] bind() to 0.0.0.0:446 failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed
二、分析处理
1)初始根据判断,446端口为https配置,换衣修改ssl目录权限所致,但是普通用户确实已经有/etc/ssl的权限,不应该的;
2)相关经验表明:nginx: [emerg] bind() to 0.0.0.0:446 failed (13: Permission denied),是因为小于1024的端口无法用普通用户权限启动,或要监听的端口不在http要求的端口列表,这通常伴随着你的系统启用了selinux,现场实际我们并没启用selinux,如果你的环境启用,可参考如下排查:
semanage port -l | grep http_port_t #查看http允许监听的端口
semanage port -a -t http_port_t -p tcp 446 #将你要监听的端口加入允许列表
完成后,重启nginx;
3)现场版本为:8.2p1,依赖于openssl 1.0.2k,后经测试该版本中正如报错中提示,nginx主进程master是不能被普通用户执行的,只能用root,worrker进程可使用普通用户运行,修改nginx.conf,修改用户为blue,root下重启nginx即可;