doujiao1814 2018-10-01 22:42
浏览 257

客户端通过nginx取消请求是否传递给fastcgi

I'm using NGINX as a reverse proxy in conjunction with the ngx_http_fastcgi_module. It is proxying requests to a custom Golang FastCGI that executes a PHP-CGI process.

There are requests that take an excessive amount of time because of some complex code that our customers are using. If the User clicks a different link while waiting for the request the browser cancels the previous request and NGINX sees it:

[info] 24#24: *1516 client 1.2.3.4 closed keepalive connection

which is great! But my upstream PHP-CGI process continues to run until it times out. This can consume a lot of resources if the user continues to click more links. I suspect my problem might be that NGINX isn't explicitly cancelling the upstream request. I've found the setting fastcgi_ignore_client_abort and it seems that by default it would not be ignored (which is good). It says:

Determines whether the connection with a proxied server should be closed when a client closes the connection without waiting for a response.

Does that mean it's actually terminating the upstream request as well, or just ignoring the upstream request/response?

And if it should be sending a signal upstream, is there a way in NGINX that I can verify it is working as expected?

On the Fast-CGI side of things the Golang server is listening for a Done() from the http.Request.Context() while it executes the request. If NGINX is explicitly terminating the upstream request we think that should detect it. Does anyone know if that's incorrect?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 fluent的在模拟压强时使用希望得到一些建议
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流
    • ¥15 Rstudio 保存代码闪退