502 Bad Gateway

Nginx日志报错:
2019/04/19 14:32:38 [error] 4724#3156: *133 connect() failed (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 106.39.246.136, server: www.zcib.edu.cn, request: "GET /userfiles/files/xszb/220952693311797014.jpg HTTP/1.1", upstream: "http://10.240.5.9:80/userfiles/files/xszb/220952693311797014.jpg", host: "www.zcib.edu.cn", referrer: "http://www.zcib.edu.cn/site/RecruitmentNetwork/RN2EnrollmentDynamics/info/2018/14826.html"

2019/04/22 15:24:04 [error] 4248#1144: *1297 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 222.85.110.137, server: 127.0.0.1, request: "GET /zcib/site/xsgate/xsyw/index_1.html HTTP/1.1", upstream: "http://10.240.5.9:80/zcib/site/xsgate/xsyw/index_1.html", host: "www.zcib.edu.cn"

重新加载配置文件
命令:nginx -s reload
报错:nginx: [error] OpenEvent("Global\ngx_reload_3800") failed (5: Access is denied)
根据这个提示分析,应该是权限问题,这时我分别用服务启动和命令启动nginx后发现
服务启动后 nginx 是以 system 身份运行的,而 命令启动后 nginx 是以 administrator 身份运行的
这样看问题应该是出在了服务的运行身份上,所以我们应该修改服务的运行身份,具体修改方法:
服务--》NGNIX--》属性--》登陆--》登陆身份--》选择,此账户后,账户填入administration,再填入密码
修改完后重启服务再试 nginx -s reload ,一切正常