variable proxy_read_timeout ?
Evan Miller
emmiller+gmane at gmail.com
Tue May 29 03:08:45 MSD 2007
Brice Figureau <brice+nginx at ...> writes:
>
> Hi,
>
> Running nging 0.5.16 it seems impossible to write something like this:
>
> server {
> ...
> set $read_timeout 90;
>
> if ( $query_string ~* special-paramater ) {
> set $read_timeout 1200;
> }
>
> location ~* .+\.php$ {
> proxy_pass http://127.0.0.1;
> proxy_read_timeout $read_timeout;
> }
> ...
> }
>
> Nginx complains with:
> 2007/05/28 12:05:33 [emerg] 22267#0: the "proxy_read_timeout" directive
> invalid value in /etc/nginx/nginx.conf:155
>
> My problem is that the upstream server can take a quite long time to
> answer some queries (long computations).
> I don't have the possibility to modify the upstream server to send a few
> bytes every read_timeout seconds, and I don't want to have all the
> requests to the upstream server with a proxy_read_timeout of 1200s
> (because it won't detect unresponsive upstream server then).
>
> Any idea on how I can work-around that ?
> Thanks,
Unfortunately, configuration directives have to be specially programmed to
accept variables, and proxy_read_timeout doesn't swing that way. I actually
don't think there's a great solution to your problem. One thought is to use some
rewrite directives, which is dirty, but I think it'll get the job done.
Something like:
server {
if ( $query_string ~* special-paramater ) {
rewrite ^(.*)$ /long/computation$1;
}
location ~* .+\.php$ {
proxy_pass http://127.0.0.1;
proxy_read_timeout 90;
}
location /long/computation {
rewrite ^/long/computation(.*)$ $1 break;
proxy_pass http://127.0.0.1;
proxy_read_timeout 1200;
}
}
I feel dirty just writing that, and in fact it's so dirty I refuse to test on my
own machine. ;)
Evan
More information about the nginx
mailing list