nginx-lua and nginx upload module

agentzh agentzh at gmail.com
Tue Nov 29 06:01:23 UTC 2011


On Mon, Nov 28, 2011 at 6:22 PM, Valery Kholodkov
<valery+nginxen at grid.net.ru> wrote:
>
> I think we've been able to do that even before.

Sadly for nginx 0.8.41 ~ 0.8.53, "IO interruptions" are explicitly
prohibited in rewrite phase handlers and for exactly the same reason
your ngx_eval module does not work at all for these versions of Nginx
:)

> But that's not point. The problem is not in what particular phase upload module will run, but that it must run whenever some module tries to read the request body. This kind of customisation is not supported by nginx yet.
>

True. We definitely need an input filter mechanism for Nginx. I've
cc'd Andrew Alexeev. Maybe he can help make this happen in the Nginx
core ;)

>
> Again, the point is not in what particular phase it will run... And by the way, the costs of internal redirects are negligible.
>

Not really if the user has a lot of regex style locations defined in
his nginx.conf. For now, the nginx core does not (yet) utilize the
PCRE JIT feature for its pattern matching, so it does consume quite a
few CPU cycles for complicated location patterns ;) And...if we *can*
eliminate the cost of internal redirects altogether, why shouldn't we
make that happen? ;)

Also, I believe it can simplify the user config file greatly and does
not cause variable scope problems (like $uri and $args' scope). I know
there is a upload_pass_args directive to forward the original URI
query args, but if the $args scope issue does not exist in the first
place, we do not need this config directive at all.

BTW, I notice that if ngx_upload's special variables like
$upload_file_md5 are used in a wrong context, it will simply crash the
nginx worker (segmentation faults) due to null module context pointer
access (at least for the latest 2.2.0 release). Maybe it's more
reasonable to check the ctx pointer and print out a helpful error
message in functions like ngx_http_upload_md5_variable?

Best,
-agentzh



More information about the nginx mailing list