Php-fpm没有从NGINX收到“客户端过早关闭的连接”

我有nginx版本:1.12.0以及以下配置:</ p>

   http {
server {

listen 443;
server_name SERVER_NAME_OR_IP;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;

ssl on;
ssl_certificate /path/to/cert.crt;
ssl_certificate_key /path/to/cert.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

location~ * / test / abcd / {

proxy_pass http://127.0.0.1:7000;
proxy_set_header主机$ http_host;
proxy_set_header X-Real-IP $ remote_address;
proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for ;

}
}
服务器{
listen 127.0.0.1:7000;
server_name SERVER_NAME_OR_IP;

位置/ {

位置〜\ .php $ {

fastcgi_pass 127.0。 0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $ request_filename;
fastcgi_param PHP_VALUE“upload_max_filesize = 3072M
post_max_size = 3072M”;
包括/ etc / nginx / fastcgi_params;
}
}
}
</ code> </ pre>

如果 客户端在上传文件时关闭连接,我在/var/log/error.log中看到:“epoll_wait()报告客户端过早关闭连接,因此上游连接也被关闭,同时向上游发送请求”和“客户端过早关闭连接 “。 我的问题是当客户端关闭连接时php-fpm没有收到该错误,所以我无法在我的代码中捕获此错误。 你知道可能是什么问题吗? </ p>

谢谢!</ p>
</ div>

展开原文

原文

I have nginx version: 1.12.0 and the following configuration:

http {
 server {

  listen      443;
  server_name SERVER_NAME_OR_IP;

  access_log  /var/log/nginx/access.log;
  error_log  /var/log/nginx/error.log  debug;

  ssl                  on;
  ssl_certificate      /path/to/cert.crt;
  ssl_certificate_key  /path/to/cert.key;
  ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;

  location ~* /test/abcd/ {

    proxy_pass http://127.0.0.1:7000;
    proxy_set_header        Host            $http_host;
    proxy_set_header        X-Real-IP       $remote_address;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

  }
 }
 server {
   listen       127.0.0.1:7000;
   server_name  SERVER_NAME_OR_IP;

   location / {

     location ~ \.php$ {
       fastcgi_pass   127.0.0.1:9000;
       fastcgi_index  index.php;
       fastcgi_param  SCRIPT_FILENAME  $request_filename;
       fastcgi_param   PHP_VALUE "upload_max_filesize = 3072M 
 post_max_size=3072M";
       include        /etc/nginx/fastcgi_params;
     }
   }
}

If the client closes connection during uploading a file, I see in /var/log/error.log : "epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while sending request to upstream" and "client prematurely closed connection" . My problem is that php-fpm doesn't receive that error when client closes connection, so I can't catch this error in my code. Do you know what might be the problem?

Thank You!

duanchu3376
duanchu3376 AFAIU你的脚本甚至不会被调用,直到上传完成,所以你无法在代码中处理这样的事情。
大约 3 年之前 回复
dragonsun00000
dragonsun00000 我应该能够在我的PHP代码(php.net/manual/ro/features.connection-handling.php)中捕获此错误,我认为“客户端过早关闭的连接信息”应该出现在/var/log/php中-fpm.log。
大约 3 年之前 回复
dqnrk44682
dqnrk44682 那么你应该怎么做?
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问