当前位置:   article > 正文

Nginx upstream绑定端口失败nginx: [emerg] bind() to 0.0.0.0:6445 failed (13: Permission denied)_nginx 启动端口绑定失败

nginx 启动端口绑定失败

今天在nginx配置upstream代理(四层负载均衡)重启nginx发现绑定端口失败

报错:提示端口绑定失败,权限不足

尝试将user模块改成root用户,重启nginx还是不行,并修改nginx相关目录权限为666,还是以前的报错。

  1. [root@k8s-master2 nginx]# systemctl restart nginx
  2. Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
  3. [root@k8s-master2 nginx]# journalctl -u nginx
  4. Dec 13 14:59:57 k8s-master2 systemd[1]: Starting The nginx HTTP and reverse proxy server...
  5. Dec 13 14:59:57 k8s-master2 nginx[10664]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  6. Dec 13 14:59:57 k8s-master2 nginx[10664]: nginx: [emerg] bind() to 0.0.0.0:16443 failed (13: Permission denied)
  7. Dec 13 14:59:57 k8s-master2 nginx[10664]: nginx: configuration file /etc/nginx/nginx.conf test failed
  8. Dec 13 14:59:57 k8s-master2 systemd[1]: nginx.service: control process exited, code=exited status=1
  9. Dec 13 14:59:57 k8s-master2 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
  10. Dec 13 14:59:57 k8s-master2 systemd[1]: Unit nginx.service entered failed state.
  11. Dec 13 14:59:57 k8s-master2 systemd[1]: nginx.service failed.
  12. Dec 13 15:02:31 k8s-master2 systemd[1]: Starting The nginx HTTP and reverse proxy server...
  13. Dec 13 15:02:31 k8s-master2 nginx[10724]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  14. Dec 13 15:02:31 k8s-master2 nginx[10724]: nginx: [emerg] bind() to 0.0.0.0:6445 failed (13: Permission denied)
  15. Dec 13 15:02:31 k8s-master2 nginx[10724]: nginx: configuration file /etc/nginx/nginx.conf test failed
  16. Dec 13 15:02:31 k8s-master2 systemd[1]: nginx.service: control process exited, code=exited status=1
  17. Dec 13 15:02:31 k8s-master2 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
  18. Dec 13 15:02:31 k8s-master2 systemd[1]: Unit nginx.service entered failed state.
  19. Dec 13 15:02:31 k8s-master2 systemd[1]: nginx.service failed.

查看配置Nginx文件

  1. [root@k8s-master2 nginx]# cat /etc/nginx/nginx.conf
  2. user nginx; 
  3. worker_processes auto;  
  4. error_log /var/log/nginx/error.log;  
  5. pid /run/nginx.pid;  
  6.   
  7. # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.  
  8. include /usr/share/nginx/modules/*.conf;  
  9.   
  10. events {  
  11.     worker_connections 1024;  
  12. }  
  13. stream {  
  14.         log_format main '$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent';  
  15.         access_log /var/log/nginx/k8s-access.log main;  
  16.   
  17.         upstream k8s-apiserver {  
  18.                 server 192.168.100.148:6443;  
  19.                 server 192.168.100.149:6443;  
  20.                 # Add more servers here if needed  
  21.         }  
  22.         server {  
  23.                 listen 6445; 
  24.                 proxy_pass k8s-apiserver;  
  25.                 # Add health check here if needed  
  26.         }  
  27. }

配置文件无误,检查系统其他配置

发现selinux没有关闭,关闭selinux,并重启nginx,nginx运行正常!

  1. [root@k8s-master2 nginx]# setenforce 0
  2. [root@k8s-master2 nginx]# sed -i 's/^SELINUX=permissive/SELINUX=disabled/' /etc/selinux/config
  3. [root@k8s-master2 nginx]# systemctl restart nginx

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号