2015-04-06 114 views
1

所以我最近安裝了nginx,現在它給了我一些錯誤,並關閉nginx每個像.. 2小時?我該如何解決它?在錯誤日誌中關閉之前,我收到了相同的錯誤如果這與它有關,我也會在錯誤日誌中看到很多其他錯誤?Nginx上游超時

我在Windows中使用nginx的2008服務器與PHP ...

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/" 

,上面是錯誤日誌和我GE tthem每一次錯誤就關閉了,這裏之前是我的配置..

#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; 
    # } 
    #} 

} 

回答

1

添加到位置

proxy_read_timeout 3600s; 
proxy_send_timeout 3600s; 

實施例,

location /cron/ { 

...  

proxy_read_timeout 3600s; 
proxy_send_timeout 3600s;  

}

+0

還是一樣,它只是關閉更快。 – 2015-04-06 16:16:12

0

我不是很熟悉這類問題的診斷,但也有可能會在系統上查詢了一些線索。 「上游超時」可能由客戶端請求太多引起,或者由於網絡/ dns /數據庫/等故障而導致請求處理php代碼中某處出現阻塞,並且默認超時時間過長,因此fastcgi被阻止,無法進行處理後續請求。也許你可以先檢查fastcgi或者你的php代碼,而不用nginx來驗證它運行正常。