diff --git a/README.md b/README.md index 5b985f224..6f130e225 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,11 @@ recompiling Tengine](https://github.com/pagespeed/ngx_pagespeed/wiki/Using-ngx_p ```bash $ cd ~ - $ wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.7.30.3-beta.zip - $ unzip v1.7.30.3-beta.zip # or unzip v1.7.30.3-beta - $ cd ngx_pagespeed-1.7.30.3-beta/ - $ wget https://dl.google.com/dl/page-speed/psol/1.7.30.3.tar.gz - $ tar -xzvf 1.7.30.3.tar.gz # expands to psol/ + $ wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.7.30.4-beta.zip + $ unzip v1.7.30.4-beta.zip # or unzip v1.7.30.4-beta + $ cd ngx_pagespeed-1.7.30.4-beta/ + $ wget https://dl.google.com/dl/page-speed/psol/1.7.30.4.tar.gz + $ tar -xzvf 1.7.30.4.tar.gz # expands to psol/ ``` 3. Download and build nginx: @@ -49,10 +49,10 @@ recompiling Tengine](https://github.com/pagespeed/ngx_pagespeed/wiki/Using-ngx_p ```bash $ cd ~ $ # check http://nginx.org/en/download.html for the latest version - $ wget http://nginx.org/download/nginx-1.4.4.tar.gz - $ tar -xvzf nginx-1.4.4.tar.gz - $ cd nginx-1.4.4/ - $ ./configure --add-module=$HOME/ngx_pagespeed-1.7.30.3-beta + $ wget http://nginx.org/download/nginx-1.4.6.tar.gz + $ tar -xvzf nginx-1.4.6.tar.gz + $ cd nginx-1.4.6/ + $ ./configure --add-module=$HOME/ngx_pagespeed-1.7.30.4-beta $ make $ sudo make install ``` @@ -95,7 +95,7 @@ To confirm that the module is loaded, fetch a page and check that you see the ```bash $ curl -I 'http://localhost:8050/some_page/' | grep X-Page-Speed -X-Page-Speed: 1.7.30.3-... +X-Page-Speed: 1.7.30.4-... ``` Looking at the source of a few pages you should see various changes, such as diff --git a/config b/config index 4cdd8ee05..260fac846 100644 --- a/config +++ b/config @@ -27,8 +27,8 @@ if [ "$mod_pagespeed_dir" = "unset" ] ; then echo " You need to separately download the pagespeed library:" echo "" echo " $ cd /path/to/ngx_pagespeed" - echo " $ wget https://dl.google.com/dl/page-speed/psol/1.7.30.2.tar.gz" - echo " $ tar -xzvf 1.7.30.2.tar.gz # expands to psol/" + echo " $ wget https://dl.google.com/dl/page-speed/psol/1.7.30.4.tar.gz" + echo " $ tar -xzvf 1.7.30.4.tar.gz # expands to psol/" echo "" echo " Or see the installation instructions:" echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build" diff --git a/src/ngx_pagespeed.cc b/src/ngx_pagespeed.cc index 29b60fa0a..52734995b 100644 --- a/src/ngx_pagespeed.cc +++ b/src/ngx_pagespeed.cc @@ -504,15 +504,24 @@ char* ps_init_dir(const StringPiece& directive, return NULL; // We're not root, so we're staying whoever we are. } + // chown if owner differs from nginx worker user. ngx_core_conf_t* ccf = (ngx_core_conf_t*)(ngx_get_conf(cf->cycle->conf_ctx, ngx_core_module)); CHECK(ccf != NULL); - - if (chown(gs_path.c_str(), ccf->user, ccf->group) != 0) { + struct stat gs_stat; + if (stat(gs_path.c_str(), &gs_stat) != 0) { return string_piece_to_pool_string( cf->pool, net_instaweb::StrCat( - directive, " ", path, " unable to set permissions")); + directive, " ", path, " stat() failed")); } + if (gs_stat.st_uid != ccf->user) { + if (chown(gs_path.c_str(), ccf->user, ccf->group) != 0) { + return string_piece_to_pool_string( + cf->pool, net_instaweb::StrCat( + directive, " ", path, " unable to set permissions")); + } + } + return NULL; } @@ -2128,6 +2137,7 @@ ngx_int_t ps_in_place_check_header_filter(ngx_http_request_t* r) { // (or at least a note that it cannot be cached stored there). // We do that using an Apache output filter. ctx->recorder = new InPlaceResourceRecorder( + RequestContextPtr(cfg_s->server_context->NewRequestContext(r)), url, request_headers, options->respect_vary(), @@ -2192,7 +2202,9 @@ ngx_int_t ps_in_place_body_filter(ngx_http_request_t* r, ngx_chain_t* in) { // Unlike in Apache we get the final response headers before we get the // content. This means we can consider them earlier and abort the // request if need be without buffering everything. - recorder->ConsiderResponseHeaders(ctx->ipro_response_headers); + recorder->ConsiderResponseHeaders( + InPlaceResourceRecorder::kPreliminaryHeaders, + ctx->ipro_response_headers); } for (ngx_chain_t* cl = in; cl; cl = cl->next) {