Nginx 502 Bad Gateway can be forcibly refreshed by the client, but the solution is either to change the configuration or put it on the CDN. In this case, someone found that index.html can be accessed. Because we are an online website and do not have much time to study it, this is temporary. Then, someone suggested that Ctrl + F5 should be used to refresh the cache on the server, this really solves the problem. It will take a long time to put the O & M suggestions on the CDN! The following is a solution for other people on the Internet: we encountered many problems when using nginx, first, we will solve the problem of nginx 502 error. After analysis, we opened the nginx Error Log and found the error prompts such as "pstream sent too big header while reading response header from upstream, after checking the information, the problem was caused by a bug in the nginx buffer zone. The page consumption on our website may be too large in the buffer zone.
We are nginx reverse proxy.
Proxy is used when nginx is used for client forwarding. If the header is too large, it exceeds the default 1 K, the above upstream sent too big header will be triggered (to put it bluntly, nginx will send external requests to the backend Apache, And the header returned by ApacheThis is because nginx is too large to handle.
Server {
Listen 80;
SERVER_NAME* .Xywy.com;
Large_client_header_buffers 4 16 K;
# Charset koi8-r;
# Access_log off;
Location /{
# Add the three rows,
Proxy_buffer_size 64 K;
Proxy_buffers 32 32 K;
Proxy_busy_buffers_size 128 K;
Proxy_set_header host $ host;
Proxy_set_header X-real-IP $ Remote_addr;
Proxy_set_header X-forwarded-$ Proxy_add_x_forwarded_for;
Set $ baiduspider '';
If ($ http_user_agent ~ Baiduspider ){
Set $ baiduspider Baidu;
}
............
For nginx + phpcgi
Fastcgi_connect_timeout 60;
Fastcgi_send_timeout 180;
Fastcgi_read_timeout 180;
Fastcgi_buffer_size 128 K;
Fastcgi_buffers' 4 256 K;
Fastcgi_busy_buffers_size 256 K;
Fastcgi_temp_file_write_size 256 K;
Fastcgi_intercept_errors on
011/01/07 11:12:57 [Error] 10770 #0: * 38585340 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 116.22.131.154, server: * .xywy.com, request: "Get/ysmp/index. PHP? Did = 124994 HTTP/1.0 ", upstream:" http: // 127.0.0.1: 8080/ysmp/index. php? Did = 124994 ", host:" xywy.yn16.com"
Then there was a new error. Upstream timed out?
Server {
Listen 80;
SERVER_NAME* .Xywy.com;
Large_client_header_buffers 4 16 K;
Client_max_body_size 300 m;
Client_body_buffer_size 128 K;
Proxy_connect_timeout 600;
Proxy_read_timeout 600;
Proxy_send_timeouts 600;
Proxy_buffer_size 64 K;
Proxy_buffers 4 32 K;
Proxy_busy_buffers_size 64 K;
Proxy_temp_file_write_size 64 K;
# Charset koi8-r;
# Access_log off;
Then I changed the parameter...
Refer:
Http://www.cnblogs.com/derekchen/archive/2011/02/21/1959626.html
Http://wiki.nginx.org/NginxHttpProxyModule
Http://blog.sina.com.cn/s/blog_5dc960cd0100i4mt.html