[英]Nginx close keep-alive connection from php
Hello Everybody 大家好
I have trouble with nginx server . 我在nginx服务器上遇到了麻烦。 I have configured nginx with keep alive connection. 我已经配置了nginx与保持活动连接。
keepalive_timeout 65; keepalive_timeout 65;
And connect to server with persistent connection , i send many request to server in same connection . 并通过持久连接连接到服务器,我在同一连接中向服务器发送了许多请求。
I want to close persistent connection from php. 我想从php关闭持久连接。 php exit and die command closes response , not connection . php exit and die命令关闭响应,而不是连接。 And client can resend to server request in same connection . 客户端可以在同一连接中重新发送到服务器请求。
simply, i want to close persistent connection from php 简单地说,我想从php关闭持久连接
I use this command , 我用这个命令
header('Connection:close'); 报头( '连接:关闭');
But not affected , connection is still alive 但不受影响,连接仍然有效
How can close http connection from php 如何从PHP关闭HTTP连接
I took SO long to find the answer to this. 我花了很长时间才找到答案。
In PHP you need to call: 在PHP中,您需要调用:
fastcgi_finish_request();
从这个servfault答案看来,您可以通过在nginx fastcgi处理程序中允许此标头来尝试。
fastcgi_pass_header Connection-close;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.