Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6db4d02a91 | |||
| 1354cee4ed | |||
| 72ddb34a1c | |||
| ae2d4bac7f |
@@ -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.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/
|
||||
```
|
||||
|
||||
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.3-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.3-...
|
||||
```
|
||||
|
||||
Looking at the source of a few pages you should see various changes, such as
|
||||
|
||||
@@ -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.3.tar.gz"
|
||||
echo " $ tar -xzvf 1.7.30.3.tar.gz # expands to psol/"
|
||||
echo ""
|
||||
echo " Or see the installation instructions:"
|
||||
echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build"
|
||||
|
||||
+20
-1
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user