Compare commits

...

2 Commits

Author SHA1 Message Date
Jeff Kaufman 72ddb34a1c readme: release 1.7.30.2 2014-01-06 16:54:56 -05:00
Jeff Kaufman ae2d4bac7f native-fetcher: fix to work with nginx 1.5.8+
nginx 1.5.8 changed the resolver api, which the native fetcher uses.

Fixes #578.

Squash-merge of @dinic's #581.
2014-01-06 16:46:48 -05:00
3 changed files with 32 additions and 13 deletions
+10 -10
View File
@@ -37,21 +37,21 @@ recompiling Tengine](https://github.com/pagespeed/ngx_pagespeed/wiki/Using-ngx_p
```bash
$ cd ~
$ wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.7.30.1-beta.zip
$ unzip release-1.7.30.1-beta.zip # or unzip release-1.7.30.1-beta
$ cd ngx_pagespeed-release-1.7.30.1-beta/
$ wget https://dl.google.com/dl/page-speed/psol/1.7.30.1.tar.gz
$ tar -xzvf 1.7.30.1.tar.gz # expands to psol/
$ wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.7.30.2-beta.zip
$ unzip v1.7.30.2-beta.zip # or unzip v1.7.30.2-beta
$ cd ngx_pagespeed-1.7.30.2-beta/
$ wget https://dl.google.com/dl/page-speed/psol/1.7.30.2.tar.gz
$ tar -xzvf 1.7.30.2.tar.gz # expands to psol/
```
3. Download and build nginx:
```bash
$ # check http://nginx.org/en/download.html for the latest version
$ wget http://nginx.org/download/nginx-1.4.3.tar.gz
$ tar -xvzf nginx-1.4.3.tar.gz
$ cd nginx-1.4.3/
$ ./configure --add-module=$HOME/ngx_pagespeed-release-1.7.30.1-beta
$ 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.2-beta
$ make
$ sudo make install
```
@@ -94,7 +94,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.1-...
X-Page-Speed: 1.7.30.2-...
```
Looking at the source of a few pages you should see various changes, such as
+2 -2
View File
@@ -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.1.tar.gz"
echo " $ tar -xzvf 1.7.30.1.tar.gz # expands to psol/"
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 ""
echo " Or see the installation instructions:"
echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build"
+20 -1
View File
@@ -24,6 +24,10 @@
// - The read handler parses the response. Add the response to the buffer at
// last.
extern "C" {
#include <nginx.h>
}
#include "ngx_fetch.h"
#include "net/instaweb/util/public/basictypes.h"
#include "base/logging.h"
@@ -164,7 +168,11 @@ namespace net_instaweb {
resolver_ctx_->data = this;
resolver_ctx_->name.data = url_.host.data;
resolver_ctx_->name.len = url_.host.len;
#if (nginx_version < 1005008)
resolver_ctx_->type = NGX_RESOLVE_A;
#endif
resolver_ctx_->handler = NgxFetchResolveDone;
resolver_ctx_->timeout = fetcher_->resolver_timeout_;
@@ -299,9 +307,20 @@ namespace net_instaweb {
return;
}
ngx_memzero(&fetch->sin_, sizeof(fetch->sin_));
#if (nginx_version < 1005008)
fetch->sin_.sin_addr.s_addr = resolver_ctx->addrs[0];
#else
struct sockaddr_in *sin;
sin = reinterpret_cast<struct sockaddr_in *>(
resolver_ctx->addrs[0].sockaddr);
fetch->sin_.sin_family = sin->sin_family;
fetch->sin_.sin_addr.s_addr = sin->sin_addr.s_addr;
#endif
fetch->sin_.sin_family = AF_INET;
fetch->sin_.sin_port = htons(fetch->url_.port);
fetch->sin_.sin_addr.s_addr = resolver_ctx->addrs[0];
char* ip_address = inet_ntoa(fetch->sin_.sin_addr);