SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port
附加表现症状:服务器起来后本地curl 127.0.0.1:端口可以访问 但是配置nginx代理用80端口转发后无法访问。
环境: CentOS8
今天,由于需要把httpd的端口改为一个自定义的端口,结果修改后,httpd启动失败。查看syslog发现报错:SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 。
从日志看,显然是被SELinux给拦截了。
SELinux为系统里的所有端口进行分配。缺省条件下,所有小于1024的端口都标识为保留端口类型 reserved_port_t;所有大于1024的端口标识为port_t。还有一些专用的类型,比如说80端口,对应的类型是http_port_t;5060端口则是sip_port_t。如果你想查询SELinux的所有端口类型,可以用semanage工具。
# semanage port -l
看下http端口有哪些:
# semanage port -l | grep http
http_cache_port_t tcp 8080, 8118, 8123, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
那么解决方案一:从80, 81, 443, 488, 8008, 8009, 8443, 9000里挑选一个配置给httpd。
解决方案二:增加一个http端口:
# semanage port -a -t http_port_t -p tcp 5060
由于5060端口已经分配给SIP,所以上面的的命令是会报错的。
如果不需要,也可以关闭策略
semanage port -d -t http_port_t -p tcp 5060
总结
以上是生活随笔为你收集整理的SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 利用python网络爬虫获取软科中国最好
- 下一篇: 高精度定位系统:地铁隧道人员定位智能巡检