Welcome! Log In Create A New Profile

Advanced

Nginx/Fastcgi Freeze

Posted by Jack0 
Nginx/Fastcgi Freeze
July 12, 2010 02:03PM
Hello,
i have problem with nginx or fastcgi, every 2-3 days one of those two(i think fastcgi) for some reason freezes and nginx just takes time to load 404 error then.
os is centos, nginx ver is 0.6.39, website traffic is ~100,000 users per day
nginx config file:
[code]
user xxxx xxxx;
worker_processes 4 ;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 4096;
use epoll;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';


sendfile on;
tcp_nodelay on;

keepalive_timeout 15;
fastcgi_read_timeout 2m;

gzip on;

server {
listen 80;
server_name xxxxx.xxx _;


location / {
root /home/xxxxx/www;
index index.php index.html index.htm;

#alot of rewrite rules

}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_buffer_size 64k;
fastcgi_buffers 4096 64k;
fastcgi_param SCRIPT_FILENAME /home/xxxxx/www$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}
}
[/code]
fastcgi params:
[code]
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
[/code]
any idea whats up or how to solve it?
Re: Nginx/Fastcgi Freeze
August 24, 2010 12:06PM
Hello.

I think this is a problem with PHP_FCGI_MAX_REQUESTS

I had this issue in windows and to work around it I made a batch file to start php-cgi but before start do
[code]
SET PHP_FCGI_MAX_REQUESTS=0
[/code]

I don't know it is possible to do in linux.

Maybe you should try adding this to fastcgi params
[code]
fastcgi_param PHP_FCGI_MAX_REQUESTS 0;
[/code]


-------------------------------------------------------------------------

Also there is a security issue with php-cgi related to cgi.fix_pathinfo explained here:
http://www.80sec.com/nginx-securit.html

I've fixed this specific problem by adding
[code]
# http://www.80sec.com/nginx-securit.html
if ( $fastcgi_script_name ~* \..*\/.*php ) {
return 403;
}
[/code]
To nginx.conf before location ~ /\.ht
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 317
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready