How to resolve Nginx’s frequent 502 bad gateway errors

How to resolve Nginx’s frequent 502 bad gateway errors

During these 2 days of a PHP site, 502 bad gateways frequently appeared, and the following items were added in the nginx configuration file: Solve:

Bold text are add items:

server
{
listen 80;
server_name shop;
index index.html index.htm index.php;
root /home/ngixroot/shop2;
tcp_nodelay on;
fastcgi_keep_conn on;
fastcgi_connect_timeout 10000;
fastcgi_send_timeout 10000;
fastcgi_read_timeout 10000;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;

 
location / {

if (!-e $request_filename) {

# rewrite ^/(.*)$ /index.php/$1 last;

# break;
}

}

location ~ \.php {

fastcgi_connect_timeout 10000;
fastcgi_send_timeout 10000;
fastcgi_read_timeout 10000;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

# include fcgi.conf;
include fastcgi_params;

set $real_script_name $fastcgi_script_name;

if ($fastcgi_script_name ~ “^(.+?\.php)(/.+)$”) {

set $real_script_name $1;

set $path_info $2;

}

fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;

fastcgi_param SCRIPT_NAME $real_script_name;

fastcgi_param PATH_INFO $path_info;

}
location /status {
stub_status on;
access_log off;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}
error_log logs/error1.log;
}


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *