Upload progress module: "track_uploads" directive inside an "if" block.
Dave Rothlisberger
dave at rothlis.net
Mon Jan 19 15:53:24 MSK 2009
After further investigation, it seems that the upload progress tracker
is stuck at 'state: starting'.
(while uploading a large file, if I do a GET for /upload_progress?X-
Progress-ID=xxxx in a separate browser window, I get:
new Object({ 'state' : 'starting' })
even a minute after it has started uploading).
Once again, this only happens if the "track_uploads" directive is
inside an "if" block; otherwise it works fine.
Regards,
Dave. Rothlisberger.
On 18/01/2009, at 8:39 PM, Dave Rothlisberger wrote:
> Thanks for the suggestion. I've tried the patch on my staging
> server, and it does indeed allow the configuration file to validate,
> but the actual progress bar is not working.
>
> With the patch, but without using an "if" block, the progress bar
> does work correctly, as before.
>
> I will have to investigate further tomorrow as it is getting late. :-)
>
> Cheers
> Dave Rothlisberger.
>
>
> On 18/01/2009, at 7:25 PM, Valery Kholodkov wrote:
>
>> It is because upload progress module's directives do not have flag
>> which tells nginx to allow them in if block. Patch in attachment
>> might help.
>>
>> Dave Rothlisberger wrote:
>>> Hi,
>>> I am using nginx as a proxy in front of a mongrel cluster running
>>> a rails application.
>>> I can't seem to get nginx to serve static files *and* use the
>>> upload progress module (I can achieve one or the other, but not
>>> both at the same time).
>>> For example, if I use an "if" block so that requests for static
>>> files aren't passed to the mongrel cluster:
>>> location / {
>>> ...
>>> if (!-f $request_filename) {
>>> proxy_pass http://mongrel_cluster;
>>> track_uploads proxied 30s;
>>> }
>>> }
>>> This gives the following error message:
>>> [emerg] 12265#0: "track_uploads" directive is not allowed here
>>> If I try, instead:
>>> location / {
>>> ...
>>> if (!-f $request_filename) {
>>> proxy_pass http://mongrel_cluster;
>>> }
>>> track_uploads proxied 30s;
>>> }
>>> I get the following error message:
>>> [emerg] 12266#0: "track_uploads" directive track_upload should be
>>> the last directive in the location, after either proxy_pass or
>>> fastcgi_pass
>>> If I remove the "if" condition completely:
>>> location / {
>>> proxy_pass http://mongrel_cluster;
>>> track_uploads proxied 30s;
>>> }
>>> That works, but then all requests are proxied to the mongrel
>>> cluster, even requests for static files, and even requests for the
>>> "maintenance.html" page which I put up (with a separate rewrite
>>> rule) when I want to take the mongrel cluster down for maintenance
>>> (rails developers will be familiar with this). The request for the
>>> "maintenance.html" file is sent to the mongrels, which are down,
>>> resulting in a "502 Bad Gateway" error. And even the request for
>>> my "50x.html" error page is proxied to the mongrel cluster (which
>>> is down) so users get the default nginx 502 error page.
>>> Does anyone know of a way around this, or a better way to
>>> configure the proxy_pass to avoid this issue? Any help would be
>>> *much* appreciated.
>>> My full nginx config file is pasted below.
>>> Regards,
>>> --Dave Rothlisberger.
>>> user xxx xxx;
>>> worker_processes 4;
>>> pid /var/run/nginx.pid;
>>> error_log logs/error.log notice;
>>> events {
>>> worker_connections 1024;
>>> }
>>> http {
>>> include mime.types;
>>> default_type application/octet-stream;
>>> upload_progress proxied 1m;
>>> # This log format is compatible with any tool like awstats
>>> # that can parse standard apache logs.
>>> log_format main '$remote_addr - $remote_user [$time_local] '
>>> '"$request" $status $body_bytes_sent
>>> "$http_referer" '
>>> '"$http_user_agen" "$http_x_forwarded_for"';
>>> sendfile on;
>>> tcp_nopush on;
>>> tcp_nodelay on;
>>> keepalive_timeout 65;
>>> gzip on;
>>> gzip_http_version 1.0;
>>> gzip_comp_level 2;
>>> gzip_proxied any;
>>> gzip_types text/plain text/html text/css application/x-javascript
>>> text/xml application/xml application/xml+rss text/
>>> javascript;
>>> # Load balance to mongrels
>>> upstream mongrel_cluster {
>>> server 0.0.0.0:8000;
>>> server 0.0.0.0:8001;
>>> }
>>> server {
>>> listen 80;
>>> server_name xxxx.com
>>> root /home/xxxx/xxxx/current/public;
>>> access_log /home/xxxx/xxxx/shared/log/nginx.access.log main;
>>> error_page 500 502 503 504 /50x.html;
>>> client_max_body_size 50M; # Avoid attempts to overload the
>>> server
>>> # Rewrite rule: Display maintenance page if it exists
>>> # (capistrano disable task creates this maintenance page)
>>> # BUT allow the image in the maintenance page to be displayed
>>> if ($request_filename ~ ^/images/) {
>>> break;
>>> }
>>> if (-f $document_root/system/maintenance.html) {
>>> rewrite ^(.*)$ /system/maintenance.html last;
>>> break;
>>> }
>>> location / {
>>> index index.html index.htm;
>>> location ~ ^/(images|javascripts|stylesheets)/ {
>>> expires 10y;
>>> }
>>> if (-f $request_filename) {
>>> break;
>>> }
>>> # Directly serve cached pages
>>> if (-f $request_filename.html) {
>>> rewrite (.*) $1.html break;
>>> }
>>> # Otherwise let mongrel handle the request
>>> #if (!-f $request_filename) { # Commented because of
>>> "track_uploads" problem
>>> proxy_pass http://mongrel_cluster;
>>> track_uploads proxied 30s;
>>> #}
>>> location ^~ /upload_progress {
>>> report_uploads proxied;
>>> }
>>> }
>>> }
>>> }
>>
>>
>> --
>> Regards,
>> Valery Kholodkov
>> diff -Naur nginx_uploadprogress_module/
>> ngx_http_uploadprogress_module.c nginx_uploadprogress_module-mine/
>> ngx_http_uploadprogress_module.c
>> --- nginx_uploadprogress_module/ngx_http_uploadprogress_module.c
>> 2008-06-27 11:31:09.000000000 +0200
>> +++ nginx_uploadprogress_module-mine/
>> ngx_http_uploadprogress_module.c 2009-01-19 01:18:27.000000000 +0100
>> @@ -75,14 +75,14 @@
>> NULL},
>>
>> {ngx_string("track_uploads"),
>> - NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
>> NGX_CONF_TAKE2,
>> + NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
>> NGX_HTTP_LIF_CONF | NGX_CONF_TAKE2,
>> ngx_http_track_uploads,
>> NGX_HTTP_LOC_CONF_OFFSET,
>> 0,
>> NULL},
>>
>> {ngx_string("report_uploads"),
>> - NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
>> NGX_CONF_TAKE1,
>> + NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
>> NGX_HTTP_LIF_CONF | NGX_CONF_TAKE1,
>> ngx_http_report_uploads,
>> NGX_HTTP_LOC_CONF_OFFSET,
>> 0,
>
More information about the nginx
mailing list