所以我最近安装了nginx,现在它给了我一些错误并关闭nginx每个像.. 2小时?我该如何解决?我在错误日志中关闭之前得到了同样的错误我的错误日志中还有很多其他错误,如果这与它有关吗?
我在带有PHP的Windows 2008服务器上使用了nginx ...
2015/04/06 14:07:29 [error] 5812#5480: *552 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: 108.162.229.140, server: http://mywebsite.com, request: "GET /assets/ajax/get_bar.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com", referrer: "http://mywebsite.com/play"
2015/04/06 14:07:31 [error] 5812#5480: *600 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: 141.101.98.47, server: centralrp.co.uk, request: "GET /assets/ajax/get_bar.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "centralrp.co.uk", referrer: "http://centralrp.co.uk/play"
2015/04/06 14:10:19 [error] 5812#5480: *663 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: 141.101.98.47, server: mywebsite.com, request: "GET /home HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com", referrer: "http://mywebsite.com/index"
2015/04/06 14:19:52 [error] 5812#5480: *665 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: 141.101.98.100, server: mywebsite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com"
2015/04/06 14:21:29 [error] 5812#5480: *667 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: 141.101.98.100, server: mywebsite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com", referrer: "http://mywebsite.com/"
以上是错误日志,每次关闭之前都会记录错误,这是我的配置..
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include 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"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
root /Dropbox/Website;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
rewrite ^/hk/(.*)$ /index.php?hk=$1;
rewrite ^/(|/)$ /index.php?url=$1;
rewrite ^/([a-zA-Z0-9_-]+)(|/)$ /index.php?url=$1;
rewrite ^/(.*).htm$ /$1.php;
rewrite ^/business/manage/(.*)/(.*)/?$ /index.php?bm=$2&cid=$1;
rewrite ^/tickets/manage/(.*)/(.*) /index.php?url=manage_ticket&t=$1 last;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME C:/Dropbox/Website/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
答案 0 :(得分:1)
添加到位置
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
实施例,
location /cron/ {
...
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
答案 1 :(得分:1)
由于您使用的是fastcgi,因此实际上可能需要设置fastcgi_read_timeout。
以下是链接:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout
location ~ .php$ {
fastcgi_read_timeout 600s;
}
答案 2 :(得分:0)
我对这些问题的诊断不太熟悉,但您可能会检查系统上的一些线索。 "上游超时"可能是由于客户端请求太多,或者请求处理php代码中的某个地方被阻止,由于网络/ dns /数据库/等失败而且默认超时太长,因此fastcgi被阻止而无法处理后续请求。也许你可以先检查fastcgi或你的php代码而不用nginx来验证它是否运行良好。