果然,是nginx虚拟主机指定的FastCGI服务器监听端口错了,这样就会导致nginx没有得到FastCGI服务器的响应。所以浏览器发出请求时,nginx给浏览器返回一个502的状态码,告诉浏览器上游的FastCGI服务器没有响应。
4,解决
在nginx的虚拟主机中,把fastcgi_pass指定的端口修改正确,这个错误就解决了。
5,总结
(1)HTTP状态码5打头的错误是由服务器端引起的,502 bad gateway则是由于作为网关或者代理工作的服务器(web服务器)尝试执行请求时,从上游服务器(fastcgi服务器)接收到无效的响应。
(2)fastcgi_pass是ngx_http_fastcgi_module模块的一个配置指令,它指定了fastcgi服务器的地址,nginx文档中对于它的描述如下:
1 Syntax: fastcgi_pass address;
2 Default: —
3 Context: location, if in location
4
5 Sets the address of a FastCGI server. The address can be specified as a domain name or IP address, and a port:
6 fastcgi_pass localhost:9000;
7
8 or as a UNIX-domain socket path:
9 fastcgi_pass unix:/tmp/fastcgi.socket;
10
11 If a domain name resolves to several addresses, all of them will be used in a round-robin fashion. In addition, an address can be specified as a server group.