crowell / modpagespeed_tmp

Automatically exported from code.google.com/p/modpagespeed
Apache License 2.0
0 stars 0 forks source link

ngx_pagespeed: Override of "pagespeed on/off" is not allowed in nested location blocks #703

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enable or disable pagespeed at the server block
2. Override previous value in a *nested* location block on nginx

For example, this is allowed:

server {
    pagespeed on;
    location /something {
        pagespeed off;
    }
}

but this isn't:

server {
    pagespeed on;
    location / {
        #foobar
        #...
        location ~* ^/(foo|bar) {
            pagespeed off;
        }
    }
}   

What is the expected output? What do you see instead?
In some location blocks, it is allowed to override the previous on/off value 
for the pagespeed module. But in nested location blocks, an assert is thrown on 
line 716 in ngx_pagespeed.cc: CHECK(parent_cfg_l->options == NULL);

According to the documentation, "pagespeed on/off" is listed under "Directives 
that can be used anywhere" which says "Including .htaccess files (Apache), 
<Directory> scopes (Apache), and location blocks (Nginx)."

What version of the product are you using (please check X-Mod-Pagespeed
header)?

1.5.27.3-3005

On what operating system?

Linux 2.6.32-31-generic (Ubuntu 10.04 LTS)

Which version of Apache?
nginx 1.4.1

Which MPM?
n/a

URL of broken page:

Original issue reported on code.google.com by mqu...@gmail.com on 19 May 2013 at 11:30

GoogleCodeExporter commented 9 years ago
I'm sorry, it's not a matter of nested location blocks.
I think it's more to do with the order in which nginx traverses the location 
blocks, i.e. if a request falls through from one nginx location block to 
another, regardless of whether it is nested or not, yet not if the state 
machine optimizes away the fallthrough via try_files?

This doesn't work:

    server {
        pagespeed on;
        location / {
        }
        location ~* \.php$ {
            pagespeed off;
            if (-f $request_filename) {
                fastcgi_pass    unix:/tmp/php5/php5.sock;
            }
            fastcgi_index   index.php;
            include     conf/fastcgi_params;
            fastcgi_param  HTTPS   on;
        }
    }

Nor this:

    server {
        pagespeed off;
        location / {
            location ~* ^/(Home|images|includes|Software|Donate) {
                pagespeed on;
                if ($request_uri ~ \.php) {
                    return 403;
                }
                try_files $uri @aspcached;
            }
        }
    }

Yet this does:

    server {
        pagespeed off;
        location / {
            location ~* ^/(Home|images|includes|Software|Donate) {
                if ($request_uri ~ \.php) {
                    return 403;
                }
                try_files $uri @aspcached;
            }
        }

        location @aspcached {
            internal;
            pagespeed on;
        }
    }

Original comment by mqu...@gmail.com on 19 May 2013 at 11:41

GoogleCodeExporter commented 9 years ago

Original comment by sligocki@google.com on 20 May 2013 at 2:42

GoogleCodeExporter commented 9 years ago
Let's move this to the ngx_pagespeed issue tracker: 
https://github.com/pagespeed/ngx_pagespeed/issues/387

Original comment by jefftk@google.com on 20 May 2013 at 5:03