简体   繁体   English

Nginx:fastcgi-proxy何时触发? 在请求标头之后还是在加载请求正文之后?

[英]Nginx: When is the fastcgi-proxy triggered? After request-header or after request-body is loaded?

Is the PHP setting max_input_time relevant, when having nginx as webserver in front? 将nginx用作Web服务器时,PHP设置max_input_time是否相关?

The whole story: 整个故事:

Take the case that a visitor is uploading a file. 以访客正在上传文件的情况为例。 The nginx webserver, listening on port 80, will get the request first. 监听端口80的Nginx Web服务器将首先获取请求。

Nginx itself has a client_header_timeout setting, which should not be that relevant since file-uploads are handled in the request body. Nginx本身具有client_header_timeout设置,该设置与该设置无关,因为文件上载是在请求正文中处理的。 The client_body_timeout is the maximum amount of time, the client can send this request-body, containing the file and some other POST data. client_body_timeout是最长时间,客户端可以发送此请求正文,其中包含文件和其他一些POST数据。 The size of this data can be limited by client_max_body_size, right? 该数据的大小可以受client_max_body_size的限制,对吗?

PHP now waits for the data. PHP现在正在等待数据。 This time is limited by max_input_time. 此时间受max_input_time限制。 And when it has all the data, it checks that the request-body does not exceed it's post_max_size limitation, parses it and checks, that the file does not exceed the upload_max_filesize limitation. 并且当拥有所有数据时,它将检查请求正文是否未超出post_max_size限制,然后对其进行解析并检查文件是否未超过upload_max_filesize限制。 And now the php-script will be executed, which should not take longer than max_execution_time. 现在,将执行php-script,该过程不应超过max_execution_time。

But when does my fastcgi-proxy get loaded? 但是我的fastcgi-proxy何时加载? Is it after the request-header is loaded, after the request-body is loaded or when does it get triggered? 是在请求标头加载之后,请求体加载之后还是何时触发?

Or ... put this question another way: Is the PHP configuration max_input_time relevant at all, when I have PHP running using PHP-FPM, backed by an nginx webserver? 或者...以另一种方式提出这个问题:当我有一个由nginx网络服务器支持的使用PHP-FPM运行的PHP时,PHP配置max_input_time是否完全相关? Do I have to increase this value when the vistor has a bad bandwidth but wants to upload a huge file, or is it enough to increase the nginx setting for client_body_timeout? 当访问者的带宽较差但想上传一个大文件时,是否必须增加此值?是否足以增加client_body_timeout的Nginx设置?

Please correct me if the assumption is not correct! 如果假设不正确,请纠正我!

Just to give an answer, that's convenient for me: 给出一个答案,对我来说很方便:

I tried to upload a 18MB file and I got it within 50sec. 我尝试上传一个18MB的文件,并在50秒内收到了它。 The fastcgi-proxy was limited to 10sec. fastcgi-proxy限制为10秒。 So, for me, it seems that nginx is caching the whole request before it sends it to the fastcgi-proxy. 因此,对我来说,nginx似乎在将整个请求发送到fastcgi-proxy之前将其缓存。

So, to have it short: No. I don't need to exceed the max_input_time in my case. 因此,简而言之:不。我不需要超过max_input_time。

This may vary from configuration to configuration. 这可能因配置而异。 It would be fine to have someone who knows the code and can tell which options this depends on. 最好有人知道该代码并且可以告诉您这取决于哪些选项。

On IRC, nobody could really tell me, when nginx sends the data to the fastcgi-proxy ... 在IRC上,当nginx将数据发送到fastcgi-proxy时,没人能真正告诉我...

EDIT: 编辑:

Just wanted to add another resource, that confirms my suggestion here: 只是想添加另一个资源,在这里确认了我的建议:

Unfortunately PHP gets the data only after the upload is completed and [...] 不幸的是,PHP仅在上传完成并且[...]之后才获取数据

See the accepted answer in Does session upload progress work with nginx and php-fpm? 请参阅会话上传进度是否可以与nginx和php-fpm一起使用中的可接受答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM