nginx端口转发 可能遇到的问题.md 1.2 KB

#杂七杂八常识

在排查问题前,可以先安装好网络工具: (需要提前设置好[[centos 7 额外软件库]])

 yum install net-tools

启动nginx的时候

systemctl start nginx

可能会遇到,服务启动失败相关

![[Pasted image 20250528102100.png]]

根据提示,可以输入指令,查看nginx状态相关:

systemctl status nginx.service

可以看到,是权限问题:

![[Pasted image 20250528103019.png]]

也可以通过[[curl]]直接测一下端口

curl -I http://localhost:82

可以看到,也是连接被拒绝的

![[Pasted image 20250528103516.png]]

还可以看一下,nginx的错误日志

nano /var/log/nginx/error.log 

可以看到,也是权限被拒绝相关

![[Pasted image 20250528103859.png]]

这个权限设置,和[[SELinux]]有关,参考临时关闭后,重新,分别执行三指令:

systemctl start nginx
curl -I http://localhost:82
netstat -tulpn | grep nginx

可以看到,打印信息,都是正常了

![[Pasted image 20250528104758.png]]

内部端口是通了,如果外部还没通,参考[[Linux防火墙 firewall]]即可。