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网络爬虫获取软科中国最好
- 下一篇: 高精度定位系统:地铁隧道人员定位智能巡检