Compare commits

..

48 Commits

Author SHA1 Message Date
Jeff Kaufman f75e891b74 We need -lstdc++ to come after psol.a (#1273) 2016-09-15 15:18:49 -04:00
Steve Hill 4e2eb3de85 Update protobuf path for non chromium version 2016-09-15 11:27:36 -04:00
Maks Orlovich c56611b6f4 Also look for headers in /url in mod_pagespeed tree (#1264)
This is needed because the current GURL implementation there --- and hence
google_url.h needs an extra compat header that's there.
2016-09-15 10:30:20 -04:00
Jeff Kaufman 7e25a0dc13 1.11.33.3 -> 1.11.33.4 2016-09-15 10:21:14 -04:00
Jeffrey Crowell acbd179cb1 remove C++11isms from 1.11.33.3, for use with dynamic modules 2016-08-17 13:07:26 -04:00
Jeffrey Crowell 46bc8ac065 release: 1.11.33.2 -> 1.11.33.3 2016-08-15 14:33:15 -04:00
Jeff Kaufman 2af2035bbd rewrite-options: don't turn on CoreFilters just because of query params (#1228)
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1190
2016-08-04 13:49:03 -04:00
Jeffrey Crowell 61f36e0b98 nginx side of https://github.com/pagespeed/mod_pagespeed/issues/1371 (#1235)
nginx side of the change
https://github.com/pagespeed/mod_pagespeed/issues/1371
2016-08-03 14:10:13 -04:00
Joshua Marantz 9711b52270 set up a test subdir with cc:public (#1215) 2016-07-26 10:56:48 -04:00
Joshua Marantz 07a6647b65 respect purge requests when serving ipro requests from ngx_pagespeed (#1193)
* respect purge requests when serving ipro requests from ngx_pagespeed

* Add TODO to share common base with ApacheFetch.

During system-tests, don't write into the source-controlled htdocs area. (#1197)

Instead, use a new (not-yet-committed) target in Makefile.tests to build
a mirror htdocs in test/tmp/root that sym-links the large readonly
section and deep copies the test areas for purge and flush tests.

Pass the install-path into Makefile (#1200)

* Pass the install-path into Makefile, rather than having the Makefile
depend on PWD.

* Move the double-quotes be before the value, to be consistent with other
Makefiles.
2016-07-25 12:58:04 -04:00
Jeff Kaufman 787239d429 url-valued-attributes: tests for mod_pagespeed/f2f0075 2016-07-21 16:48:18 -04:00
Maks Orlovich e0a3bf223a Make sure RewriteDriverFactory::default_options gets the top-level proces-scope options. (#1203)
Needed for ImageMaxRewritesAtOnce to work with latest revisions.

Fix for when there is only server-level configuration (#1218)

When there is no top-level configuration but only server configuration,
we don't have main options to set and consider. This prevents
a NULL dereference in that case. (Later on we'll writes out a message
about why we cannot startup with this configuration).
2016-07-21 14:25:51 -04:00
hillsp 21f9b5c9e3 Fix IPRO and missing Content-Length headers in 32-bit builds. (#1196) 2016-07-21 13:37:38 -04:00
Otto van der Schaaf ff8969770d Fix segfault when there's no http{} block in nginx.conf (#1221)
Should fix https://github.com/pagespeed/ngx_pagespeed/issues/1220
2016-07-21 13:34:29 -04:00
Steve Hill b26e174d8b release: version 1.11.3.1 -> 1.11.3.2 2016-05-06 13:01:11 -04:00
Jeffrey Crowell 026f86dfc2 1.11.33.0-beta -> 1.11.33.1-beta 2016-04-29 16:26:29 -04:00
Maks Orlovich 0db78f6e8c Fix build with recent nginx which lacks NGX_CONF_MULTI (#1185) 2016-04-28 11:03:08 -04:00
Maks Orlovich 4af79a1e2b Adjust our UA string to fix to make it compatible with fonts.google.com parsing on IE11.
Counterpart of:
https://github.com/pagespeed/mod_pagespeed/commit/f3639e84c0196a5f5151ff5e54ad57285db09b37
2016-04-26 13:18:49 -04:00
Jeffrey Crowell ed20dabf66 fix up the description in the run_tests.sh (#1176)
run_tests had the wrong invocation of the script in the comments. fix
that.
2016-04-11 16:50:44 -04:00
Jeff Kaufman 067764aa92 1.10.33.7 -> 1.11.33.0 2016-03-30 15:27:36 -04:00
Jeff Kaufman 84ab39e8e3 Disable the multiple vary headers test for 1.11 2016-03-30 15:27:36 -04:00
Huibao Lin 2cfbec12c5 For backward compatibility, only allow varying on Accept header for ipro-for-browser.example.com 2016-03-30 14:59:07 -04:00
Huibao Lin 9fd8c6f1bb Add system tests for image format, quality, and response in IPRO 2016-03-30 14:59:07 -04:00
Otto van der Schaaf 1051a90c4e NgxFetch: Log url and error when url parsing fails.
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1148
2016-03-30 14:59:07 -04:00
Kees Spoelstra 21a4a83b77 Strip subresource hints pagespeed automatic system test configuration
Corresponding changes for:
- pull https://github.com/pagespeed/mod_pagespeed/pull/1204
- issue Strip subresource hints #973 https://github.com/pagespeed/mod_pagespeed/issues/973
2016-03-30 14:59:07 -04:00
Otto van der Schaaf 2b4c097d48 vary-header: Emit a single vary header in the IPRO flow
The report from some time ago mentioned three Vary: headers,
but I can now only reproduce two using trunk-tracking plus the
original repro-configuration.

This fix unflags r->gzip_vary as set by the gzip module when PSOL
hands us Vary: Accept-Encoding, to make sure that nginx's core
header filter doesn't append another one.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1064
2016-03-30 14:59:07 -04:00
Jeff Kaufman 181875e80b 1.10.33.6 -> 1.10.33.7 2016-03-28 09:04:30 -04:00
Jeff Kaufman 371293af48 handle additional warnings 2016-03-28 09:04:29 -04:00
Jeff Kaufman ba78a8542b 1.10.33.5 -> 1.10.33.6 2016-03-03 15:02:43 -05:00
Otto van der Schaaf 306cdf358a IPRO: Copy the cache control value to ensure a correct lifetime
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1138
2016-03-03 15:02:05 -05:00
Otto van der Schaaf 8ff08ed7e9 Fix valgrind complaint caused by NgxBaseFetch
We should not use r->connection after we finalize the request.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1100
2016-03-03 14:57:55 -05:00
Otto van der Schaaf fab4aac24e Eliminate CHECK that fails (rarely) during the IPRO lookup.
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1096
2016-03-03 14:57:49 -05:00
Otto van der Schaaf 88e3d48d23 Fix crasher on 404 .pagespeed. resources w/a custom location
- Fix nginx-side flow so we handle .pagespeed. resources ok
  when they will land on a customized 404 internal location.
- Additionally, check for a wiped request context and make sure
  we do not dereference a null pointer, which is what hurt in
  the flow we entered above as the IPRO lookup still was
  generating events while the nginx side request context was
  gone.
- Also, as a preliminary measure, do not check fail when we
  receive a stale event originating from a NgxBaseFetch that
  is no longer associated with our request context.
  Do log a warning so we'll hear about this happening either
  through system test failures or a bug report.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1081
2016-03-03 14:57:40 -05:00
Otto van der Schaaf 4ec7afe5a8 Fix shutdown when ngx_pagespeed is completely disabled.
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1120
2016-02-17 10:19:21 -05:00
Jeffrey Crowell 751f532162 1.10.33.5 is released 2016-02-16 16:48:48 -05:00
Otto van der Schaaf fbde0ace7e Support building ngx_pagespeed as a dynamic module.
As of 1.9.11, nginx supports loading dynamic modules
This change makes us support building ngx_pagespeed.so

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1116
2016-02-16 10:57:37 -05:00
Jeff Kaufman 13e99f631b Merge pull request #1112 from pra85/patch-1
Fix a typo
2016-02-11 13:17:03 -05:00
Jeff Kaufman 1c6c9f1a32 Merge pull request #1114 from PiotrSikora/nginx-1.9.11
Fix build with nginx-1.9.11+.
2016-02-10 15:03:00 -05:00
Piotr Sikora daa6031294 Fix build with nginx-1.9.11+.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-02-10 11:43:44 -08:00
Prayag Verma 5446303610 Fix a typo
`neet` → `need`
2016-02-09 11:30:05 +05:30
Jeffrey Crowell 6c3cc29def 1.10.33.4 is out 2016-02-05 13:11:31 -05:00
Jeffrey Crowell 17e8c7535a Merge pull request #1088 from pagespeed/crowell-reapply744
reapply:  location-header: tweak location header handling
2015-12-31 10:45:40 -05:00
Jeffrey Crowell 01e458ca0d reapply: location-header: tweak location header handling
- Fix potentially sending the location header into PSOL twice.
- Be more thorough when unsetting the location header

Attempts to fix #725

from oschaaf
2015-12-31 10:38:38 -05:00
Jeff Kaufman cd8c45fc86 1.10.33.1 -> 1.10.33.2 2015-12-18 15:04:42 -05:00
Jeff Kaufman 9d6bfad665 Restore dropped fix for #957
@rfnx fixed #957 in acb89a, but this was accidentally merged to master
instead of trunk-tracking.  I checked for this sort of problem as part
of the 1.10 release, but missed this commit.  Restored.

Fixes #1054
2015-12-18 15:04:42 -05:00
Otto van der Schaaf c253c3ba80 log: initialize logging earlier
It turns out to be possible to initialize logging earlier by
grabbing the log from a global ngx_cycle structure.

This makes us start logging earlier, yet loses the
"No threading detected ..." messages both from stderr and
in error.log when nginx initially starts.

With this change, these messages will now be logged as we start
logging earlier:

"
flush
.
"

These originate from SystemCachePath::CacheKey which appends
newlines to the key, and the resulting cache key ends up being
logged. We might want to change that, because the resulting
lines in error.log look weird and might raise questions.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/895
2015-12-17 17:18:18 -05:00
Jeff Kaufman 8c7c8a843a 1.10.33.0 -> 1.10.33.1 2015-12-16 08:13:40 -05:00
Jeff Kaufman bcb1eb1dec release: version 1.9 -> 1.10 2015-12-14 08:27:41 -05:00
88 changed files with 756 additions and 5196 deletions
-1
View File
@@ -2,4 +2,3 @@ test/tmp
psol/ psol/
psol-*.tar.gz psol-*.tar.gz
*.*.*.*.tar.gz *.*.*.*.tar.gz
nginx
-18
View File
@@ -1,18 +0,0 @@
[submodule "testing-dependencies/mod_pagespeed"]
path = testing-dependencies/mod_pagespeed
url = https://github.com/apache/incubator-pagespeed-mod.git
[submodule "testing-dependencies/ngx_cache_purge"]
path = testing-dependencies/ngx_cache_purge
url = https://github.com/FRiCKLE/ngx_cache_purge.git
[submodule "testing-dependencies/nginx"]
path = testing-dependencies/nginx
url = https://github.com/nginx/nginx.git
[submodule "testing-dependencies/set-misc-nginx-module"]
path = testing-dependencies/set-misc-nginx-module
url = https://github.com/openresty/set-misc-nginx-module
[submodule "testing-dependencies/ngx_devel_kit"]
path = testing-dependencies/ngx_devel_kit
url = https://github.com/simpl/ngx_devel_kit
[submodule "testing-dependencies/headers-more-nginx-module"]
path = testing-dependencies/headers-more-nginx-module
url = https://github.com/openresty/headers-more-nginx-module
-33
View File
@@ -1,33 +0,0 @@
language: c++
env:
global:
- MAKEFLAGS=-j3
# By default travis loads submodules serially, but we can load them in parallel
# if we install an updated git and use --jobs. Some timing numbers:
# serial: 257s
# jobs=4: 182s (29s to install new git, 153s to run the downloads)
# jobs=8: 179s (29s to install new git, 150s to run the downloads)
# We can't use --depth=1, though, because github doesn't have
# allowReachableSHA1InWant set.
#
# TODO(jefftk): once we're running on a server with git 2.8 or later we can have
# --jobs without installing a new git.
git:
submodules: false
before_install:
- sudo add-apt-repository --yes ppa:git-core/ppa
- sudo apt-get update
- sudo apt-get install git
- git submodule update --init --recursive --jobs=8
install:
scripts/build_ngx_pagespeed.sh --devel --assume-yes
script:
test/run_tests.sh $PWD/testing-dependencies/mod_pagespeed/ \
$PWD/nginx/sbin/nginx
dist: trusty
sudo: required
compiler:
- gcc
notifications:
email:
- pagespeed-ci@googlegroups.com
-17
View File
@@ -1,17 +0,0 @@
Apache ngx_pagespeed
Copyright 2018 The Apache Software Foundation
This product includes software developed at
- The Apache Software Foundation (http://www.apache.org/).
- Google Inc.
Codebase originally donated by Google Inc:
Copyright (C) 2010-2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
-4
View File
@@ -1,4 +0,0 @@
In a release this file would contain the URL to download the pre-compiled PSOL
binary, but on development branches (like this one) you have to build PSOL from
source yourself. See:
https://github.com/apache/incubator-pagespeed-ngx/wiki/Building-PSOL-From-Source
+1 -3
View File
@@ -1,6 +1,4 @@
![ngx_pagespeed](https://user-images.githubusercontent.com/6751650/73116078-338a9180-3f0f-11ea-8fdf-8c99cb4bec7f.png) ![ngx_pagespeed](https://lh6.googleusercontent.com/-qufedJIJq7Y/UXEvVYxyYvI/AAAAAAAADo8/JHDFQhs91_c/s401/04_ngx_pagespeed.png)
[![Build Status](https://travis-ci.org/apache/incubator-pagespeed-ngx.svg?branch=master)](https://travis-ci.org/apache/incubator-pagespeed-ngx)
ngx_pagespeed speeds up your site and reduces page load time by automatically ngx_pagespeed speeds up your site and reduces page load time by automatically
applying web performance best practices to pages and associated assets (CSS, applying web performance best practices to pages and associated assets (CSS,
-1
View File
@@ -1 +0,0 @@
This podling has been retired, please see: http://incubator.apache.org/projects/index.html#pagespeed
+21 -57
View File
@@ -15,11 +15,9 @@
# Environment Variables (Optional): # Environment Variables (Optional):
# MOD_PAGESPEED_DIR: absolute path to the mod_pagespeed/src directory # MOD_PAGESPEED_DIR: absolute path to the mod_pagespeed/src directory
# PSOL_BINARY: absolute path to pagespeed_automatic.a # PSOL_BINARY: absolute path to pagespeed_automatic.a
# PSOL_BUILDTYPE: Release or Debug
mod_pagespeed_dir="${MOD_PAGESPEED_DIR:-unset}" mod_pagespeed_dir="${MOD_PAGESPEED_DIR:-unset}"
position_aux="${POSITION_AUX:-unset}" position_aux="${POSITION_AUX:-unset}"
psol_buildtype="${PSOL_BUILDTYPE:-unset}"
if [ "$mod_pagespeed_dir" = "unset" ] ; then if [ "$mod_pagespeed_dir" = "unset" ] ; then
mod_pagespeed_dir="$ngx_addon_dir/psol/include" mod_pagespeed_dir="$ngx_addon_dir/psol/include"
@@ -27,28 +25,18 @@ if [ "$mod_pagespeed_dir" = "unset" ] ; then
if [ ! -e "$mod_pagespeed_dir" ] ; then if [ ! -e "$mod_pagespeed_dir" ] ; then
echo "ngx_pagespeed: pagespeed optimization library not found:" echo "ngx_pagespeed: pagespeed optimization library not found:"
echo ""
psol_binary_url="$($ngx_addon_dir/scripts/format_binary_url.sh \ echo " You need to separately download the pagespeed library:"
$ngx_addon_dir/PSOL_BINARY_URL)" echo ""
if [[ "$psol_binary_url" != https://* ]]; then echo " $ cd /path/to/ngx_pagespeed"
echo " echo " $ wget https://dl.google.com/dl/page-speed/psol/1.11.33.4.tar.gz"
This is a development branch of ngx_pagespeed, which means there is no echo " $ tar -xzvf 1.11.33.4.tar.gz # expands to psol/"
precompiled PSOL library available to link against. Either build from a echo ""
release tag, like latest-beta, or build PSOL from source: echo " Or see the installation instructions:"
https://github.com/apache/incubator-pagespeed-ngx/wiki/Building-PSOL-From-Source" echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build"
exit 1
fi
echo "
You need to separately download the pagespeed library:
$ cd $ngx_addon_dir
$ wget $psol_binary_url
$ tar -xzvf $(basename $psol_binary_url) # expands to psol/
Or see the installation instructions:
https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source"
exit 1 exit 1
fi fi
else else
build_from_source=true build_from_source=true
fi fi
@@ -77,16 +65,10 @@ else
exit 1 exit 1
fi fi
if [ "$psol_buildtype" = "unset" ] ; then if [ "$NGX_DEBUG" = "YES" ]; then
if [ "$NGX_DEBUG" = "YES" ]; then buildtype=Debug
buildtype=Debug
# If we're using a psol tarball that doesn't contain Debug/ (which is the case
# from 1.12 onward) then this will be overriden to buildtype=Release below.
else
buildtype=Release
fi
else else
buildtype=$psol_buildtype buildtype=Release
fi fi
# If the compiler is gcc, we want to use g++ to link, if at all possible, # If the compiler is gcc, we want to use g++ to link, if at all possible,
@@ -114,8 +96,7 @@ CFLAGS="$CFLAGS $FLAG_MARCH"
# to our libpsol.a # to our libpsol.a
# See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html # See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
CFLAGS="$CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0" CFLAGS="$CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
CC_OLD_TEST_FLAGS="$CC_TEST_FLAGS" CC_TEST_FLAGS="$CC_TEST_FLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
CC_TEST_FLAGS="$CC_TEST_FLAGS -D_GLIBCXX_USE_CXX11_ABI=0 --std=c++11"
case "$NGX_GCC_VER" in case "$NGX_GCC_VER" in
4.8*) 4.8*)
@@ -152,22 +133,6 @@ if [ "$psol_binary" = "unset" ] ; then
psol_binary="\ psol_binary="\
$mod_pagespeed_dir/pagespeed/automatic/pagespeed_automatic.a" $mod_pagespeed_dir/pagespeed/automatic/pagespeed_automatic.a"
else else
if ! [ -d "$ngx_addon_dir/psol/lib/$buildtype" ]; then
echo "
You have set --with-debug for building nginx, but precompiled Debug binaries for
PSOL, which ngx_pagespeed depends on, aren't available. If you're trying to
debug PSOL you need to build it from source. If you just want to run nginx with
debug-level logging you can use the Release binaries."
echo -n "
Use the available Release binaries?"
read -p " [Y/n] " yn
if [[ "$yn" == N* || "$yn" == n* ]]; then
echo "Cancelled."
exit 1
fi
buildtype=Release
fi
psol_library_dir="$ngx_addon_dir/psol/lib/$buildtype/$os_name/$arch_name" psol_library_dir="$ngx_addon_dir/psol/lib/$buildtype/$os_name/$arch_name"
psol_binary="$psol_library_dir/pagespeed_automatic.a" psol_binary="$psol_library_dir/pagespeed_automatic.a"
fi fi
@@ -190,9 +155,8 @@ ngx_feature_incs="
pagespeed_include="\ pagespeed_include="\
$mod_pagespeed_dir \ $mod_pagespeed_dir \
$mod_pagespeed_dir/third_party/chromium/src \ $mod_pagespeed_dir/third_party/chromium/src \
$mod_pagespeed_dir/third_party/google-sparsehash/src/src \ $mod_pagespeed_dir/third_party/google-sparsehash/src \
$mod_pagespeed_dir/third_party/google-sparsehash/gen/arch/$os_name/$arch_name/include \ $mod_pagespeed_dir/third_party/google-sparsehash/gen/arch/$os_name/$arch_name/include \
$mod_pagespeed_dir/third_party/grpc/src/include \
$mod_pagespeed_dir/third_party/protobuf/src/src \ $mod_pagespeed_dir/third_party/protobuf/src/src \
$mod_pagespeed_dir/third_party/re2/src \ $mod_pagespeed_dir/third_party/re2/src \
$mod_pagespeed_dir/out/$buildtype/obj/gen \ $mod_pagespeed_dir/out/$buildtype/obj/gen \
@@ -204,7 +168,7 @@ pagespeed_include="\
$mod_pagespeed_dir/url" $mod_pagespeed_dir/url"
ngx_feature_path="$pagespeed_include" ngx_feature_path="$pagespeed_include"
pagespeed_libs="$psol_binary $pagespeed_libs -lrt -pthread -lm -luuid" pagespeed_libs="$psol_binary $pagespeed_libs -lrt -pthread -lm"
ngx_feature_libs="$pagespeed_libs" ngx_feature_libs="$pagespeed_libs"
ngx_feature_test=" ngx_feature_test="
@@ -231,7 +195,7 @@ ngx_feature_test="
if [ $ngx_found = no ]; then if [ $ngx_found = no ]; then
cat << END cat << END
$0: error: module ngx_pagespeed requires the pagespeed optimization library. $0: error: module ngx_pagespeed requires the pagespeed optimization library.
Look in $PWD/$NGX_AUTOCONF_ERR for more details. Look in obj/autoconf.err for more details.
END END
exit 1 exit 1
fi fi
@@ -321,6 +285,8 @@ if [ -n "$ngx_module_link" ]; then
| sed "s/ngx_pagespeed_etag_filter//" \ | sed "s/ngx_pagespeed_etag_filter//" \
| sed "s/ngx_http_range_header_filter_module/ngx_http_range_header_filter_module ngx_pagespeed_etag_filter/") | sed "s/ngx_http_range_header_filter_module/ngx_http_range_header_filter_module ngx_pagespeed_etag_filter/")
else else
# config.make is not executed for dynamic modules
CFLAGS="$CFLAGS -Wno-c++11-extensions"
if [ "$position_aux" = "true" ] ; then if [ "$position_aux" = "true" ] ; then
ngx_module_type=HTTP_AUX_FILTER ngx_module_type=HTTP_AUX_FILTER
ngx_module_order="" ngx_module_order=""
@@ -353,7 +319,7 @@ ngx_feature_libs="-lstdc++"
ngx_feature_test=" ngx_feature_test="
#if defined(__clang__) && defined(__GLIBCXX__) #if defined(__clang__) && defined(__GLIBCXX__)
// See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning // See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning
// for a list of various values of __GLIBCXX__. Note that they're not monotonic // for a list of various values of __GLIBCXX__. Note that they're not monotonic
// with respect to version numbers. // with respect to version numbers.
#if __GLIBCXX__ == 20120322 || __GLIBCXX__ == 20120614 #if __GLIBCXX__ == 20120322 || __GLIBCXX__ == 20120614
@@ -380,11 +346,9 @@ if [ $ngx_found = no ]; then
cat << END cat << END
$0: error: module ngx_pagespeed requires gcc >= 4.8 or clang >= 3.3. $0: error: module ngx_pagespeed requires gcc >= 4.8 or clang >= 3.3.
See https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source for some recommendations. See https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source for some recommendations.
Look in $PWD/$NGX_AUTOCONF_ERR for more details. Look in objs/autoconf.err for more details.
END END
exit 1 exit 1
fi fi
have=NGX_PAGESPEED . auto/have have=NGX_PAGESPEED . auto/have
CC_TEST_FLAGS="$CC_OLD_TEST_FLAGS"
+7 -25
View File
@@ -1,25 +1,7 @@
# Licensed to the Apache Software Foundation (ASF) under one if [ -n "$NGX_CLANG_VER" ]; then
# or more contributor license agreements. See the NOTICE file # Chromium headers assume clang is always in C++11 mode. Oblige it.
# distributed with this work for additional information for ps_src_file in $PS_NGX_SRCS; do
# regarding copyright ownership. The ASF licenses this file ps_obj_file="$NGX_OBJS/addon/src/`basename $ps_src_file .cc`.o"
# to you under the Apache License, Version 2.0 (the echo "$ps_obj_file : CFLAGS += --std=c++11" >> $NGX_MAKEFILE
# "License"); you may not use this file except in compliance done
# with the License. You may obtain a copy of the License at fi
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Since nginx build system doesn't normally do C++, there is no CXXFLAGS for us
# to touch, and compilers are understandably unhappy with --std=c++11 on C
# files. Hence, we hack the makefile to add it for just our sources.
for ps_src_file in $PS_NGX_SRCS; do
ps_obj_file="$NGX_OBJS/addon/src/`basename $ps_src_file .cc`.o"
echo "$ps_obj_file : CFLAGS += --std=c++11" >> $NGX_MAKEFILE
done
-187
View File
@@ -1,187 +0,0 @@
# Supported tags and respective `Dockerfile` links
- [`1.13.35.2`, `stable`, `1.13.35`, `1.13`, `1.13.35.2-alpine3.8`, `1.13.35-alpine3.8`, `1.13-alpine3.8`, `stable-alpine3.8`, `1.13.35.2-alpine3.8-ngx1.14`, `1.13.35-alpine3.8-ngx1.14`, `1.13-alpine3.8-ngx1.14`, `stable-alpine3.8-ngx1.14`, `latest` (*alpine-3.8/nginx-stable/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob/master/docker/alpine-3.8/nginx-stable/Dockerfile)
- [`1.13.35.2-edge`, `stable-edge`, `edge`, `1.13.35-edge`, `1.13-edge`, `1.13.35.2-edge-ngx1.14`, `1.13.35-edge-ngx1.14`, `1.13-edge-ngx1.14`, `stable-edge-ngx1.14` (*alpine-edge/nginx-stable/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob/master/docker/alpine-edge/nginx-stable/Dockerfile)
- [`1.13.35.2-alpine3.8-ngx1.15`, `ngx1.15`, `1.13.35-alpine3.8-ngx1.15`, `1.13-alpine3.8-ngx1.15`, `stable-alpine3.8-ngx1.15` (*alpine-3.8/nginx-mainline/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob//master/docker/alpine-3.8/nginx-mainline/Dockerfile)
- [`1.13.35.2-edge-ngx1.15`, `1.13.35-edge-ngx1.15`, `1.13-edge-ngx1.15`, `stable-edge-ngx1.15` (*alpine-edge/nginx-mainline/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob/master/docker/alpine-edge/nginx-mainline/Dockerfile)
# Quick reference
- **Where to get help**:
[Read the wiki](https://github.com/apache/incubator-pagespeed-mod/wiki), [Ask a question on the mailing list](https://groups.google.com/group/ngx-pagespeed-discuss)
- **Docker image repository**:
[Dockerhub](https://hub.docker.com/r/pagespeed/nginx-pagespeed)
- **Git Dockerfile repository**:
[Github](https://github.com/apache/incubator-pagespeed-ngx/tree/master/docker)
- **Where to file issues**:
[https://github.com/We-Amp/ngx-pagespeed-alpine/issues](https://github.com/apache/incubator-pagespeed-ngx/issues)
- **Docker images maintained by**:
[Nico Berlee](mailto:nico.berlee@on2it.net)
- **Supported Docker versions**:
[the latest release](https://github.com/docker/docker-ce/releases/latest) (down to 1.12 on a best-effort basis)
# What is pagespeed?
The PageSpeed Modules, [mod_pagespeed](https://github.com/apache/incubator-pagespeed-mod) and [ngx_pagespeed](https://github.com/apache/incubator-pagespeed-ngx), are open-source webserver modules that [optimize your site automatically](https://www.modpagespeed.com/doc/filters).
ngx_pagespeed speeds up your site and reduces page load time by automatically
applying web performance best practices to pages and associated assets (CSS,
JavaScript, images) without requiring you to modify your existing content or
workflow. Features include:
- Image optimization: stripping meta-data, dynamic resizing, recompression
- CSS & JavaScript minification, concatenation, inlining, and outlining
- Small resource inlining
- Deferring image and JavaScript loading
- HTML rewriting
- Cache lifetime extension
- and [more](https://developers.google.com/speed/docs/mod_pagespeed/config_filters)
To see ngx_pagespeed in action, with example pages for each of the
optimizations, see our [demonstration site](http://ngxpagespeed.com).
![logo](https://camo.githubusercontent.com/4138679c6cf85adb18c4cf820189c898f7dbf5cb/68747470733a2f2f6c68362e676f6f676c6575736572636f6e74656e742e636f6d2f2d71756665644a494a7137592f55584576565978795976492f4141414141414141446f382f4a48444651687339315f632f733430312f30345f6e67785f7061676573706565642e706e67)
# What is nginx?
Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server). The nginx project started with a strong focus on high concurrency, high performance and low memory usage.
> [wikipedia.org/wiki/Nginx](https://en.wikipedia.org/wiki/Nginx)
# What is nginx-pagespeed?
The nginx-pagespeed brings all the goods of nginx and pagespeed together in one single small alpine docker image. Nginx-pagespeed aims to be 100% compatible with the plain [nginx](https://hub.docker.com/_/nginx/) images. Meaning, nginx-pagespeed can be a safe drop-in replacement for any container running `nginx:alpine`.
Nginx-pagespeed makes it easy to start optimizing your website by reducing page load time, without requiring you to modify existing content.
# How to use this image
## Hosting some simple static content
```console
$ docker run --name pagespeed-nginx -v /some/content:/usr/share/nginx/html:ro -d pagespeed/nginx-pagespeed
```
Alternatively, a simple `Dockerfile` can be used to generate a new image that includes the necessary content (which is a much cleaner solution than the bind mount above):
```dockerfile
FROM pagespeed/nginx-pagespeed
COPY static-html-directory /usr/share/nginx/html
```
Place this file in the same directory as your directory of content ("static-html-directory"), run `docker build -t some-content-ngxpagespeed .`, then start your container:
```console
$ docker run --name my-nginx-pagespeed -d some-content-ngxpagespeed
```
## Exposing external port
```console
$ docker run --name my-nginx-pagespeed -d -p 8080:80 some-content-ngxpagespeed
```
Then you can hit `http://localhost:8080` or `http://host-ip:8080` in your browser.
## Complex configuration
```console
$ docker run --name my-custom-nginx-pagespeed -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d pagespeed/nginx-pagespeed
```
For information on the syntax of the nginx configuration files, see [the official documentation](http://nginx.org/en/docs/) (specifically the [Beginner's Guide](http://nginx.org/en/docs/beginners_guide.html#conf_structure)). For pagespeed specific nginx config syntax, see [Beginner's guide](https://www.modpagespeed.com/doc/configuration) or a complete overview of [all pagespeed filters](https://www.ngxpagespeed.com/).
For a quick start on pagespeed specific configuration see []
If you wish to adapt the default configuration, use something like the following to copy it from a running nginx-pagespeed container:
```console
$ docker run --name tmp-ngxpagespeed-container -d pagespeed/nginx-pagespeed
$ docker cp tmp-ngxpagespeed-container:/etc/nginx/nginx.conf /host/path/nginx.conf
$ docker rm -f tmp-ngxpagespeed-container
```
This can also be accomplished more cleanly using a simple `Dockerfile` (in `/host/path/`):
```dockerfile
FROM pagespeed/nginx-pagespeed
COPY nginx.conf /etc/nginx/nginx.conf
```
If you add a custom `CMD` in the Dockerfile, be sure to include `-g daemon off;` in the `CMD` in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)!
Then build the image with `docker build -t custom-ngxpagespeed .` and run it as follows:
```console
$ docker run --name my-custom-ngxpagespeed-container -d custom-ngxpagespeed
```
### Using environment variables in nginx configuration
Out-of-the-box, nginx doesn't support environment variables inside most configuration blocks. But `envsubst` may be used as a workaround if you need to generate your nginx configuration dynamically before nginx starts.
Here is an example using docker-compose.yml:
```yaml
web:
image: pagespeed/nginx-pagespeed
volumes:
- ./mysite.template:/etc/nginx/conf.d/mysite.template
ports:
- "8080:80"
environment:
- NGINX_HOST=foobar.com
- NGINX_PORT=80
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
```
The `mysite.template` file may then contain variable references like this:
`listen ${NGINX_PORT};
`
# Image Variants
The `pagespeed/nginx-pagespeed` images come in many flavors, each designed for a specific use case.
## `pagespeed/nginx-pagespeed:<version>`
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.
## `nginx:edge`
This image has the most up-to-date system packages available in the [Alpine Linux project](http://alpinelinux.org). This means the latest LibreSSL and musl-libc, with the downside of having less tested system packages.
## Using the Dockerfile
### Use docker build command to build an image from dockerfile:
docker build -t <image_tag> <dockerfile_path> .
$ docker build -t ngxpagespeed-alpine38-ngxstable stable/3.8/nginx-stable
Refer [this](https://docs.docker.com/engine/reference/commandline/build/) for additional options.
### Run this container as an independent service:
$ docker run -d -p 80:80 <image_tag>
Refer [this](https://docs.docker.com/engine/reference/run/) for additional options.
## Requirements for building:
- > 3 GB of free diskspace
- 2GB of memory
- an x86_64 compatible processor
- Docker CE > 17.3.2
# Disclaimer
Apache PageSpeed is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
# License
View [PageSpeed license information](https://github.com/apache/incubator-pagespeed-ngx/blob/master/LICENSE)
View [Nginx license information](http://nginx.org/LICENSE)
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in [the `repo-info` repository's `nginx/` directory](https://github.com/docker-library/repo-info/tree/master/repos/nginx).
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
-230
View File
@@ -1,230 +0,0 @@
ARG ALPINE_VERSION=3.8
########################
# Build pagespeed psol #
########################
FROM alpine:$ALPINE_VERSION as pagespeed
# Check https://github.com/apache/incubator-pagespeed-mod/tags
ARG MOD_PAGESPEED_TAG=v1.13.35.2
RUN apk add --no-cache \
apache2-dev \
apr-dev \
apr-util-dev \
build-base \
curl \
gettext-dev \
git \
gperf \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libressl-dev \
pcre-dev \
py-setuptools \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${MOD_PAGESPEED_TAG} \
--recurse-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-mod.git \
modpagespeed \
;
WORKDIR /usr/src/modpagespeed
COPY patches/modpagespeed/*.patch ./
RUN for i in *.patch; do printf "\r\nApplying patch ${i%%.*}\r\n"; patch -p1 < $i || exit 1; done
WORKDIR /usr/src/modpagespeed/tools/gyp
RUN ./setup.py install
WORKDIR /usr/src/modpagespeed
RUN build/gyp_chromium --depth=. \
-D use_system_libs=1 \
&& \
cd /usr/src/modpagespeed/pagespeed/automatic && \
make psol BUILDTYPE=Release \
CFLAGS+="-I/usr/include/apr-1" \
CXXFLAGS+="-I/usr/include/apr-1 -DUCHAR_TYPE=uint16_t" \
-j`nproc` \
;
RUN mkdir -p /usr/src/ngxpagespeed/psol/lib/Release/linux/x64 && \
mkdir -p /usr/src/ngxpagespeed/psol/include/out/Release && \
cp -R out/Release/obj /usr/src/ngxpagespeed/psol/include/out/Release/ && \
cp -R pagespeed/automatic/pagespeed_automatic.a /usr/src/ngxpagespeed/psol/lib/Release/linux/x64/ && \
cp -R net \
pagespeed \
testing \
third_party \
url \
/usr/src/ngxpagespeed/psol/include/ \
;
##########################################
# Build Nginx with support for PageSpeed #
##########################################
FROM alpine:$ALPINE_VERSION AS nginx
# Check https://github.com/apache/incubator-pagespeed-ngx/tags
ARG NGX_PAGESPEED_TAG=v1.13.35.2-stable
# Check http://nginx.org/en/download.html for the latest version.
ARG NGINX_VERSION=1.15.6
ARG NGINX_PGPKEY=520A9993A1C052F8
ARG NGINX_BUILD_CONFIG="\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-compat \
--with-file-aio \
--with-http_v2_module \
"
RUN apk add --no-cache \
apr-dev \
apr-util-dev \
build-base \
ca-certificates \
gd-dev \
geoip-dev \
git \
gnupg \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libxslt-dev \
linux-headers \
libressl-dev \
pcre-dev \
tar \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${NGX_PAGESPEED_TAG} \
--recurse-submodules \
--shallow-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-ngx.git \
ngxpagespeed \
;
RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
(gpg --keyserver ha.pool.sks-keyservers.net --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --keyserver-options timeout=10 --recv-keys $NGINX_PGPKEY} ) && \
gpg --trusted-key ${NGINX_PGPKEY} --verify nginx-${NGINX_VERSION}.tar.gz.asc
COPY --from=pagespeed /usr/src/ngxpagespeed /usr/src/ngxpagespeed/
WORKDIR /usr/src/nginx
RUN tar zxf ../nginx-${NGINX_VERSION}.tar.gz --strip-components=1 -C . && \
./configure \
${NGINX_BUILD_CONFIG} \
--add-module=/usr/src/ngxpagespeed \
--with-ld-opt="-Wl,-z,relro,--start-group -lapr-1 -laprutil-1 -licudata -licuuc -lpng -lturbojpeg -ljpeg" \
&& \
make install -j`nproc`
RUN rm -rf /etc/nginx/html/ && \
mkdir /etc/nginx/conf.d/ && \
mkdir -p /usr/share/nginx/html/ && \
sed -i 's|^</body>|<p><a href="https://www.ngxpagespeed.com/"><img src="pagespeed.png" title="Nginx module for rewriting web pages to reduce latency and bandwidth" /></a></p>\n</body>|' html/index.html && \
install -m644 html/index.html /usr/share/nginx/html/ && \
install -m644 html/50x.html /usr/share/nginx/html/ && \
ln -s ../../usr/lib/nginx/modules /etc/nginx/modules && \
strip /usr/sbin/nginx* \
/usr/lib/nginx/modules/*.so \
;
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx.vh.default.conf /etc/nginx/conf.d/default.conf
COPY pagespeed.png /usr/share/nginx/html/
##########################################
# Combine everything with minimal layers #
##########################################
FROM alpine:$ALPINE_VERSION
LABEL maintainer="Nico Berlee <nico.berlee@on2it.net>" \
version.mod-pagespeed="1.13.35.2" \
version.nginx="1.15.6" \
version.ngx-pagespeed="1.13.35.2"
COPY --from=pagespeed /usr/bin/envsubst /usr/local/bin
COPY --from=nginx /usr/sbin/nginx /usr/sbin/nginx
COPY --from=nginx /usr/lib/nginx/modules/ /usr/lib/nginx/modules/
COPY --from=nginx /etc/nginx /etc/nginx
COPY --from=nginx /usr/share/nginx/html/ /usr/share/nginx/html/
RUN apk --no-cache upgrade && \
scanelf --needed --nobanner --format '%n#p' /usr/sbin/nginx /usr/lib/nginx/modules/*.so /usr/local/bin/envsubst \
| tr ',' '\n' \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
| xargs apk add --no-cache \
&& \
apk add --no-cache tzdata
RUN addgroup -S nginx && \
adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx && \
install -g nginx -o nginx -d /var/cache/ngx_pagespeed && \
mkdir -p /var/log/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
@@ -1,32 +0,0 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
@@ -1,57 +0,0 @@
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
pagespeed on;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

@@ -1,31 +0,0 @@
--- a/pagespeed/automatic/Makefile
+++ b/pagespeed/automatic/Makefile
@@ -146,8 +146,6 @@
pagespeed/libpagespeed_thread.a \
pagespeed/libpthread_system.a \
pagespeed/libutil.a \
- third_party/apr/libapr.a \
- third_party/aprutil/libaprutil.a \
third_party/base64/libbase64.a \
third_party/chromium/src/base/third_party/dynamic_annotations/libdynamic_annotations.a \
third_party/css_parser/libcss_parser.a \
@@ -163,18 +161,11 @@
third_party/grpc/libgrpc_core.a \
third_party/grpc/libgrpc_cpp.a \
third_party/hiredis/libhiredis.a \
- third_party/icu/libicudata.a \
- third_party/icu/libicuuc.a \
third_party/jsoncpp/libjsoncpp.a \
- third_party/libjpeg_turbo/libjpeg.a \
- third_party/libjpeg_turbo/src/libjpeg_turbo.a \
- third_party/libpng/libpng.a \
third_party/optipng/libopngreduc.a \
third_party/protobuf/libprotobuf_full_do_not_use.a \
third_party/re2/libre2.a \
- third_party/serf/libopenssl.a \
third_party/serf/libserf.a \
- third_party/zlib/libzlib.a \
url/liburl_lib.a
# The 'gclient' build flow uses 'xcodebuild' on Mac and 'make' on Linux.
@@ -1,141 +0,0 @@
From 7ea8d5fc141c7067c54ffa2b9fbc552c15089ca6 Mon Sep 17 00:00:00 2001
From: ashishk-1 <ashish.k@gdbtech.in>
Date: Thu, 18 Jan 2018 22:14:05 +0530
Subject: [PATCH] Upgrading libpng library to version 1.6 (#1724)
---
net/instaweb/rewriter/image.cc | 8 ++++++++
pagespeed/kernel/image/gif_reader.cc | 4 ++--
pagespeed/kernel/image/image_converter.cc | 6 ++++++
pagespeed/kernel/image/png_optimizer_test.cc | 6 ++++++
third_party/libpng/libpng.gyp | 26 +++++++++++++++++++++++---
third_party/libpng/src | 2 +-
6 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/net/instaweb/rewriter/image.cc b/net/instaweb/rewriter/image.cc
index 4f631182a..bb67bba35 100644
--- a/net/instaweb/rewriter/image.cc
+++ b/net/instaweb/rewriter/image.cc
@@ -21,6 +21,14 @@
#include <algorithm>
#include <cstddef>
+extern "C" {
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
+} // extern "C"
+
#include "base/logging.h"
#include "net/instaweb/rewriter/cached_result.pb.h"
#include "net/instaweb/rewriter/public/image_data_lookup.h"
diff --git a/pagespeed/kernel/image/gif_reader.cc b/pagespeed/kernel/image/gif_reader.cc
index 7de69b3d7..bb0bc9cfc 100644
--- a/pagespeed/kernel/image/gif_reader.cc
+++ b/pagespeed/kernel/image/gif_reader.cc
@@ -411,8 +411,8 @@ bool ReadGifToPng(GifFileType* gif_file,
png_uint_32 height = png_get_image_height(paletted_png_ptr,
paletted_info_ptr);
for (png_uint_32 row = 1; row < height; ++row) {
- memcpy(paletted_info_ptr->row_pointers[row],
- paletted_info_ptr->row_pointers[0],
+ memcpy(row_pointers[row],
+ row_pointers[0],
row_size);
}
diff --git a/pagespeed/kernel/image/image_converter.cc b/pagespeed/kernel/image/image_converter.cc
index d796b5065..84b7aff74 100644
--- a/pagespeed/kernel/image/image_converter.cc
+++ b/pagespeed/kernel/image/image_converter.cc
@@ -30,6 +30,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
} // extern "C"
#include "base/logging.h"
diff --git a/pagespeed/kernel/image/png_optimizer_test.cc b/pagespeed/kernel/image/png_optimizer_test.cc
index 9ad915aff..3faa526a8 100644
--- a/pagespeed/kernel/image/png_optimizer_test.cc
+++ b/pagespeed/kernel/image/png_optimizer_test.cc
@@ -36,6 +36,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
}
namespace {
diff --git a/third_party/libpng/libpng.gyp b/third_party/libpng/libpng.gyp
index cfaafee00..d96a8f74c 100644
--- a/third_party/libpng/libpng.gyp
+++ b/third_party/libpng/libpng.gyp
@@ -22,14 +22,29 @@
'dependencies': [
'../zlib/zlib.gyp:zlib',
],
+ 'actions': [
+ {
+ 'action_name': 'copy_libpngconf_prebuilt',
+ 'inputs' : [],
+ 'outputs': [''],
+ 'action': [
+ 'cp',
+ '-f',
+ '<(DEPTH)/third_party/libpng/src/scripts/pnglibconf.h.prebuilt',
+ '<(DEPTH)/third_party/libpng/src/pnglibconf.h',
+ ],
+ },
+ ],
'msvs_guid': 'C564F145-9172-42C3-BFCB-6014CA97DBCD',
'sources': [
+ 'src/pngpriv.h',
'src/png.c',
'src/png.h',
'src/pngconf.h',
+ 'src/pngdebug.h',
'src/pngerror.c',
- 'src/pnggccrd.c',
'src/pngget.c',
+ 'src/pnginfo.h',
'src/pngmem.c',
'src/pngpread.c',
'src/pngread.c',
@@ -37,9 +52,8 @@
'src/pngrtran.c',
'src/pngrutil.c',
'src/pngset.c',
+ 'src/pngstruct.h',
'src/pngtrans.c',
- 'src/pngusr.h',
- 'src/pngvcrd.c',
'src/pngwio.c',
'src/pngwrite.c',
'src/pngwtran.c',
@@ -54,6 +68,12 @@
# doesn't like that. This define tells libpng to not
# complain about our inclusion of setjmp.h.
'PNG_SKIP_SETJMP_CHECK',
+
+ # The PNG_FREE_ME_SUPPORTED define was dropped in libpng
+ # 1.4.0beta78, with its behavior becoming the default
+ # behavior.
+ # Hence, we define it ourselves for version >= 1.4.0
+ 'PNG_FREE_ME_SUPPORTED',
],
},
'export_dependent_settings': [
@@ -1,11 +0,0 @@
--- a/pagespeed/kernel/thread/pthread_rw_lock.cc
+++ b/pagespeed/kernel/thread/pthread_rw_lock.cc
@@ -31,7 +31,7 @@
//
// Other OS's (FreeBSD, Darwin, OpenSolaris) documentation suggests
// that they prefer writers by default.
-#ifdef linux
+#if defined(linux) && defined(__GLIBC__)
pthread_rwlockattr_setkind_np(&attr_,
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
#endif
@@ -1,13 +0,0 @@
--- a/pagespeed/automatic/rename_c_symbols.sh
+++ b/pagespeed/automatic/rename_c_symbols.sh
@@ -24,8 +24,8 @@
set -e # exit script if any command returns an error
set -u # exit the script if any variable is uninitialized
-IN=$(readlink -f $1)
-OUT=$(readlink -f $2)
+IN=$1
+OUT=$2
# Get a list of defined non-C++ symbols that are global and not weak.
# _Z is used at start of C++-mangled symbol names.
@@ -1,64 +0,0 @@
--- a/third_party/chromium/src/base/debug/stack_trace_posix.cc
+++ b/third_party/chromium/src/base/debug/stack_trace_posix.cc
@@ -5,7 +5,9 @@
#include "base/debug/stack_trace.h"
#include <errno.h>
+#if defined(HAVE_BACKTRACE)
#include <execinfo.h>
+#endif
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
@@ -64,7 +66,7 @@
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
-#if defined(__GLIBCXX__)
+#if defined(__GLIBCXX__) && defined(HAVE_BACKTRACE)
std::string::size_type search_from = 0;
while (search_from < text->size()) {
@@ -145,7 +147,7 @@
handler->HandleOutput("\n");
}
-#else
+#elif defined(HAVE_BACKTRACE)
bool printed = false;
// Below part is async-signal unsafe (uses malloc), so execute it only
@@ -469,23 +471,31 @@
StackTrace::StackTrace() {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+#else
+ count_ = 0;
+#endif
}
void StackTrace::Print() const {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
PrintBacktraceOutputHandler handler;
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
void StackTrace::OutputToStream(std::ostream* os) const {
+#if !defined(HAVE_BACKTRACE)
+(*os) << "(stack trace not supported)\n";
+#else
StreamBacktraceOutputHandler handler(os);
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
namespace internal {
-231
View File
@@ -1,231 +0,0 @@
ARG ALPINE_VERSION=3.8
########################
# Build pagespeed psol #
########################
FROM alpine:$ALPINE_VERSION as pagespeed
# Check https://github.com/apache/incubator-pagespeed-mod/tags
ARG MOD_PAGESPEED_TAG=v1.13.35.2
RUN apk add --no-cache \
apache2-dev \
apr-dev \
apr-util-dev \
build-base \
curl \
gettext-dev \
git \
gperf \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libressl-dev \
pcre-dev \
py-setuptools \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${MOD_PAGESPEED_TAG} \
--recurse-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-mod.git \
modpagespeed \
;
WORKDIR /usr/src/modpagespeed
COPY patches/modpagespeed/*.patch ./
RUN for i in *.patch; do printf "\r\nApplying patch ${i%%.*}\r\n"; patch -p1 < $i || exit 1; done
WORKDIR /usr/src/modpagespeed/tools/gyp
RUN ./setup.py install
WORKDIR /usr/src/modpagespeed
RUN build/gyp_chromium --depth=. \
-D use_system_libs=1 \
&& \
cd /usr/src/modpagespeed/pagespeed/automatic && \
make psol BUILDTYPE=Release \
CFLAGS+="-I/usr/include/apr-1" \
CXXFLAGS+="-I/usr/include/apr-1 -DUCHAR_TYPE=uint16_t" \
-j`nproc` \
;
RUN mkdir -p /usr/src/ngxpagespeed/psol/lib/Release/linux/x64 && \
mkdir -p /usr/src/ngxpagespeed/psol/include/out/Release && \
cp -R out/Release/obj /usr/src/ngxpagespeed/psol/include/out/Release/ && \
cp -R pagespeed/automatic/pagespeed_automatic.a /usr/src/ngxpagespeed/psol/lib/Release/linux/x64/ && \
cp -R net \
pagespeed \
testing \
third_party \
url \
/usr/src/ngxpagespeed/psol/include/ \
;
##########################################
# Build Nginx with support for PageSpeed #
##########################################
FROM alpine:$ALPINE_VERSION AS nginx
# Check https://github.com/apache/incubator-pagespeed-ngx/tags
ARG NGX_PAGESPEED_TAG=v1.13.35.2-stable
# Check http://nginx.org/en/download.html for the latest version.
ARG NGINX_VERSION=1.14.1
ARG NGINX_PGPKEY=520A9993A1C052F8
ARG NGINX_BUILD_CONFIG="\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-compat \
--with-file-aio \
--with-http_v2_module \
"
RUN apk add --no-cache \
apr-dev \
apr-util-dev \
build-base \
ca-certificates \
gd-dev \
geoip-dev \
git \
gnupg \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libxslt-dev \
linux-headers \
libressl-dev \
pcre-dev \
tar \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${NGX_PAGESPEED_TAG} \
--recurse-submodules \
--shallow-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-ngx.git \
ngxpagespeed \
;
RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
(gpg --keyserver ha.pool.sks-keyservers.net --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --keyserver-options timeout=10 --recv-keys $NGINX_PGPKEY} ) && \
gpg --trusted-key ${NGINX_PGPKEY} --verify nginx-${NGINX_VERSION}.tar.gz.asc
COPY --from=pagespeed /usr/src/ngxpagespeed /usr/src/ngxpagespeed/
WORKDIR /usr/src/nginx
RUN tar zxf ../nginx-${NGINX_VERSION}.tar.gz --strip-components=1 -C . && \
./configure \
${NGINX_BUILD_CONFIG} \
--add-module=/usr/src/ngxpagespeed \
--with-ld-opt="-Wl,-z,relro,--start-group -lapr-1 -laprutil-1 -licudata -licuuc -lpng -lturbojpeg -ljpeg" \
&& \
make install -j`nproc`
RUN rm -rf /etc/nginx/html/ && \
mkdir /etc/nginx/conf.d/ && \
mkdir -p /usr/share/nginx/html/ && \
sed -i 's|^</body>|<p><a href="https://www.ngxpagespeed.com/"><img src="pagespeed.png" title="Nginx module for rewriting web pages to reduce latency and bandwidth" /></a></p>\n</body>|' html/index.html && \
install -m644 html/index.html /usr/share/nginx/html/ && \
install -m644 html/50x.html /usr/share/nginx/html/ && \
ln -s ../../usr/lib/nginx/modules /etc/nginx/modules && \
strip /usr/sbin/nginx* \
/usr/lib/nginx/modules/*.so \
;
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx.vh.default.conf /etc/nginx/conf.d/default.conf
COPY pagespeed.png /usr/share/nginx/html/
##########################################
# Combine everything with minimal layers #
##########################################
FROM alpine:$ALPINE_VERSION
LABEL maintainer="Nico Berlee <nico.berlee@on2it.net>" \
version.mod-pagespeed="1.13.35.2" \
version.nginx="1.14.1" \
version.ngx-pagespeed="1.13.35.2"
COPY --from=pagespeed /usr/bin/envsubst /usr/local/bin
COPY --from=nginx /usr/sbin/nginx /usr/sbin/nginx
COPY --from=nginx /usr/lib/nginx/modules/ /usr/lib/nginx/modules/
COPY --from=nginx /etc/nginx /etc/nginx
COPY --from=nginx /usr/share/nginx/html/ /usr/share/nginx/html/
RUN apk --no-cache upgrade && \
scanelf --needed --nobanner --format '%n#p' /usr/sbin/nginx /usr/lib/nginx/modules/*.so /usr/local/bin/envsubst \
| tr ',' '\n' \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
| xargs apk add --no-cache \
&& \
apk add --no-cache tzdata
RUN addgroup -S nginx && \
adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx && \
install -g nginx -o nginx -d /var/cache/ngx_pagespeed && \
mkdir -p /var/log/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
@@ -1,32 +0,0 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
@@ -1,57 +0,0 @@
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
pagespeed on;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

@@ -1,31 +0,0 @@
--- a/pagespeed/automatic/Makefile
+++ b/pagespeed/automatic/Makefile
@@ -146,8 +146,6 @@
pagespeed/libpagespeed_thread.a \
pagespeed/libpthread_system.a \
pagespeed/libutil.a \
- third_party/apr/libapr.a \
- third_party/aprutil/libaprutil.a \
third_party/base64/libbase64.a \
third_party/chromium/src/base/third_party/dynamic_annotations/libdynamic_annotations.a \
third_party/css_parser/libcss_parser.a \
@@ -163,18 +161,11 @@
third_party/grpc/libgrpc_core.a \
third_party/grpc/libgrpc_cpp.a \
third_party/hiredis/libhiredis.a \
- third_party/icu/libicudata.a \
- third_party/icu/libicuuc.a \
third_party/jsoncpp/libjsoncpp.a \
- third_party/libjpeg_turbo/libjpeg.a \
- third_party/libjpeg_turbo/src/libjpeg_turbo.a \
- third_party/libpng/libpng.a \
third_party/optipng/libopngreduc.a \
third_party/protobuf/libprotobuf_full_do_not_use.a \
third_party/re2/libre2.a \
- third_party/serf/libopenssl.a \
third_party/serf/libserf.a \
- third_party/zlib/libzlib.a \
url/liburl_lib.a
# The 'gclient' build flow uses 'xcodebuild' on Mac and 'make' on Linux.
@@ -1,141 +0,0 @@
From 7ea8d5fc141c7067c54ffa2b9fbc552c15089ca6 Mon Sep 17 00:00:00 2001
From: ashishk-1 <ashish.k@gdbtech.in>
Date: Thu, 18 Jan 2018 22:14:05 +0530
Subject: [PATCH] Upgrading libpng library to version 1.6 (#1724)
---
net/instaweb/rewriter/image.cc | 8 ++++++++
pagespeed/kernel/image/gif_reader.cc | 4 ++--
pagespeed/kernel/image/image_converter.cc | 6 ++++++
pagespeed/kernel/image/png_optimizer_test.cc | 6 ++++++
third_party/libpng/libpng.gyp | 26 +++++++++++++++++++++++---
third_party/libpng/src | 2 +-
6 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/net/instaweb/rewriter/image.cc b/net/instaweb/rewriter/image.cc
index 4f631182a..bb67bba35 100644
--- a/net/instaweb/rewriter/image.cc
+++ b/net/instaweb/rewriter/image.cc
@@ -21,6 +21,14 @@
#include <algorithm>
#include <cstddef>
+extern "C" {
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
+} // extern "C"
+
#include "base/logging.h"
#include "net/instaweb/rewriter/cached_result.pb.h"
#include "net/instaweb/rewriter/public/image_data_lookup.h"
diff --git a/pagespeed/kernel/image/gif_reader.cc b/pagespeed/kernel/image/gif_reader.cc
index 7de69b3d7..bb0bc9cfc 100644
--- a/pagespeed/kernel/image/gif_reader.cc
+++ b/pagespeed/kernel/image/gif_reader.cc
@@ -411,8 +411,8 @@ bool ReadGifToPng(GifFileType* gif_file,
png_uint_32 height = png_get_image_height(paletted_png_ptr,
paletted_info_ptr);
for (png_uint_32 row = 1; row < height; ++row) {
- memcpy(paletted_info_ptr->row_pointers[row],
- paletted_info_ptr->row_pointers[0],
+ memcpy(row_pointers[row],
+ row_pointers[0],
row_size);
}
diff --git a/pagespeed/kernel/image/image_converter.cc b/pagespeed/kernel/image/image_converter.cc
index d796b5065..84b7aff74 100644
--- a/pagespeed/kernel/image/image_converter.cc
+++ b/pagespeed/kernel/image/image_converter.cc
@@ -30,6 +30,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
} // extern "C"
#include "base/logging.h"
diff --git a/pagespeed/kernel/image/png_optimizer_test.cc b/pagespeed/kernel/image/png_optimizer_test.cc
index 9ad915aff..3faa526a8 100644
--- a/pagespeed/kernel/image/png_optimizer_test.cc
+++ b/pagespeed/kernel/image/png_optimizer_test.cc
@@ -36,6 +36,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
}
namespace {
diff --git a/third_party/libpng/libpng.gyp b/third_party/libpng/libpng.gyp
index cfaafee00..d96a8f74c 100644
--- a/third_party/libpng/libpng.gyp
+++ b/third_party/libpng/libpng.gyp
@@ -22,14 +22,29 @@
'dependencies': [
'../zlib/zlib.gyp:zlib',
],
+ 'actions': [
+ {
+ 'action_name': 'copy_libpngconf_prebuilt',
+ 'inputs' : [],
+ 'outputs': [''],
+ 'action': [
+ 'cp',
+ '-f',
+ '<(DEPTH)/third_party/libpng/src/scripts/pnglibconf.h.prebuilt',
+ '<(DEPTH)/third_party/libpng/src/pnglibconf.h',
+ ],
+ },
+ ],
'msvs_guid': 'C564F145-9172-42C3-BFCB-6014CA97DBCD',
'sources': [
+ 'src/pngpriv.h',
'src/png.c',
'src/png.h',
'src/pngconf.h',
+ 'src/pngdebug.h',
'src/pngerror.c',
- 'src/pnggccrd.c',
'src/pngget.c',
+ 'src/pnginfo.h',
'src/pngmem.c',
'src/pngpread.c',
'src/pngread.c',
@@ -37,9 +52,8 @@
'src/pngrtran.c',
'src/pngrutil.c',
'src/pngset.c',
+ 'src/pngstruct.h',
'src/pngtrans.c',
- 'src/pngusr.h',
- 'src/pngvcrd.c',
'src/pngwio.c',
'src/pngwrite.c',
'src/pngwtran.c',
@@ -54,6 +68,12 @@
# doesn't like that. This define tells libpng to not
# complain about our inclusion of setjmp.h.
'PNG_SKIP_SETJMP_CHECK',
+
+ # The PNG_FREE_ME_SUPPORTED define was dropped in libpng
+ # 1.4.0beta78, with its behavior becoming the default
+ # behavior.
+ # Hence, we define it ourselves for version >= 1.4.0
+ 'PNG_FREE_ME_SUPPORTED',
],
},
'export_dependent_settings': [
@@ -1,11 +0,0 @@
--- a/pagespeed/kernel/thread/pthread_rw_lock.cc
+++ b/pagespeed/kernel/thread/pthread_rw_lock.cc
@@ -31,7 +31,7 @@
//
// Other OS's (FreeBSD, Darwin, OpenSolaris) documentation suggests
// that they prefer writers by default.
-#ifdef linux
+#if defined(linux) && defined(__GLIBC__)
pthread_rwlockattr_setkind_np(&attr_,
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
#endif
@@ -1,13 +0,0 @@
--- a/pagespeed/automatic/rename_c_symbols.sh
+++ b/pagespeed/automatic/rename_c_symbols.sh
@@ -24,8 +24,8 @@
set -e # exit script if any command returns an error
set -u # exit the script if any variable is uninitialized
-IN=$(readlink -f $1)
-OUT=$(readlink -f $2)
+IN=$1
+OUT=$2
# Get a list of defined non-C++ symbols that are global and not weak.
# _Z is used at start of C++-mangled symbol names.
@@ -1,64 +0,0 @@
--- a/third_party/chromium/src/base/debug/stack_trace_posix.cc
+++ b/third_party/chromium/src/base/debug/stack_trace_posix.cc
@@ -5,7 +5,9 @@
#include "base/debug/stack_trace.h"
#include <errno.h>
+#if defined(HAVE_BACKTRACE)
#include <execinfo.h>
+#endif
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
@@ -64,7 +66,7 @@
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
-#if defined(__GLIBCXX__)
+#if defined(__GLIBCXX__) && defined(HAVE_BACKTRACE)
std::string::size_type search_from = 0;
while (search_from < text->size()) {
@@ -145,7 +147,7 @@
handler->HandleOutput("\n");
}
-#else
+#elif defined(HAVE_BACKTRACE)
bool printed = false;
// Below part is async-signal unsafe (uses malloc), so execute it only
@@ -469,23 +471,31 @@
StackTrace::StackTrace() {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+#else
+ count_ = 0;
+#endif
}
void StackTrace::Print() const {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
PrintBacktraceOutputHandler handler;
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
void StackTrace::OutputToStream(std::ostream* os) const {
+#if !defined(HAVE_BACKTRACE)
+(*os) << "(stack trace not supported)\n";
+#else
StreamBacktraceOutputHandler handler(os);
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
namespace internal {
@@ -1,230 +0,0 @@
ARG ALPINE_VERSION=edge
########################
# Build pagespeed psol #
########################
FROM alpine:$ALPINE_VERSION as pagespeed
# Check https://github.com/apache/incubator-pagespeed-mod/tags
ARG MOD_PAGESPEED_TAG=v1.13.35.2
RUN apk add --no-cache \
apache2-dev \
apr-dev \
apr-util-dev \
build-base \
curl \
gettext-dev \
git \
gperf \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libressl-dev \
pcre-dev \
py-setuptools \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${MOD_PAGESPEED_TAG} \
--recurse-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-mod.git \
modpagespeed \
;
WORKDIR /usr/src/modpagespeed
COPY patches/modpagespeed/*.patch ./
RUN for i in *.patch; do printf "\r\nApplying patch ${i%%.*}\r\n"; patch -p1 < $i || exit 1; done
WORKDIR /usr/src/modpagespeed/tools/gyp
RUN ./setup.py install
WORKDIR /usr/src/modpagespeed
RUN build/gyp_chromium --depth=. \
-D use_system_libs=1 \
&& \
cd /usr/src/modpagespeed/pagespeed/automatic && \
make psol BUILDTYPE=Release \
CFLAGS+="-I/usr/include/apr-1" \
CXXFLAGS+="-I/usr/include/apr-1 -DUCHAR_TYPE=uint16_t" \
-j`nproc` \
;
RUN mkdir -p /usr/src/ngxpagespeed/psol/lib/Release/linux/x64 && \
mkdir -p /usr/src/ngxpagespeed/psol/include/out/Release && \
cp -R out/Release/obj /usr/src/ngxpagespeed/psol/include/out/Release/ && \
cp -R pagespeed/automatic/pagespeed_automatic.a /usr/src/ngxpagespeed/psol/lib/Release/linux/x64/ && \
cp -R net \
pagespeed \
testing \
third_party \
url \
/usr/src/ngxpagespeed/psol/include/ \
;
##########################################
# Build Nginx with support for PageSpeed #
##########################################
FROM alpine:$ALPINE_VERSION AS nginx
# Check https://github.com/apache/incubator-pagespeed-ngx/tags
ARG NGX_PAGESPEED_TAG=v1.13.35.2-stable
# Check http://nginx.org/en/download.html for the latest version.
ARG NGINX_VERSION=1.15.6
ARG NGINX_PGPKEY=520A9993A1C052F8
ARG NGINX_BUILD_CONFIG="\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-compat \
--with-file-aio \
--with-http_v2_module \
"
RUN apk add --no-cache \
apr-dev \
apr-util-dev \
build-base \
ca-certificates \
gd-dev \
geoip-dev \
git \
gnupg \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libxslt-dev \
linux-headers \
libressl-dev \
pcre-dev \
tar \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${NGX_PAGESPEED_TAG} \
--recurse-submodules \
--shallow-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-ngx.git \
ngxpagespeed \
;
RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
(gpg --keyserver ha.pool.sks-keyservers.net --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --keyserver-options timeout=10 --recv-keys $NGINX_PGPKEY} ) && \
gpg --trusted-key ${NGINX_PGPKEY} --verify nginx-${NGINX_VERSION}.tar.gz.asc
COPY --from=pagespeed /usr/src/ngxpagespeed /usr/src/ngxpagespeed/
WORKDIR /usr/src/nginx
RUN tar zxf ../nginx-${NGINX_VERSION}.tar.gz --strip-components=1 -C . && \
./configure \
${NGINX_BUILD_CONFIG} \
--add-module=/usr/src/ngxpagespeed \
--with-ld-opt="-Wl,-z,relro,--start-group -lapr-1 -laprutil-1 -licudata -licuuc -lpng -lturbojpeg -ljpeg" \
&& \
make install -j`nproc`
RUN rm -rf /etc/nginx/html/ && \
mkdir /etc/nginx/conf.d/ && \
mkdir -p /usr/share/nginx/html/ && \
sed -i 's|^</body>|<p><a href="https://www.ngxpagespeed.com/"><img src="pagespeed.png" title="Nginx module for rewriting web pages to reduce latency and bandwidth" /></a></p>\n</body>|' html/index.html && \
install -m644 html/index.html /usr/share/nginx/html/ && \
install -m644 html/50x.html /usr/share/nginx/html/ && \
ln -s ../../usr/lib/nginx/modules /etc/nginx/modules && \
strip /usr/sbin/nginx* \
/usr/lib/nginx/modules/*.so \
;
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx.vh.default.conf /etc/nginx/conf.d/default.conf
COPY pagespeed.png /usr/share/nginx/html/
##########################################
# Combine everything with minimal layers #
##########################################
FROM alpine:$ALPINE_VERSION
LABEL maintainer="Nico Berlee <nico.berlee@on2it.net>" \
version.mod-pagespeed="1.13.35.2" \
version.nginx="1.15.6" \
version.ngx-pagespeed="1.13.35.2"
COPY --from=pagespeed /usr/bin/envsubst /usr/local/bin
COPY --from=nginx /usr/sbin/nginx /usr/sbin/nginx
COPY --from=nginx /usr/lib/nginx/modules/ /usr/lib/nginx/modules/
COPY --from=nginx /etc/nginx /etc/nginx
COPY --from=nginx /usr/share/nginx/html/ /usr/share/nginx/html/
RUN apk --no-cache upgrade && \
scanelf --needed --nobanner --format '%n#p' /usr/sbin/nginx /usr/lib/nginx/modules/*.so /usr/local/bin/envsubst \
| tr ',' '\n' \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
| xargs apk add --no-cache \
&& \
apk add --no-cache tzdata
RUN addgroup -S nginx && \
adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx && \
install -g nginx -o nginx -d /var/cache/ngx_pagespeed && \
mkdir -p /var/log/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
@@ -1,32 +0,0 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
@@ -1,57 +0,0 @@
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
pagespeed on;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

@@ -1,31 +0,0 @@
--- a/pagespeed/automatic/Makefile
+++ b/pagespeed/automatic/Makefile
@@ -146,8 +146,6 @@
pagespeed/libpagespeed_thread.a \
pagespeed/libpthread_system.a \
pagespeed/libutil.a \
- third_party/apr/libapr.a \
- third_party/aprutil/libaprutil.a \
third_party/base64/libbase64.a \
third_party/chromium/src/base/third_party/dynamic_annotations/libdynamic_annotations.a \
third_party/css_parser/libcss_parser.a \
@@ -163,18 +161,11 @@
third_party/grpc/libgrpc_core.a \
third_party/grpc/libgrpc_cpp.a \
third_party/hiredis/libhiredis.a \
- third_party/icu/libicudata.a \
- third_party/icu/libicuuc.a \
third_party/jsoncpp/libjsoncpp.a \
- third_party/libjpeg_turbo/libjpeg.a \
- third_party/libjpeg_turbo/src/libjpeg_turbo.a \
- third_party/libpng/libpng.a \
third_party/optipng/libopngreduc.a \
third_party/protobuf/libprotobuf_full_do_not_use.a \
third_party/re2/libre2.a \
- third_party/serf/libopenssl.a \
third_party/serf/libserf.a \
- third_party/zlib/libzlib.a \
url/liburl_lib.a
# The 'gclient' build flow uses 'xcodebuild' on Mac and 'make' on Linux.
@@ -1,141 +0,0 @@
From 7ea8d5fc141c7067c54ffa2b9fbc552c15089ca6 Mon Sep 17 00:00:00 2001
From: ashishk-1 <ashish.k@gdbtech.in>
Date: Thu, 18 Jan 2018 22:14:05 +0530
Subject: [PATCH] Upgrading libpng library to version 1.6 (#1724)
---
net/instaweb/rewriter/image.cc | 8 ++++++++
pagespeed/kernel/image/gif_reader.cc | 4 ++--
pagespeed/kernel/image/image_converter.cc | 6 ++++++
pagespeed/kernel/image/png_optimizer_test.cc | 6 ++++++
third_party/libpng/libpng.gyp | 26 +++++++++++++++++++++++---
third_party/libpng/src | 2 +-
6 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/net/instaweb/rewriter/image.cc b/net/instaweb/rewriter/image.cc
index 4f631182a..bb67bba35 100644
--- a/net/instaweb/rewriter/image.cc
+++ b/net/instaweb/rewriter/image.cc
@@ -21,6 +21,14 @@
#include <algorithm>
#include <cstddef>
+extern "C" {
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
+} // extern "C"
+
#include "base/logging.h"
#include "net/instaweb/rewriter/cached_result.pb.h"
#include "net/instaweb/rewriter/public/image_data_lookup.h"
diff --git a/pagespeed/kernel/image/gif_reader.cc b/pagespeed/kernel/image/gif_reader.cc
index 7de69b3d7..bb0bc9cfc 100644
--- a/pagespeed/kernel/image/gif_reader.cc
+++ b/pagespeed/kernel/image/gif_reader.cc
@@ -411,8 +411,8 @@ bool ReadGifToPng(GifFileType* gif_file,
png_uint_32 height = png_get_image_height(paletted_png_ptr,
paletted_info_ptr);
for (png_uint_32 row = 1; row < height; ++row) {
- memcpy(paletted_info_ptr->row_pointers[row],
- paletted_info_ptr->row_pointers[0],
+ memcpy(row_pointers[row],
+ row_pointers[0],
row_size);
}
diff --git a/pagespeed/kernel/image/image_converter.cc b/pagespeed/kernel/image/image_converter.cc
index d796b5065..84b7aff74 100644
--- a/pagespeed/kernel/image/image_converter.cc
+++ b/pagespeed/kernel/image/image_converter.cc
@@ -30,6 +30,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
} // extern "C"
#include "base/logging.h"
diff --git a/pagespeed/kernel/image/png_optimizer_test.cc b/pagespeed/kernel/image/png_optimizer_test.cc
index 9ad915aff..3faa526a8 100644
--- a/pagespeed/kernel/image/png_optimizer_test.cc
+++ b/pagespeed/kernel/image/png_optimizer_test.cc
@@ -36,6 +36,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
}
namespace {
diff --git a/third_party/libpng/libpng.gyp b/third_party/libpng/libpng.gyp
index cfaafee00..d96a8f74c 100644
--- a/third_party/libpng/libpng.gyp
+++ b/third_party/libpng/libpng.gyp
@@ -22,14 +22,29 @@
'dependencies': [
'../zlib/zlib.gyp:zlib',
],
+ 'actions': [
+ {
+ 'action_name': 'copy_libpngconf_prebuilt',
+ 'inputs' : [],
+ 'outputs': [''],
+ 'action': [
+ 'cp',
+ '-f',
+ '<(DEPTH)/third_party/libpng/src/scripts/pnglibconf.h.prebuilt',
+ '<(DEPTH)/third_party/libpng/src/pnglibconf.h',
+ ],
+ },
+ ],
'msvs_guid': 'C564F145-9172-42C3-BFCB-6014CA97DBCD',
'sources': [
+ 'src/pngpriv.h',
'src/png.c',
'src/png.h',
'src/pngconf.h',
+ 'src/pngdebug.h',
'src/pngerror.c',
- 'src/pnggccrd.c',
'src/pngget.c',
+ 'src/pnginfo.h',
'src/pngmem.c',
'src/pngpread.c',
'src/pngread.c',
@@ -37,9 +52,8 @@
'src/pngrtran.c',
'src/pngrutil.c',
'src/pngset.c',
+ 'src/pngstruct.h',
'src/pngtrans.c',
- 'src/pngusr.h',
- 'src/pngvcrd.c',
'src/pngwio.c',
'src/pngwrite.c',
'src/pngwtran.c',
@@ -54,6 +68,12 @@
# doesn't like that. This define tells libpng to not
# complain about our inclusion of setjmp.h.
'PNG_SKIP_SETJMP_CHECK',
+
+ # The PNG_FREE_ME_SUPPORTED define was dropped in libpng
+ # 1.4.0beta78, with its behavior becoming the default
+ # behavior.
+ # Hence, we define it ourselves for version >= 1.4.0
+ 'PNG_FREE_ME_SUPPORTED',
],
},
'export_dependent_settings': [
@@ -1,11 +0,0 @@
--- a/pagespeed/kernel/thread/pthread_rw_lock.cc
+++ b/pagespeed/kernel/thread/pthread_rw_lock.cc
@@ -31,7 +31,7 @@
//
// Other OS's (FreeBSD, Darwin, OpenSolaris) documentation suggests
// that they prefer writers by default.
-#ifdef linux
+#if defined(linux) && defined(__GLIBC__)
pthread_rwlockattr_setkind_np(&attr_,
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
#endif
@@ -1,13 +0,0 @@
--- a/pagespeed/automatic/rename_c_symbols.sh
+++ b/pagespeed/automatic/rename_c_symbols.sh
@@ -24,8 +24,8 @@
set -e # exit script if any command returns an error
set -u # exit the script if any variable is uninitialized
-IN=$(readlink -f $1)
-OUT=$(readlink -f $2)
+IN=$1
+OUT=$2
# Get a list of defined non-C++ symbols that are global and not weak.
# _Z is used at start of C++-mangled symbol names.
@@ -1,64 +0,0 @@
--- a/third_party/chromium/src/base/debug/stack_trace_posix.cc
+++ b/third_party/chromium/src/base/debug/stack_trace_posix.cc
@@ -5,7 +5,9 @@
#include "base/debug/stack_trace.h"
#include <errno.h>
+#if defined(HAVE_BACKTRACE)
#include <execinfo.h>
+#endif
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
@@ -64,7 +66,7 @@
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
-#if defined(__GLIBCXX__)
+#if defined(__GLIBCXX__) && defined(HAVE_BACKTRACE)
std::string::size_type search_from = 0;
while (search_from < text->size()) {
@@ -145,7 +147,7 @@
handler->HandleOutput("\n");
}
-#else
+#elif defined(HAVE_BACKTRACE)
bool printed = false;
// Below part is async-signal unsafe (uses malloc), so execute it only
@@ -469,23 +471,31 @@
StackTrace::StackTrace() {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+#else
+ count_ = 0;
+#endif
}
void StackTrace::Print() const {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
PrintBacktraceOutputHandler handler;
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
void StackTrace::OutputToStream(std::ostream* os) const {
+#if !defined(HAVE_BACKTRACE)
+(*os) << "(stack trace not supported)\n";
+#else
StreamBacktraceOutputHandler handler(os);
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
namespace internal {
-235
View File
@@ -1,235 +0,0 @@
ARG ALPINE_VERSION=edge
########################
# Build pagespeed psol #
########################
FROM alpine:$ALPINE_VERSION as pagespeed
# Check https://github.com/apache/incubator-pagespeed-mod/tags
ARG MOD_PAGESPEED_TAG=v1.13.35.2
RUN apk add --no-cache \
apache2-dev \
apr-dev \
apr-util-dev \
build-base \
curl \
gettext-dev \
git \
gperf \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libressl-dev \
pcre-dev \
py-setuptools \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${MOD_PAGESPEED_TAG} \
--recurse-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-mod.git \
modpagespeed \
;
WORKDIR /usr/src/modpagespeed
COPY patches/modpagespeed/*.patch ./
RUN for i in *.patch; do printf "\r\nApplying patch ${i%%.*}\r\n"; patch -p1 < $i || exit 1; done
WORKDIR /usr/src/modpagespeed/tools/gyp
RUN ./setup.py install
WORKDIR /usr/src/modpagespeed
RUN build/gyp_chromium --depth=. \
-D use_system_libs=1 \
&& \
cd /usr/src/modpagespeed/pagespeed/automatic && \
make psol BUILDTYPE=Release \
CFLAGS+="-I/usr/include/apr-1" \
CXXFLAGS+="-I/usr/include/apr-1 -DUCHAR_TYPE=uint16_t" \
-j`nproc` \
;
RUN mkdir -p /usr/src/ngxpagespeed/psol/lib/Release/linux/x64 && \
mkdir -p /usr/src/ngxpagespeed/psol/include/out/Release && \
cp -R out/Release/obj /usr/src/ngxpagespeed/psol/include/out/Release/ && \
cp -R pagespeed/automatic/pagespeed_automatic.a /usr/src/ngxpagespeed/psol/lib/Release/linux/x64/ && \
cp -R net \
pagespeed \
testing \
third_party \
url \
/usr/src/ngxpagespeed/psol/include/ \
;
##########################################
# Build Nginx with support for PageSpeed #
##########################################
FROM alpine:$ALPINE_VERSION AS nginx
# Check https://github.com/apache/incubator-pagespeed-ngx/tags
ARG NGX_PAGESPEED_TAG=v1.13.35.2-stable
# Check http://nginx.org/en/download.html for the latest version.
ARG NGINX_VERSION=1.14.1
ARG NGINX_PGPKEY=520A9993A1C052F8
ARG NGINX_BUILD_CONFIG="\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-compat \
--with-file-aio \
--with-http_v2_module \
"
RUN apk add --no-cache \
apr-dev \
apr-util-dev \
build-base \
ca-certificates \
gd-dev \
geoip-dev \
git \
gnupg \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libxslt-dev \
linux-headers \
libressl-dev \
pcre-dev \
tar \
zlib-dev \
;
WORKDIR /usr/src
RUN git clone -b ${NGX_PAGESPEED_TAG} \
--recurse-submodules \
--shallow-submodules \
--depth=1 \
-c advice.detachedHead=false \
-j`nproc` \
https://github.com/apache/incubator-pagespeed-ngx.git \
ngxpagespeed \
;
RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
(gpg --keyserver ha.pool.sks-keyservers.net --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options timeout=10 --recv-keys ${NGINX_PGPKEY} || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --keyserver-options timeout=10 --recv-keys $NGINX_PGPKEY} ) && \
gpg --trusted-key ${NGINX_PGPKEY} --verify nginx-${NGINX_VERSION}.tar.gz.asc
COPY --from=pagespeed /usr/src/ngxpagespeed /usr/src/ngxpagespeed/
WORKDIR /usr/src/nginx
RUN tar zxf ../nginx-${NGINX_VERSION}.tar.gz --strip-components=1 -C .
COPY patches/ngx/*.patch ./
RUN for i in *.patch; do printf "\r\nApplying patch ${i%%.*}\r\n"; patch -p1 < $i || exit 1; done
RUN ./configure \
${NGINX_BUILD_CONFIG} \
--add-module=/usr/src/ngxpagespeed \
--with-ld-opt="-Wl,-z,relro,--start-group -lapr-1 -laprutil-1 -licudata -licuuc -lpng -lturbojpeg -ljpeg" \
&& \
make install -j`nproc`
RUN rm -rf /etc/nginx/html/ && \
mkdir /etc/nginx/conf.d/ && \
mkdir -p /usr/share/nginx/html/ && \
sed -i 's|^</body>|<p><a href="https://www.ngxpagespeed.com/"><img src="pagespeed.png" title="Nginx module for rewriting web pages to reduce latency and bandwidth" /></a></p>\n</body>|' html/index.html && \
install -m644 html/index.html /usr/share/nginx/html/ && \
install -m644 html/50x.html /usr/share/nginx/html/ && \
ln -s ../../usr/lib/nginx/modules /etc/nginx/modules && \
strip /usr/sbin/nginx* \
/usr/lib/nginx/modules/*.so \
;
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx.vh.default.conf /etc/nginx/conf.d/default.conf
COPY pagespeed.png /usr/share/nginx/html/
##########################################
# Combine everything with minimal layers #
##########################################
FROM alpine:$ALPINE_VERSION
LABEL maintainer="Nico Berlee <nico.berlee@on2it.net>" \
version.mod-pagespeed="1.13.35.2" \
version.nginx="1.14.1" \
version.ngx-pagespeed="1.13.35.2"
COPY --from=pagespeed /usr/bin/envsubst /usr/local/bin
COPY --from=nginx /usr/sbin/nginx /usr/sbin/nginx
COPY --from=nginx /usr/lib/nginx/modules/ /usr/lib/nginx/modules/
COPY --from=nginx /etc/nginx /etc/nginx
COPY --from=nginx /usr/share/nginx/html/ /usr/share/nginx/html/
RUN apk --no-cache upgrade && \
scanelf --needed --nobanner --format '%n#p' /usr/sbin/nginx /usr/lib/nginx/modules/*.so /usr/local/bin/envsubst \
| tr ',' '\n' \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
| xargs apk add --no-cache \
&& \
apk add --no-cache tzdata
RUN addgroup -S nginx && \
adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx && \
install -g nginx -o nginx -d /var/cache/ngx_pagespeed && \
mkdir -p /var/log/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
@@ -1,32 +0,0 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
@@ -1,57 +0,0 @@
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
pagespeed on;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

@@ -1,31 +0,0 @@
--- a/pagespeed/automatic/Makefile
+++ b/pagespeed/automatic/Makefile
@@ -146,8 +146,6 @@
pagespeed/libpagespeed_thread.a \
pagespeed/libpthread_system.a \
pagespeed/libutil.a \
- third_party/apr/libapr.a \
- third_party/aprutil/libaprutil.a \
third_party/base64/libbase64.a \
third_party/chromium/src/base/third_party/dynamic_annotations/libdynamic_annotations.a \
third_party/css_parser/libcss_parser.a \
@@ -163,18 +161,11 @@
third_party/grpc/libgrpc_core.a \
third_party/grpc/libgrpc_cpp.a \
third_party/hiredis/libhiredis.a \
- third_party/icu/libicudata.a \
- third_party/icu/libicuuc.a \
third_party/jsoncpp/libjsoncpp.a \
- third_party/libjpeg_turbo/libjpeg.a \
- third_party/libjpeg_turbo/src/libjpeg_turbo.a \
- third_party/libpng/libpng.a \
third_party/optipng/libopngreduc.a \
third_party/protobuf/libprotobuf_full_do_not_use.a \
third_party/re2/libre2.a \
- third_party/serf/libopenssl.a \
third_party/serf/libserf.a \
- third_party/zlib/libzlib.a \
url/liburl_lib.a
# The 'gclient' build flow uses 'xcodebuild' on Mac and 'make' on Linux.
@@ -1,141 +0,0 @@
From 7ea8d5fc141c7067c54ffa2b9fbc552c15089ca6 Mon Sep 17 00:00:00 2001
From: ashishk-1 <ashish.k@gdbtech.in>
Date: Thu, 18 Jan 2018 22:14:05 +0530
Subject: [PATCH] Upgrading libpng library to version 1.6 (#1724)
---
net/instaweb/rewriter/image.cc | 8 ++++++++
pagespeed/kernel/image/gif_reader.cc | 4 ++--
pagespeed/kernel/image/image_converter.cc | 6 ++++++
pagespeed/kernel/image/png_optimizer_test.cc | 6 ++++++
third_party/libpng/libpng.gyp | 26 +++++++++++++++++++++++---
third_party/libpng/src | 2 +-
6 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/net/instaweb/rewriter/image.cc b/net/instaweb/rewriter/image.cc
index 4f631182a..bb67bba35 100644
--- a/net/instaweb/rewriter/image.cc
+++ b/net/instaweb/rewriter/image.cc
@@ -21,6 +21,14 @@
#include <algorithm>
#include <cstddef>
+extern "C" {
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
+} // extern "C"
+
#include "base/logging.h"
#include "net/instaweb/rewriter/cached_result.pb.h"
#include "net/instaweb/rewriter/public/image_data_lookup.h"
diff --git a/pagespeed/kernel/image/gif_reader.cc b/pagespeed/kernel/image/gif_reader.cc
index 7de69b3d7..bb0bc9cfc 100644
--- a/pagespeed/kernel/image/gif_reader.cc
+++ b/pagespeed/kernel/image/gif_reader.cc
@@ -411,8 +411,8 @@ bool ReadGifToPng(GifFileType* gif_file,
png_uint_32 height = png_get_image_height(paletted_png_ptr,
paletted_info_ptr);
for (png_uint_32 row = 1; row < height; ++row) {
- memcpy(paletted_info_ptr->row_pointers[row],
- paletted_info_ptr->row_pointers[0],
+ memcpy(row_pointers[row],
+ row_pointers[0],
row_size);
}
diff --git a/pagespeed/kernel/image/image_converter.cc b/pagespeed/kernel/image/image_converter.cc
index d796b5065..84b7aff74 100644
--- a/pagespeed/kernel/image/image_converter.cc
+++ b/pagespeed/kernel/image/image_converter.cc
@@ -30,6 +30,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
} // extern "C"
#include "base/logging.h"
diff --git a/pagespeed/kernel/image/png_optimizer_test.cc b/pagespeed/kernel/image/png_optimizer_test.cc
index 9ad915aff..3faa526a8 100644
--- a/pagespeed/kernel/image/png_optimizer_test.cc
+++ b/pagespeed/kernel/image/png_optimizer_test.cc
@@ -36,6 +36,12 @@ extern "C" {
#else
#include "third_party/libpng/src/png.h"
#endif
+
+#ifdef USE_SYSTEM_ZLIB
+#include "zlib.h"
+#else
+#include "third_party/zlib/zlib.h"
+#endif
}
namespace {
diff --git a/third_party/libpng/libpng.gyp b/third_party/libpng/libpng.gyp
index cfaafee00..d96a8f74c 100644
--- a/third_party/libpng/libpng.gyp
+++ b/third_party/libpng/libpng.gyp
@@ -22,14 +22,29 @@
'dependencies': [
'../zlib/zlib.gyp:zlib',
],
+ 'actions': [
+ {
+ 'action_name': 'copy_libpngconf_prebuilt',
+ 'inputs' : [],
+ 'outputs': [''],
+ 'action': [
+ 'cp',
+ '-f',
+ '<(DEPTH)/third_party/libpng/src/scripts/pnglibconf.h.prebuilt',
+ '<(DEPTH)/third_party/libpng/src/pnglibconf.h',
+ ],
+ },
+ ],
'msvs_guid': 'C564F145-9172-42C3-BFCB-6014CA97DBCD',
'sources': [
+ 'src/pngpriv.h',
'src/png.c',
'src/png.h',
'src/pngconf.h',
+ 'src/pngdebug.h',
'src/pngerror.c',
- 'src/pnggccrd.c',
'src/pngget.c',
+ 'src/pnginfo.h',
'src/pngmem.c',
'src/pngpread.c',
'src/pngread.c',
@@ -37,9 +52,8 @@
'src/pngrtran.c',
'src/pngrutil.c',
'src/pngset.c',
+ 'src/pngstruct.h',
'src/pngtrans.c',
- 'src/pngusr.h',
- 'src/pngvcrd.c',
'src/pngwio.c',
'src/pngwrite.c',
'src/pngwtran.c',
@@ -54,6 +68,12 @@
# doesn't like that. This define tells libpng to not
# complain about our inclusion of setjmp.h.
'PNG_SKIP_SETJMP_CHECK',
+
+ # The PNG_FREE_ME_SUPPORTED define was dropped in libpng
+ # 1.4.0beta78, with its behavior becoming the default
+ # behavior.
+ # Hence, we define it ourselves for version >= 1.4.0
+ 'PNG_FREE_ME_SUPPORTED',
],
},
'export_dependent_settings': [
@@ -1,11 +0,0 @@
--- a/pagespeed/kernel/thread/pthread_rw_lock.cc
+++ b/pagespeed/kernel/thread/pthread_rw_lock.cc
@@ -31,7 +31,7 @@
//
// Other OS's (FreeBSD, Darwin, OpenSolaris) documentation suggests
// that they prefer writers by default.
-#ifdef linux
+#if defined(linux) && defined(__GLIBC__)
pthread_rwlockattr_setkind_np(&attr_,
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
#endif
@@ -1,13 +0,0 @@
--- a/pagespeed/automatic/rename_c_symbols.sh
+++ b/pagespeed/automatic/rename_c_symbols.sh
@@ -24,8 +24,8 @@
set -e # exit script if any command returns an error
set -u # exit the script if any variable is uninitialized
-IN=$(readlink -f $1)
-OUT=$(readlink -f $2)
+IN=$1
+OUT=$2
# Get a list of defined non-C++ symbols that are global and not weak.
# _Z is used at start of C++-mangled symbol names.
@@ -1,64 +0,0 @@
--- a/third_party/chromium/src/base/debug/stack_trace_posix.cc
+++ b/third_party/chromium/src/base/debug/stack_trace_posix.cc
@@ -5,7 +5,9 @@
#include "base/debug/stack_trace.h"
#include <errno.h>
+#if defined(HAVE_BACKTRACE)
#include <execinfo.h>
+#endif
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
@@ -64,7 +66,7 @@
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
-#if defined(__GLIBCXX__)
+#if defined(__GLIBCXX__) && defined(HAVE_BACKTRACE)
std::string::size_type search_from = 0;
while (search_from < text->size()) {
@@ -145,7 +147,7 @@
handler->HandleOutput("\n");
}
-#else
+#elif defined(HAVE_BACKTRACE)
bool printed = false;
// Below part is async-signal unsafe (uses malloc), so execute it only
@@ -469,23 +471,31 @@
StackTrace::StackTrace() {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+#else
+ count_ = 0;
+#endif
}
void StackTrace::Print() const {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
PrintBacktraceOutputHandler handler;
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
void StackTrace::OutputToStream(std::ostream* os) const {
+#if !defined(HAVE_BACKTRACE)
+(*os) << "(stack trace not supported)\n";
+#else
StreamBacktraceOutputHandler handler(os);
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
namespace internal {
@@ -1,190 +0,0 @@
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index bc43f53ed9..3eec1b7dd0 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -3264,7 +3264,8 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
copy = ngx_array_push_n(params->lengths,
@@ -3273,7 +3274,8 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].skip_empty;
diff --git a/src/http/modules/ngx_http_grpc_module.c b/src/http/modules/ngx_http_grpc_module.c
index 837ad9a2ea..300d927047 100644
--- a/src/http/modules/ngx_http_grpc_module.c
+++ b/src/http/modules/ngx_http_grpc_module.c
@@ -4389,7 +4389,8 @@ ngx_http_grpc_init_headers(ngx_conf_t *cf, ngx_http_grpc_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
size = (sizeof(ngx_http_script_copy_code_t)
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index c9ad638df9..e7f829d653 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -3493,7 +3493,8 @@ ngx_http_proxy_init_headers(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
size = (sizeof(ngx_http_script_copy_code_t)
diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c
index 3fb227b28c..9bd45bd136 100644
--- a/src/http/modules/ngx_http_scgi_module.c
+++ b/src/http/modules/ngx_http_scgi_module.c
@@ -1724,7 +1724,8 @@ ngx_http_scgi_init_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].key.len + 1;
copy = ngx_array_push_n(params->lengths,
@@ -1733,7 +1734,8 @@ ngx_http_scgi_init_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].skip_empty;
diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c
index 124da4db56..238bcf8a3b 100644
--- a/src/http/modules/ngx_http_uwsgi_module.c
+++ b/src/http/modules/ngx_http_uwsgi_module.c
@@ -1987,7 +1987,8 @@ ngx_http_uwsgi_init_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
copy = ngx_array_push_n(params->lengths,
@@ -1996,7 +1997,8 @@ ngx_http_uwsgi_init_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
return NGX_ERROR;
}
- copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
copy->len = src[i].skip_empty;
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index 96f3ec6965..1a87735617 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -695,7 +695,8 @@ ngx_http_script_add_copy_code(ngx_http_script_compile_t *sc, ngx_str_t *value,
return NGX_ERROR;
}
- code->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ code->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_len_code;
code->len = len;
size = (sizeof(ngx_http_script_copy_code_t) + len + sizeof(uintptr_t) - 1)
@@ -784,7 +785,8 @@ ngx_http_script_add_var_code(ngx_http_script_compile_t *sc, ngx_str_t *name)
return NGX_ERROR;
}
- code->code = (ngx_http_script_code_pt) ngx_http_script_copy_var_len_code;
+ code->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_var_len_code;
code->index = (uintptr_t) index;
code = ngx_http_script_add_code(*sc->values,
@@ -1178,8 +1180,8 @@ ngx_http_script_add_capture_code(ngx_http_script_compile_t *sc, ngx_uint_t n)
return NGX_ERROR;
}
- code->code = (ngx_http_script_code_pt)
- ngx_http_script_copy_capture_len_code;
+ code->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_copy_capture_len_code;
code->n = 2 * n;
@@ -1293,7 +1295,8 @@ ngx_http_script_add_full_name_code(ngx_http_script_compile_t *sc)
return NGX_ERROR;
}
- code->code = (ngx_http_script_code_pt) ngx_http_script_full_name_len_code;
+ code->code = (ngx_http_script_code_pt) (void *)
+ ngx_http_script_full_name_len_code;
code->conf_prefix = sc->conf_prefix;
code = ngx_http_script_add_code(*sc->values,
diff --git a/src/stream/ngx_stream_script.c b/src/stream/ngx_stream_script.c
index aa555ca2c1..b00e7086f7 100644
--- a/src/stream/ngx_stream_script.c
+++ b/src/stream/ngx_stream_script.c
@@ -587,7 +587,8 @@ ngx_stream_script_add_copy_code(ngx_stream_script_compile_t *sc,
return NGX_ERROR;
}
- code->code = (ngx_stream_script_code_pt) ngx_stream_script_copy_len_code;
+ code->code = (ngx_stream_script_code_pt) (void *)
+ ngx_stream_script_copy_len_code;
code->len = len;
size = (sizeof(ngx_stream_script_copy_code_t) + len + sizeof(uintptr_t) - 1)
@@ -677,8 +678,8 @@ ngx_stream_script_add_var_code(ngx_stream_script_compile_t *sc, ngx_str_t *name)
return NGX_ERROR;
}
- code->code = (ngx_stream_script_code_pt)
- ngx_stream_script_copy_var_len_code;
+ code->code = (ngx_stream_script_code_pt) (void *)
+ ngx_stream_script_copy_var_len_code;
code->index = (uintptr_t) index;
code = ngx_stream_script_add_code(*sc->values,
@@ -767,8 +768,8 @@ ngx_stream_script_add_capture_code(ngx_stream_script_compile_t *sc,
return NGX_ERROR;
}
- code->code = (ngx_stream_script_code_pt)
- ngx_stream_script_copy_capture_len_code;
+ code->code = (ngx_stream_script_code_pt) (void *)
+ ngx_stream_script_copy_capture_len_code;
code->n = 2 * n;
@@ -859,7 +860,7 @@ ngx_stream_script_add_full_name_code(ngx_stream_script_compile_t *sc)
return NGX_ERROR;
}
- code->code = (ngx_stream_script_code_pt)
+ code->code = (ngx_stream_script_code_pt) (void *)
ngx_stream_script_full_name_len_code;
code->conf_prefix = sc->conf_prefix;
-824
View File
@@ -1,824 +0,0 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
function usage() {
echo "
Usage: build_ngx_pagespeed.sh [options]
Installs ngx_pagespeed and its dependencies. Can optionally build and install
nginx as well. Can be run either as:
bash <(curl -f -L -sS https://ngxpagespeed.com/install) [options]
Or:
git clone git@github.com:pagespeed/ngx_pagespeed.git
cd ngx_pagespeed/
git checkout <branch>
scripts/build_ngx_pagespeed.sh [options]
Options:
-v, --ngx-pagespeed-version <ngx_pagespeed version>
What version of ngx_pagespeed to build. Valid options include:
* latest-beta
* latest-stable
* a version number, such as 1.11.33.4
If you don't specify a version, defaults to latest-stable unless --devel
is specified, in which case it defaults to master.
This option doesn't make sense if we're running within an existing
ngx_pagespeed checkout.
-n, --nginx-version <nginx version>
What version of nginx to build. If not set, this script only prepares the
ngx_pagespeed module, and expects you to handle including it when you
build nginx.
If you pass in 'latest' then this script scrapes the nginx download page
and attempts to determine the latest version automatically.
-m, --dynamic-module
Build ngx_pagespeed as a dynamic module.
-b, --builddir <directory>
Where to build. Defaults to \$HOME.
-p, --no-deps-check
By default, this script checks for the packages it depends on and tries to
install them. If you have installed dependencies from source or are on a
non-deb non-rpm system, this won't work. In that case, install the
dependencies yourself and pass --no-deps-check.
-s, --psol-from-source
Build PSOL from source instead of downloading a pre-built binary module.
-l, --devel
Sets up a development environment in ngx_pagespeed/nginx, building with
testing-only dependencies. Includes --psol-from-source, conflicts with
--nginx-version. Uses a 'git clone' checkout for ngx_pagespeed and nginx
instead of downloading a tarball.
-t, --build-type
When building PSOL from source, what to tell it for BUILD_TYPE. Defaults
to 'Release' unless --devel is set in which case it defaults to 'Debug'.
-y, --assume-yes
Assume the answer to all prompts is 'yes, please continue'. Intended for
automated usage, such as buildbots.
-a, --additional-nginx-configure-arguments
When running ./configure for nginx, you may want to specify additional
arguments, such as --with-http_ssl_module. By default this script will
pause and prompt you for them, but this option lets you pass them in. For
example, you might do:
-a '--with-http_ssl_module --with-cc-opt=\"-I /usr/local/include\"'
-d, --dryrun
Don't make any changes to the system, just print what changes you
would have made.
-h, --help
Print this message and exit."
}
RED=31
GREEN=32
YELLOW=33
function begin_color() {
color="$1"
echo -e -n "\e[${color}m"
}
function end_color() {
echo -e -n "\e[0m"
}
function echo_color() {
color="$1"
shift
begin_color "$color"
echo "$@"
end_color
}
function error() {
local error_message="$@"
echo_color "$RED" -n "Error: " >&2
echo "$@" >&2
}
# Prints an error message and exits with an error code.
function fail() {
error "$@"
# Normally I'd use $0 in "usage" here, but since most people will be running
# this via curl, that wouldn't actually give something useful.
echo >&2
echo "For usage information, run this script with --help" >&2
exit 1
}
function status() {
echo_color "$GREEN" "$@"
}
# Intended to be called as:
# bash <(curl dl.google.com/.../build_ngx_pagespeed.sh) <args>
# If we set -e or -u then users of this script will see it silently exit on
# failure. Instead we need to check the exit status of each command manually.
# The run function handles exit-status checking for system-changing commands.
# Additionally, this allows us to easily have a dryrun mode where we don't
# actually make any changes.
INITIAL_ENV=$(printenv | sort)
function run() {
if "$DRYRUN"; then
echo_color "$YELLOW" -n "would run"
echo " $@"
env_differences=$(comm -13 <(echo "$INITIAL_ENV") <(printenv | sort))
if [ -n "$env_differences" ]; then
echo " with the following additional environment variables:"
echo "$env_differences" | sed 's/^/ /'
fi
else
if ! "$@"; then
error "Failure running '$@', exiting."
exit 1
fi
fi
}
function redhat_is_installed() {
local package_name="$1"
rpm -qa $package_name | grep -q .
}
function debian_is_installed() {
local package_name="$1"
dpkg -l $package_name | grep ^ii | grep -q .
}
function version_sort() {
# We'd rather use sort -V, but that's not available on Centos 5. This works
# for versions in the form A.B.C.D or shorter, which is enough for our use.
sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g
}
# Compare two numeric versions in the form "A.B.C". Works with version numbers
# having up to four components, since that's enough to handle both nginx (3) and
# ngx_pagespeed (4).
function version_older_than() {
local test_version="$1"
local compare_to="$2"
local older_version=$(echo $@ | tr ' ' '\n' | version_sort | head -n 1)
test "$older_version" != "$compare_to"
}
function determine_latest_nginx_version() {
# Scrape nginx's download page to try to find the most recent nginx version.
nginx_download_url="https://nginx.org/en/download.html"
function report_error() {
fail "
Couldn't automatically determine the latest nginx version: failed to $@
$nginx_download_url"
}
nginx_download_page=$(curl -sS --fail "$nginx_download_url") || \
report_error "download"
download_refs=$(echo "$nginx_download_page" | \
grep -o '/download/nginx-[0-9.]*[.]tar[.]gz') || \
report_error "parse"
versions_available=$(echo "$download_refs" | \
sed -e 's~^/download/nginx-~~' -e 's~\.tar\.gz$~~') || \
report_error "extract versions from"
latest_version=$(echo "$versions_available" | version_sort | tail -n 1) || \
report_error "determine latest version from"
if version_older_than "$latest_version" "1.11.4"; then
fail "
Expected the latest version of nginx to be at least 1.11.4 but found
$latest_version on $nginx_download_url"
fi
echo "$latest_version"
}
# Usage:
# install_dependencies install_pkg_cmd is_pkg_installed_cmd dep1 dep2 ...
#
# install_pkg_cmd is a command to install a dependency
# is_pkg_installed_cmd is a command that returns true if the dependency is
# already installed
# each dependency is a package name
function install_dependencies() {
local install_pkg_cmd="$1"
local is_pkg_installed_cmd="$2"
shift 2
local missing_dependencies=""
for package_name in "$@"; do
if ! $is_pkg_installed_cmd $package_name; then
missing_dependencies+="$package_name "
fi
done
if [ -n "$missing_dependencies" ]; then
status "Detected that we're missing the following depencencies:"
echo " $missing_dependencies"
status "Installing them:"
run sudo $install_pkg_cmd $missing_dependencies
fi
}
function gcc_too_old() {
# We need gcc >= 4.8
local gcc_major_version=$(gcc -dumpversion | awk -F. '{print $1}')
if [ "$gcc_major_version" -lt 4 ]; then
return 0 # too old
elif [ "$gcc_major_version" -gt 4 ]; then
return 1 # plenty new
fi
# It's gcc 4.x, check if x >= 8:
local gcc_minor_version=$(gcc -dumpversion | awk -F. '{print $2}')
test "$gcc_minor_version" -lt 8
}
function continue_or_exit() {
if "$ASSUME_YES"; then
return
fi
local prompt="$1"
echo_color "$YELLOW" -n "$prompt"
read -p " [Y/n] " yn
if [[ "$yn" == N* || "$yn" == n* ]]; then
echo "Cancelled."
exit 0
fi
}
# If a string is very simple we don't need to quote it. But we should quote
# everything else to be safe.
function needs_quoting() {
echo "$@" | grep -q '[^a-zA-Z0-9./_=-]'
}
function escape_for_quotes() {
echo "$@" | sed -e 's~\\~\\\\~g' -e "s~'~\\\\'~g"
}
function quote_arguments() {
local argument_str=""
for argument in "$@"; do
if [ -n "$argument_str" ]; then
argument_str+=" "
fi
if needs_quoting "$argument"; then
argument="'$(escape_for_quotes "$argument")'"
fi
argument_str+="$argument"
done
echo "$argument_str"
}
function build_ngx_pagespeed() {
getopt --test
if [ "$?" != 4 ]; then
# Even Centos 5 and Ubuntu 10 LTS have new-style getopt, so I don't expect
# this to be hit in practice on systems that are actually able to run
# PageSpeed.
fail "Your version of getopt is too old. Exiting with no changes made."
fi
opts=$(getopt -o v:n:mb:pslt:ya:dh \
--longoptions ngx-pagespeed-version:,nginx-version:,dynamic-module \
--longoptions buildir:,no-deps-check,psol-from-source,devel,build-type: \
--longoptions assume-yes,additional-nginx-configure-arguments:,dryrun,help \
-n "$(basename "$0")" -- "$@")
if [ $? != 0 ]; then
usage
exit 1
fi
eval set -- "$opts"
NPS_VERSION="DEFAULT"
NGINX_VERSION=""
BUILDDIR="$HOME"
DO_DEPS_CHECK=true
PSOL_FROM_SOURCE=false
DEVEL=false
BUILD_TYPE=""
ASSUME_YES=false
DRYRUN=false
DYNAMIC_MODULE=false
while true; do
case "$1" in
-v | --ngx-pagespeed-version) shift
NPS_VERSION="$1"
shift
;;
-n | --nginx-version) shift
NGINX_VERSION="$1"
shift
;;
-m | --dynamic-module) shift
DYNAMIC_MODULE=true
;;
-b | --builddir) shift
BUILDDIR="$1"
shift
;;
-p | --no-deps-check) shift
DO_DEPS_CHECK=false
;;
-s | --psol-from-source) shift
PSOL_FROM_SOURCE=true
;;
-l | --devel) shift
DEVEL=true
;;
-t | --build-type) shift
BUILD_TYPE="$1"
shift
;;
-y | --assume-yes) shift
ASSUME_YES="true"
;;
-a | --additional-nginx-configure-arguments) shift
ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS="$1"
shift
;;
-d | --dryrun) shift
DRYRUN="true"
;;
-h | --help) shift
usage
exit 0
;;
--) shift
break
;;
*)
echo "Invalid argument: $1"
usage
exit 1
;;
esac
done
USE_GIT_CHECKOUT="$DEVEL"
ALREADY_CHECKED_OUT=false
if [ -e PSOL_BINARY_URL ]; then
status "Detected that we're running in an existing ngx_pagespeed checkout."
USE_GIT_CHECKOUT=true
ALREADY_CHECKED_OUT=true
fi
if "$ALREADY_CHECKED_OUT"; then
if [ "$NPS_VERSION" != "DEFAULT" ]; then
fail \
"The --ngx-pagespeed-version argument doesn't make sense when running within an existing checkout."
fi
elif [ "$NPS_VERSION" = "DEFAULT" ]; then
if "$DEVEL"; then
NPS_VERSION="master"
else
NPS_VERSION="latest-stable"
fi
fi
if [ ! -d "$BUILDDIR" ]; then
fail "Told to build in $BUILDDIR, but that directory doesn't exist."
fi
BUILD_NGINX=false
if [ -n "$NGINX_VERSION" ]; then
BUILD_NGINX=true
fi
if "$DEVEL"; then
PSOL_FROM_SOURCE=true
BUILD_NGINX=true
if [ -n "$NGINX_VERSION" ]; then
fail \
"The --devel argument conflicts with --nginx. In devel mode we use the version of nginx that's included as a submodule."
fi
if "$DYNAMIC_MODULE"; then
fail "Can't currently build a dynamic module in --devel mode."
fi
fi
if "$PSOL_FROM_SOURCE" && [ -z "$BUILD_TYPE" ]; then
if "$DEVEL"; then
BUILD_TYPE="Debug"
else
BUILD_TYPE="Release"
fi
elif [ -n "$BUILD_TYPE" ]; then
fail "Setting --build-type requires --psol-from-source or --devel."
fi
if [ "$NGINX_VERSION" = "latest" ]; then
# When this function fails it prints the debugging information needed first
# to stderr.
NGINX_VERSION=$(determine_latest_nginx_version) || exit 1
fi
if "$DYNAMIC_MODULE"; then
# Check that ngx_pagespeed and nginx are recent enough to support dynamic
# modules. Unfortunately NPS_VERSION might be a tag, in which case we don't
# know. If it's not a numeric version number, then assume it's recent
# enough and if it's not they'll get an ugly compilation error later.
# Luckily 1.10.33.5 was a while ago now.
#
# I'd like to use =~ here, but they changed syntax between v3 and v4 (quotes
# moved from mandatory to optional to prohibited).
if [[ "${NPS_VERSION#*[^0-9.]}" = "$NPS_VERSION" ]] &&
version_older_than "$NPS_VERSION" "1.10.33.5"; then
fail "
You're trying to build ngx_pagespeed $NPS_VERSION as a dynamic module, but
ngx_pagespeed didn't add support for dynamic modules until 1.10.33.5."
fi
if [ ! -z "NGINX_VERSION" ]; then
if version_older_than "$NGINX_VERSION" "1.9.13"; then
fail "
You're trying to build nginx $NGINX_VERSION as a dynamic module but nginx didn't
add support for dynamic modules in a way compatible with ngx_pagespeed until
1.9.13."
fi
fi
fi
if "$DRYRUN"; then
TEMPDIR="/tmp/output-of-mktemp"
else
TEMPDIR=$(mktemp -d)
function cleanup_tempdir {
rm -rf "$TEMPDIR"
}
trap cleanup_tempdir EXIT
fi
extra_flags=()
# Now make sure our dependencies are installed.
if "$DO_DEPS_CHECK"; then
INSTALL_FLAGS=""
if "$ASSUME_YES"; then
INSTALL_FLAGS="-y"
fi
if [ -f /etc/debian_version ]; then
status "Detected debian-based distro."
install_dependencies "apt-get install ${INSTALL_FLAGS}" debian_is_installed \
build-essential zlib1g-dev libpcre3 libpcre3-dev unzip wget uuid-dev
if gcc_too_old; then
if [ ! -e /usr/lib/gcc-mozilla/bin/gcc ]; then
status "Detected that gcc is older than 4.8. Installing gcc-mozilla"
status "which installs gcc-4.8 into /usr/lib/gcc-mozilla/ and doesn't"
status "affect your global gcc installation."
run sudo apt-get install ${INSTALL_FLAGS} gcc-mozilla
fi
extra_flags=("--with-cc=/usr/lib/gcc-mozilla/bin/gcc" \
"--with-ld-opt=-static-libstdc++")
fi
elif [ -f /etc/redhat-release ]; then
status "Detected redhat-based distro."
install_dependencies "yum install ${INSTALL_FLAGS}" redhat_is_installed \
gcc-c++ pcre-devel zlib-devel make unzip wget libuuid-devel
if gcc_too_old; then
if [ ! -e /opt/rh/devtoolset-2/root/usr/bin/gcc ]; then
redhat_major_version=$(
cat /etc/redhat-release | grep -o -E '[0-9]+' | head -n 1)
if [ "$redhat_major_version" == 5 ]; then
slc_version=5
elif [ "$redhat_major_version" == 6 ]; then
slc_version=6
else
fail "
Unexpected major version $redhat_major_version in /etc/redhat-release:
$(cat /etc/redhat-release) Expected 5 or 6."
fi
status "Detected that gcc is older than 4.8. Scientific Linux"
status "provides a gcc package that installs gcc-4.8 into /opt/ and"
status "doesn't affect your global gcc installation."
slc_key="https://linux.web.cern.ch/linux/scientific6/docs/repository/"
slc_key+="cern/slc6X/i386/RPM-GPG-KEY-cern"
slc_key_out="$TEMPDIR/RPM-GPG-KEY-cern"
run sudo wget "$slc_key" -O "$slc_key_out"
run sudo rpm --import "$slc_key_out"
repo_fname="/etc/yum.repos.d/slc${slc_version}-devtoolset.repo"
if [ -e "$repo_fname" ]; then
fail "Expected $repo_fname not to exist; aborting."
fi
repo_url="https://linux.web.cern.ch/linux/scientific${slc_version}/"
repo_url+="/docs/repository/cern/devtoolset/"
repo_url+="slc${slc_version}-devtoolset.repo"
run sudo wget -O "$repo_fname" "$repo_url"
run sudo yum install ${INSTALL_FLAGS} devtoolset-2-gcc-c++ devtoolset-2-binutils
fi
extra_flags=("--with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc")
fi
else
fail "
This doesn't appear to be a deb-based distro or an rpm-based one. Not going to
be able to install dependencies. Please install dependencies manually and rerun
with --no-deps-check."
fi
status "Operating system dependencies are all set."
else
status "Not checking whether operating system dependencies are installed."
fi
function delete_if_already_exists() {
if "$DRYRUN"; then return; fi
local directory="$1"
if [ -d "$directory" ]; then
if [ ${#directory} -lt 8 ]; then
fail "
Not deleting $directory; name is suspiciously short. Something is wrong."
fi
continue_or_exit "OK to delete $directory?"
run rm -rf "$directory"
fi
}
# In general, the zip github builds for tag foo unzips to ngx_pagespeed-foo,
# but it looks like they special case vVERSION tags to ngx_pagespeed-VERSION
if [[ "$NPS_VERSION" =~ ^[0-9]*[.][0-9]*[.][0-9]*[.][0-9]*$ ]]; then
# We've been given a numeric version number. This has an associated tag
# in the form vVERSION-beta.
tag_name="v${NPS_VERSION}-beta"
nps_downloaded_fname="ngx_pagespeed-${NPS_VERSION}-beta"
else
# We've been given a tag name, like latest-beta. Download that directly.
tag_name="$NPS_VERSION"
nps_downloaded_fname="ngx_pagespeed-${NPS_VERSION}"
fi
install_dir="this-only-makes-sense-in-devel-mode"
if "$USE_GIT_CHECKOUT"; then
# We're either doing a --devel build, or someone is running us from an
# existing git checkout.
nps_module_dir="$PWD"
install_dir="$nps_module_dir"
if "$ALREADY_CHECKED_OUT"; then
run cd "$nps_module_dir"
else
status "Checking out ngx_pagespeed..."
run git clone "git@github.com:pagespeed/ngx_pagespeed.git" \
"$nps_module_dir"
run cd "$nps_module_dir"
run git checkout "$tag_name"
fi
submodules_dir="$nps_module_dir/testing-dependencies"
if "$DEVEL"; then
status "Downloading dependencies..."
run git submodule update --init --recursive
if [[ "$CONTINUOUS_INTEGRATION" != true ]]; then
status "Switching submodules over to git protocol."
# This lets us push to github by public key.
for config in $(find .git/ -name config) ; do
run sed -i s~https://github.com/~git@github.com:~ $config ;
done
fi
fi
else
nps_baseurl="https://github.com/apache/incubator-pagespeed-ngx/archive"
nps_downloaded="$TEMPDIR/$nps_downloaded_fname.zip"
status "Downloading ngx_pagespeed..."
run wget "$nps_baseurl/$tag_name.zip" -O "$nps_downloaded"
# Read the directory name from the zip, the first line is expected to have it.
nps_module_dir=$(unzip -qql "$nps_downloaded" | head -n1 | tr -s ' ' | cut -d' ' -f5-)
nps_module_dir="$BUILDDIR/${nps_module_dir::-1}"
delete_if_already_exists "$nps_module_dir"
status "Extracting ngx_pagespeed..."
run unzip -q "$nps_downloaded" -d "$BUILDDIR"
run cd "$nps_module_dir"
fi
MOD_PAGESPEED_DIR=""
PSOL_BINARY=""
if "$PSOL_FROM_SOURCE"; then
MOD_PAGESPEED_DIR="$PWD/testing-dependencies/mod_pagespeed"
git submodule update --init --recursive -- "$MOD_PAGESPEED_DIR"
run pushd "$MOD_PAGESPEED_DIR"
if "$DEVEL"; then
if [ ! -d "$HOME/apache2" ]; then
run install/build_development_apache.sh 2.2 prefork
fi
cd devel
run make apache_debug_psol
PSOL_BINARY="$MOD_PAGESPEED_DIR/out/$BUILD_TYPE/pagespeed_automatic.a"
else
if "$DO_DEPS_CHECK"; then
skip_deps_arg=""
else
skip_deps_arg="--skip_deps"
fi
run install/build_psol.sh --skip_tests --skip_packaging "$skip_deps_arg"
PSOL_BINARY="$MOD_PAGESPEED_DIR/pagespeed/automatic/pagespeed_automatic.a"
fi
run popd
else
# Now we need to figure out what precompiled version of PSOL to build
# ngx_pagespeed against.
if "$DRYRUN"; then
psol_url="https://psol.example.com/cant-get-psol-version-in-dry-run.tar.gz"
elif [ -e PSOL_BINARY_URL ]; then
# Releases after 1.11.33.4 there is a PSOL_BINARY_URL file that tells us
# where to look.
psol_url="$(scripts/format_binary_url.sh PSOL_BINARY_URL)"
if [[ "$psol_url" != https://* ]]; then
fail "Got bad psol binary location information: $psol_url"
fi
else
# For past releases we have to grep it from the config file. The url has
# always looked like this, and the config file has contained it since
# before we started tagging our ngx_pagespeed releases.
psol_url="$(grep -o \
"https://dl.google.com/dl/page-speed/psol/[0-9.]*.tar.gz" config)"
if [ -z "$psol_url" ]; then
fail "Couldn't find PSOL url in $PWD/config"
fi
fi
status "Downloading PSOL binary..."
run wget "$psol_url"
status "Extracting PSOL..."
run tar -xzf $(basename "$psol_url") # extracts to psol/
fi
if "$DYNAMIC_MODULE"; then
add_module="--add-dynamic-module=$nps_module_dir"
else
add_module="--add-module=$nps_module_dir"
fi
configure_args=("$add_module" "${extra_flags[@]}")
if "$DEVEL"; then
configure_args=("${configure_args[@]}"
"--prefix=$install_dir/nginx"
"--add-module=$submodules_dir/ngx_cache_purge"
"--add-module=$submodules_dir/ngx_devel_kit"
"--add-module=$submodules_dir/set-misc-nginx-module"
"--add-module=$submodules_dir/headers-more-nginx-module"
"--with-ipv6"
"--with-http_v2_module")
if [ "$BUILD_TYPE" = "Debug" ]; then
configure_args=("${configure_args[@]}" "--with-debug")
fi
fi
echo
if ! "$BUILD_NGINX"; then
# Just prepare the module for them to install.
status "ngx_pagespeed is ready to be built against nginx."
echo "When running ./configure:"
if "$PSOL_FROM_SOURCE"; then
echo " Set the following environment variables:"
echo " MOD_PAGESPEED_DIR=$MOD_PAGESPEED_DIR"
echo " PSOL_BINARY=$PSOL_BINARY"
fi
echo " Give ./configure the following arguments:"
echo " $(quote_arguments "${configure_args[@]}")"
echo
if [ ${#extra_flags[@]} -eq 0 ]; then
echo "If this is for integration with an already-built nginx, make sure"
echo "to include any other arguments you originally passed to"
echo "./configure. You can see these with 'nginx -V'."
else
echo "Note: because we need to set $(quote_arguments "${extra_flags[@]}")"
echo "on this platform, if you want to integrate ngx_pagespeed with an"
echo "already-built nginx you're going to need to rebuild your nginx with"
echo "those flags set."
fi
else
if "$DEVEL"; then
# Use the nginx we loaded as a submodule
nginx_dir="$submodules_dir/nginx"
configure_location="auto"
else
# Download and build the specified nginx version.
nginx_leaf="nginx-${NGINX_VERSION}.tar.gz"
nginx_fname="$TEMPDIR/$nginx_leaf"
status "Downloading nginx..."
run wget "http://nginx.org/download/$nginx_leaf" -O "$nginx_fname"
nginx_dir="$BUILDDIR/nginx-${NGINX_VERSION}/"
delete_if_already_exists "$nginx_dir"
status "Extracting nginx..."
run tar -xzf "$nginx_fname" --directory "$BUILDDIR"
configure_location="."
fi
run cd "$nginx_dir"
configure=("$configure_location/configure" "${configure_args[@]}")
additional_configure_args=""
if [ -z "${ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS+x}" ]; then
if ! "$ASSUME_YES"; then
echo "About to build nginx. Do you have any additional ./configure"
echo "arguments you would like to set? For example, if you would like"
echo "to build nginx with https support give --with-http_ssl_module"
echo "If you don't have any, just press enter."
read -p "> " additional_configure_args
fi
else
additional_configure_args="$ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS"
fi
if [ -n "$additional_configure_args" ]; then
# Split additional_configure_args respecting any internal quotation.
# Otherwise things like --with-cc-opt='-foo -bar' won't work.
eval additional_configure_args=("$additional_configure_args")
configure=("${configure[@]}" "${additional_configure_args[@]}")
fi
echo "About to configure nginx with:"
echo " $(quote_arguments "${configure[@]}")"
continue_or_exit "Does this look right?"
MOD_PAGESPEED_DIR="$MOD_PAGESPEED_DIR" \
PSOL_BINARY="$PSOL_BINARY" \
run "${configure[@]}"
if ! "$DEVEL"; then
continue_or_exit "Build nginx?"
fi
run make
if "$DEVEL"; then
run make install
status "Nginx installed with ngx_pagespeed, and set up for development."
echo "To run tests:"
echo " cd $nps_module_dir"
echo " test/run_tests.sh"
echo
echo "To rebuild after changes:"
echo " scripts/rebuild.sh"
else
continue_or_exit "Install nginx?"
run sudo make install
echo
if "$DYNAMIC_MODULE"; then
echo "Nginx installed with ngx_pagespeed support available as a"
echo "loadable module."
echo
echo "To load the ngx_pagespeed module, you'll need to add:"
echo " load_module \"modules/ngx_pagespeed.so\";"
echo "at the top of your main nginx configuration file."
else
echo "Nginx installed with ngx_pagespeed support compiled-in."
fi
echo
echo "If this is a new installation you probably need an init script to"
echo "manage starting and stopping the nginx service. See:"
echo " http://wiki.nginx.org/InitScripts"
echo
echo "You'll also need to configure ngx_pagespeed if you haven't yet:"
echo " https://developers.google.com/speed/pagespeed/module/configuration"
fi
fi
if "$DRYRUN"; then
echo_color "$YELLOW" "[this was a dry run; your system is unchanged]"
fi
}
# Start running things from a call at the end so if this script is executed
# after a partial download it doesn't do anything.
build_ngx_pagespeed "$@"
-40
View File
@@ -1,40 +0,0 @@
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -e
set -u
if [ $# -ne 1 ]; then
echo "Usage: $(basename $0) <url_file>" >&2
exit 1
fi
url_file=$1
if [ ! -e "$url_file" ]; then
echo "Url file '$url_file' missing!" >&2
fi
# The size names must match install/build_psol.sh in mod_pagespeed
if [ "$(uname -m)" = x86_64 ]; then
bit_size_name=x64
else
bit_size_name=ia32
fi
sed -e 's/$BIT_SIZE_NAME/'$bit_size_name'/g' $url_file
+6 -19
View File
@@ -1,32 +1,19 @@
#!/bin/bash #!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one #
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Converts pagespeed_libraries.conf from Apache-format to Nginx-format, # Converts pagespeed_libraries.conf from Apache-format to Nginx-format,
# supporting the canonicalize_javascript_libraries filter. # supporting the canonicalize_javascript_libraries filter.
# Inspired by https://github.com/apache/incubator-pagespeed-ngx/issues/532 # Inspired by https://github.com/pagespeed/ngx_pagespeed/issues/532
# #
# Usage: # Usage:
# scripts/pagespeed_libraries_generator.sh > pagespeed_libraries.conf # scripts/pagespeed_libraries_generator.sh > pagespeed_libraries.conf
# #
# Then have nginx include that configuration file and enable the filter # Then have nginx include that configuration file and enable the filter
# canonicalize_javascript_libraries. # canonicalize_javascript_libraries.
#
# Author: vid@zippykid.com (Vid Luther)
# jefftk@google.com (Jeff Kaufman)
URL="https://github.com/apache/incubator-pagespeed-mod/raw/master/" URL="https://github.com/pagespeed/mod_pagespeed/raw/master/"
URL+="net/instaweb/genfiles/conf/pagespeed_libraries.conf" URL+="net/instaweb/genfiles/conf/pagespeed_libraries.conf"
curl -L -s -S "$URL" \ curl -L -s -S "$URL" \
| grep ModPagespeedLibrary \ | grep ModPagespeedLibrary \
+94
View File
@@ -0,0 +1,94 @@
#!/bin/bash
#
# Copyright 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: jefftk@google.com (Jeff Kaufman)
#
# Usage:
# scripts/prepare_psol.sh /path/to/mod_pagespeed/src
#
# Creates a directory psol/ and copies headers and a few source files from a
# depot_tools (glient) checkout into psol/include. Along with creating
# binaries, this is a step in preparing psol.tar.gz for distribution.
#
set -u # check for undefined variables
set -e # exit on failed commands
if [ "$(basename "$PWD")" != "ngx_pagespeed" ] ; then
echo "$(basename $0) must be invoked from the ngx_pagespeed directory"
exit 1
fi
if [ $# -ne 1 ] ; then
echo "Usage: $(basename $0) /path/to/mod_pagespeed/src"
exit 1
fi
MOD_PAGESPEED_SRC="$1"
if [ "$(basename "$(dirname "$MOD_PAGESPEED_SRC")")/$( \
basename "$MOD_PAGESPEED_SRC")" != "mod_pagespeed/src" ] ; then
echo "Usage: $(basename $0) /path/to/mod_pagespeed/src"
exit 1
fi
if [ -e psol ] ; then
echo "A psol/ directory already exists. Move it somewhere else and rerun."
exit 1
fi
mkdir psol/
# Copy over the .h files, plus a few selected .cc and .c files.
rsync -arvz "$MOD_PAGESPEED_SRC/" "psol/include/" --prune-empty-dirs \
--exclude=".svn" \
--exclude=".git" \
--include='*.h' \
--include='*/' \
--include="apr_thread_compatible_pool.cc" \
--include="serf_url_async_fetcher.cc" \
--include="apr_mem_cache.cc" \
--include="key_value_codec.cc" \
--include="apr_memcache2.c" \
--include="loopback_route_fetcher.cc" \
--include="add_headers_fetcher.cc" \
--include="console_css_out.cc" \
--include="console_out.cc" \
--include="dense_hash_map" \
--include="dense_hash_set" \
--include="sparse_hash_map" \
--include="sparse_hash_set" \
--include="sparsetable" \
--include="mod_pagespeed_console_out.cc" \
--include="mod_pagespeed_console_css_out.cc" \
--include="mod_pagespeed_console_html_out.cc" \
--exclude='*'
mkdir -p psol/lib/Debug/linux/ia32
mkdir -p psol/lib/Debug/linux/x64
mkdir -p psol/lib/Release/linux/ia32
mkdir -p psol/lib/Release/linux/x64
# Log that we did this.
SVN_REVISION="$(svn info $MOD_PAGESPEED_SRC | grep Revision | awk '{print $2}')"
SVN_TAG="$(svn info $MOD_PAGESPEED_SRC | grep URL | awk -F/ '{print $(NF-1)}')"
DATE="$(date +%F)"
echo "${DATE}: Copied from mod_pagespeed ${SVN_TAG}@r${SVN_REVISION} ($USER)" \
>> psol/include_history.txt
echo
echo "Output is in psol/include. Now put binaries in psol/lib following"
echo "https://github.com/pagespeed/ngx_pagespeed/wiki/Building-Release-Binaries"
echo "and then you can distribute PSOL."
-37
View File
@@ -1,37 +0,0 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Usage: scripts/rebuild.sh
#
# After building with "scripts/build_ngx_pagespeed.sh --devel", if you make
# changes to ngx_pagespeed you'll need to rebuild it. The underlying commands
# aren't complicated, but it's faster to work if it's automated.
set -e # exit script if any command returns an error
set -u # exit the script if any variable is uninitialized
this_dir="$(dirname $0)"
cd "$this_dir/.."
nps_dir="$PWD"
cd "$nps_dir/testing-dependencies/mod_pagespeed/devel"
make apache_debug_psol
cd "$nps_dir/testing-dependencies/nginx/"
make
make install
+17 -20
View File
@@ -1,23 +1,20 @@
/* // Copyright 2010 Google Inc.
* Licensed to the Apache Software Foundation (ASF) under one //
* or more contributor license agreements. See the NOTICE file // Licensed under the Apache License, Version 2.0 (the "License");
* distributed with this work for additional information // you may not use this file except in compliance with the License.
* regarding copyright ownership. The ASF licenses this file // You may obtain a copy of the License at
* to you under the Apache License, Version 2.0 (the //
* "License"); you may not use this file except in compliance // http://www.apache.org/licenses/LICENSE-2.0
* with the License. You may obtain a copy of the License at //
* // Unless required by applicable law or agreed to in writing, software
* http://www.apache.org/licenses/LICENSE-2.0 // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* Unless required by applicable law or agreed to in writing, // See the License for the specific language governing permissions and
* software distributed under the License is distributed on an // limitations under the License.
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY //
* KIND, either express or implied. See the License for the // Author: jmarantz@google.com (Joshua Marantz)
* specific language governing permissions and limitations // Author: sligocki@google.com (Shawn Ligocki)
* under the License. // Author: jefftk@google.com (Jeff Kaufman)
*/
// TODO(jefftk): share more of this code with apache's log_message_handler // TODO(jefftk): share more of this code with apache's log_message_handler
+17 -20
View File
@@ -1,23 +1,20 @@
/* // Copyright 2010 Google Inc.
* Licensed to the Apache Software Foundation (ASF) under one //
* or more contributor license agreements. See the NOTICE file // Licensed under the Apache License, Version 2.0 (the "License");
* distributed with this work for additional information // you may not use this file except in compliance with the License.
* regarding copyright ownership. The ASF licenses this file // You may obtain a copy of the License at
* to you under the Apache License, Version 2.0 (the //
* "License"); you may not use this file except in compliance // http://www.apache.org/licenses/LICENSE-2.0
* with the License. You may obtain a copy of the License at //
* // Unless required by applicable law or agreed to in writing, software
* http://www.apache.org/licenses/LICENSE-2.0 // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* Unless required by applicable law or agreed to in writing, // See the License for the specific language governing permissions and
* software distributed under the License is distributed on an // limitations under the License.
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY //
* KIND, either express or implied. See the License for the // Author: jmarantz@google.com (Joshua Marantz)
* specific language governing permissions and limitations // Author: sligocki@google.com (Shawn Ligocki)
* under the License. // Author: jefftk@google.com (Jeff Kaufman)
*/
#ifndef LOG_MESSAGE_HANDLER_H_ #ifndef LOG_MESSAGE_HANDLER_H_
#define LOG_MESSAGE_HANDLER_H_ #define LOG_MESSAGE_HANDLER_H_
+21 -28
View File
@@ -1,23 +1,21 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the *
* specific language governing permissions and limitations * Author: jefftk@google.com (Jeff Kaufman)
* under the License.
*/ */
#include "ngx_pagespeed.h" // Must come first, see comments in CollectHeaders. #include "ngx_pagespeed.h" // Must come first, see comments in CollectHeaders.
#include <unistd.h> //for usleep #include <unistd.h> //for usleep
@@ -26,6 +24,8 @@
#include "ngx_event_connection.h" #include "ngx_event_connection.h"
#include "ngx_list_iterator.h" #include "ngx_list_iterator.h"
#include "ngx_pagespeed.h"
#include "net/instaweb/rewriter/public/rewrite_driver.h" #include "net/instaweb/rewriter/public/rewrite_driver.h"
#include "net/instaweb/rewriter/public/rewrite_options.h" #include "net/instaweb/rewriter/public/rewrite_options.h"
#include "net/instaweb/rewriter/public/rewrite_stats.h" #include "net/instaweb/rewriter/public/rewrite_stats.h"
@@ -55,7 +55,6 @@ NgxBaseFetch::NgxBaseFetch(StringPiece url,
request_(r), request_(r),
server_context_(server_context), server_context_(server_context),
options_(options), options_(options),
need_flush_(false),
done_called_(false), done_called_(false),
last_buf_sent_(false), last_buf_sent_(false),
references_(2), references_(2),
@@ -91,7 +90,7 @@ void NgxBaseFetch::Terminate() {
NgxBaseFetch::active_base_fetches); NgxBaseFetch::active_base_fetches);
// Try to continue processing and get the active base fetch count to 0 // Try to continue processing and get the active base fetch count to 0
// until the timeout expires. // untill the timeout expires.
// TODO(oschaaf): This needs more work. // TODO(oschaaf): This needs more work.
while (NgxBaseFetch::active_base_fetches > 0 && end_us > timer.NowUs()) { while (NgxBaseFetch::active_base_fetches > 0 && end_us > timer.NowUs()) {
event_connection->Drain(); event_connection->Drain();
@@ -154,7 +153,7 @@ void NgxBaseFetch::ReadCallback(const ps_event_data& data) {
ps_request_ctx_t* ctx = ps_get_request_context(r); ps_request_ctx_t* ctx = ps_get_request_context(r);
// If our request context was zeroed, skip this event. // If our request context was zeroed, skip this event.
// See https://github.com/apache/incubator-pagespeed-ngx/issues/1081 // See https://github.com/pagespeed/ngx_pagespeed/issues/1081
if (ctx == NULL) { if (ctx == NULL) {
// Should not happen normally, when it does this message will cause our // Should not happen normally, when it does this message will cause our
// system tests to fail. // system tests to fail.
@@ -230,11 +229,8 @@ ngx_int_t NgxBaseFetch::CopyBufferToNginx(ngx_chain_t** link_ptr) {
return NGX_AGAIN; return NGX_AGAIN;
} }
int rc = string_piece_to_buffer_chain(request_->pool, buffer_, link_ptr, int rc = string_piece_to_buffer_chain(
done_called_ /* send_last_buf */, request_->pool, buffer_, link_ptr, done_called_ /* send_last_buf */);
need_flush_);
need_flush_ = false;
if (rc != NGX_OK) { if (rc != NGX_OK) {
return rc; return rc;
} }
@@ -319,9 +315,6 @@ void NgxBaseFetch::HandleHeadersComplete() {
} }
bool NgxBaseFetch::HandleFlush(MessageHandler* handler) { bool NgxBaseFetch::HandleFlush(MessageHandler* handler) {
Lock();
need_flush_ = true;
Unlock();
RequestCollection(kFlush); // A new part of the response body is available RequestCollection(kFlush); // A new part of the response body is available
return true; return true;
} }
+15 -19
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
// //
// Collects output from pagespeed and buffers it until nginx asks for it. // Collects output from pagespeed and buffers it until nginx asks for it.
// Notifies nginx via NgxEventConnection to call ReadCallback() when // Notifies nginx via NgxEventConnection to call ReadCallback() when
@@ -134,7 +131,7 @@ class NgxBaseFetch : public AsyncFetch {
ngx_http_request_t* request() { return request_; } ngx_http_request_t* request() { return request_; }
NgxBaseFetchType base_fetch_type() { return base_fetch_type_; } NgxBaseFetchType base_fetch_type() { return base_fetch_type_; }
bool IsCachedResultValid(const ResponseHeaders& headers) override; virtual bool IsCachedResultValid(const ResponseHeaders& headers);
private: private:
virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler); virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler);
@@ -172,7 +169,6 @@ class NgxBaseFetch : public AsyncFetch {
GoogleString buffer_; GoogleString buffer_;
NgxServerContext* server_context_; NgxServerContext* server_context_;
const RewriteOptions* options_; const RewriteOptions* options_;
bool need_flush_;
bool done_called_; bool done_called_;
bool last_buf_sent_; bool last_buf_sent_;
// How many active references there are to this fetch. Starts at two, // How many active references there are to this fetch. Starts at two,
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2013 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#include "ngx_caching_headers.h" #include "ngx_caching_headers.h"
#include "ngx_list_iterator.h" #include "ngx_list_iterator.h"
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2013 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#ifndef NGX_CACHING_HEADERS_H_ #ifndef NGX_CACHING_HEADERS_H_
#define NGX_CACHING_HEADERS_H_ #define NGX_CACHING_HEADERS_H_
+14 -25
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2014 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: oschaaf@we-amp.com (Otto van der Schaaf)
extern "C" { extern "C" {
@@ -55,14 +52,6 @@ bool NgxEventConnection::Init(ngx_cycle_t* cycle) {
} else { } else {
pipe_read_fd_ = file_descriptors[0]; pipe_read_fd_ = file_descriptors[0];
pipe_write_fd_ = file_descriptors[1]; pipe_write_fd_ = file_descriptors[1];
// Attempt to bump the pipe capacity, because running out of buffer space
// can potentially lead up to writes spinning on EAGAIN.
// See https://github.com/apache/incubator-pagespeed-ngx/issues/1380
// TODO(oschaaf): Consider implementing a queueing mechanism for retrying
// failed writes.
#ifdef F_SETPIPE_SZ
fcntl(pipe_write_fd_, F_SETPIPE_SZ, 200*1024 /* minimal amount of bytes */);
#endif
return true; return true;
} }
close(file_descriptors[0]); close(file_descriptors[0]);
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2014 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: oschaaf@we-amp.com (Otto van der Schaaf)
// //
// NgxEventConnection implements a means to send events from other threads to // NgxEventConnection implements a means to send events from other threads to
// nginx's event loop, and is implemented by a named pipe under the hood. // nginx's event loop, and is implemented by a named pipe under the hood.
+15 -18
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: x.dinic@gmail.com (Junmin Xiong)
// //
// - The fetch is started by the main thread. // - The fetch is started by the main thread.
// - Resolver event was hooked when a NgxFetch starting. It could // - Resolver event was hooked when a NgxFetch starting. It could
@@ -33,7 +30,7 @@
// TODO(oschaaf): style: reindent namespace according to google C++ style guide // TODO(oschaaf): style: reindent namespace according to google C++ style guide
// TODO(oschaaf): Retry mechanism for failures on a re-used k-a connection. // TODO(oschaaf): Retry mechanism for failures on a re-used k-a connection.
// Currently we don't think it's going to be an issue, see the comments at // Currently we don't think it's going to be an issue, see the comments at
// https://github.com/apache/incubator-pagespeed-ngx/pull/781. // https://github.com/pagespeed/ngx_pagespeed/pull/781.
extern "C" { extern "C" {
#include <nginx.h> #include <nginx.h>
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: x.dinic@gmail.com (Junmin Xiong)
// //
// PageSpeed needs some way to talk to the internet and request resources. For // PageSpeed needs some way to talk to the internet and request resources. For
// example, if it's optimizing www.example.com/index.html and it sees html with // example, if it's optimizing www.example.com/index.html and it sees html with
+24 -27
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2014 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: kspoelstra@we-amp.com (Kees Spoelstra)
#include "ngx_gzip_setter.h" #include "ngx_gzip_setter.h"
@@ -108,10 +105,10 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
#if (NGX_HTTP_GZIP) #if (NGX_HTTP_GZIP)
bool gzip_signature_mismatch = false; bool gzip_signature_mismatch = false;
bool other_signature_mismatch = false; bool other_signature_mismatch = false;
for (int m = 0; cf->cycle->modules[m] != NULL; m++) { for (int m = 0; ngx_modules[m] != NULL; m++) {
if (cf->cycle->modules[m]->commands != NULL) { if (ngx_modules[m]->commands != NULL) {
for (int c = 0; cf->cycle->modules[m]->commands[c].name.len; c++) { for (int c = 0; ngx_modules[m]->commands[c].name.len; c++) {
ngx_command_t* current_command =& cf->cycle->modules[m]->commands[c]; ngx_command_t* current_command =& ngx_modules[m]->commands[c];
// We look for the gzip command, and the exact signature we trust // We look for the gzip command, and the exact signature we trust
// this means configured as an config location offset // this means configured as an config location offset
@@ -124,7 +121,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
if (IsNgxFlagCommand(current_command)) { if (IsNgxFlagCommand(current_command)) {
current_command->set = ngx_gzip_redirect_conf_set_flag_slot; current_command->set = ngx_gzip_redirect_conf_set_flag_slot;
gzip_command_.command_ = current_command; gzip_command_.command_ = current_command;
gzip_command_.module_ = cf->cycle->modules[m]; gzip_command_.module_ = ngx_modules[m];
enabled_ = 1; enabled_ = 1;
} else { } else {
ngx_conf_log_error( ngx_conf_log_error(
@@ -139,7 +136,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
if (IsNgxEnumCommand(current_command)) { if (IsNgxEnumCommand(current_command)) {
current_command->set = ngx_gzip_redirect_conf_set_enum_slot; current_command->set = ngx_gzip_redirect_conf_set_enum_slot;
gzip_http_version_command_.command_ = current_command; gzip_http_version_command_.command_ = current_command;
gzip_http_version_command_.module_ = cf->cycle->modules[m]; gzip_http_version_command_.module_ = ngx_modules[m];
} else { } else {
ngx_conf_log_error( ngx_conf_log_error(
NGX_LOG_WARN, cf, 0, NGX_LOG_WARN, cf, 0,
@@ -153,7 +150,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
if (IsNgxBitmaskCommand(current_command)) { if (IsNgxBitmaskCommand(current_command)) {
current_command->set = ngx_gzip_redirect_conf_set_bitmask_slot; current_command->set = ngx_gzip_redirect_conf_set_bitmask_slot;
gzip_proxied_command_.command_ = current_command; gzip_proxied_command_.command_ = current_command;
gzip_proxied_command_.module_ = cf->cycle->modules[m]; gzip_proxied_command_.module_ = ngx_modules[m];
} else { } else {
ngx_conf_log_error( ngx_conf_log_error(
NGX_LOG_WARN, cf, 0, NGX_LOG_WARN, cf, 0,
@@ -167,7 +164,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
if (IsNgxHttpTypesCommand(current_command)) { if (IsNgxHttpTypesCommand(current_command)) {
current_command->set = ngx_gzip_redirect_http_types_slot; current_command->set = ngx_gzip_redirect_http_types_slot;
gzip_http_types_command_.command_ = current_command; gzip_http_types_command_.command_ = current_command;
gzip_http_types_command_.module_ = cf->cycle->modules[m]; gzip_http_types_command_.module_ = ngx_modules[m];
} else { } else {
ngx_conf_log_error( ngx_conf_log_error(
NGX_LOG_WARN, cf, 0, NGX_LOG_WARN, cf, 0,
@@ -181,7 +178,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
if (IsNgxFlagCommand(current_command)) { if (IsNgxFlagCommand(current_command)) {
current_command->set = ngx_gzip_redirect_conf_set_flag_slot; current_command->set = ngx_gzip_redirect_conf_set_flag_slot;
gzip_vary_command_.command_ = current_command; gzip_vary_command_.command_ = current_command;
gzip_vary_command_.module_ = cf->cycle->modules[m]; gzip_vary_command_.module_ = ngx_modules[m];
} else { } else {
ngx_conf_log_error( ngx_conf_log_error(
NGX_LOG_WARN, cf, 0, NGX_LOG_WARN, cf, 0,
@@ -313,7 +310,7 @@ void NgxGZipSetter::EnableGZipForLocation(ngx_conf_t* cf) {
} }
if (gzip_proxied_command_.command_) { if (gzip_proxied_command_.command_) {
SetNgxConfBitmask( SetNgxConfBitmask(
cf, &gzip_proxied_command_, NGX_HTTP_GZIP_PROXIED_ANY); cf, &gzip_http_version_command_, NGX_HTTP_GZIP_PROXIED_ANY);
} }
// This is actually the most prone to future API changes, because gzip_types // This is actually the most prone to future API changes, because gzip_types
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2014 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: kspoelstra@we-amp.com (Kees Spoelstra)
/* /*
* NgxGZipSetter sets up gzip for pagespeed * NgxGZipSetter sets up gzip for pagespeed
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2013 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#include "ngx_list_iterator.h" #include "ngx_list_iterator.h"
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2013 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
// //
// Simplifies iteration over nginx lists. // Simplifies iteration over nginx lists.
// //
+15 -21
View File
@@ -1,24 +1,18 @@
/* // Copyright 2013 Google Inc.
* Licensed to the Apache Software Foundation (ASF) under one //
* or more contributor license agreements. See the NOTICE file // Licensed under the Apache License, Version 2.0 (the "License");
* distributed with this work for additional information // you may not use this file except in compliance with the License.
* regarding copyright ownership. The ASF licenses this file // You may obtain a copy of the License at
* to you under the Apache License, Version 2.0 (the //
* "License"); you may not use this file except in compliance // http://www.apache.org/licenses/LICENSE-2.0
* with the License. You may obtain a copy of the License at //
* // Unless required by applicable law or agreed to in writing, software
* http://www.apache.org/licenses/LICENSE-2.0 // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* Unless required by applicable law or agreed to in writing, // See the License for the specific language governing permissions and
* software distributed under the License is distributed on an // limitations under the License.
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Author: oschaaf@gmail.com (Otto van der Schaaf)
#include "ngx_message_handler.h" #include "ngx_message_handler.h"
@@ -103,6 +97,7 @@ void NgxMessageHandler::MessageSImpl(MessageType type,
} else { } else {
GoogleMessageHandler::MessageSImpl(type, message); GoogleMessageHandler::MessageSImpl(type, message);
} }
// Prepare a log message for the SharedCircularBuffer only.
AddMessageToBuffer(type, message); AddMessageToBuffer(type, message);
} }
@@ -116,7 +111,6 @@ void NgxMessageHandler::FileMessageSImpl(
} else { } else {
GoogleMessageHandler::FileMessageSImpl(type, file, line, message); GoogleMessageHandler::FileMessageSImpl(type, file, line, message);
} }
AddMessageToBuffer(type, file, line, message);
} }
} // namespace net_instaweb } // namespace net_instaweb
+14 -20
View File
@@ -1,24 +1,18 @@
/* // Copyright 2013 Google Inc.
* Licensed to the Apache Software Foundation (ASF) under one //
* or more contributor license agreements. See the NOTICE file // Licensed under the Apache License, Version 2.0 (the "License");
* distributed with this work for additional information // you may not use this file except in compliance with the License.
* regarding copyright ownership. The ASF licenses this file // You may obtain a copy of the License at
* to you under the Apache License, Version 2.0 (the //
* "License"); you may not use this file except in compliance // http://www.apache.org/licenses/LICENSE-2.0
* with the License. You may obtain a copy of the License at //
* // Unless required by applicable law or agreed to in writing, software
* http://www.apache.org/licenses/LICENSE-2.0 // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* Unless required by applicable law or agreed to in writing, // See the License for the specific language governing permissions and
* software distributed under the License is distributed on an // limitations under the License.
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Author: oschaaf@gmail.com (Otto van der Schaaf)
#ifndef NGX_MESSAGE_HANDLER_H_ #ifndef NGX_MESSAGE_HANDLER_H_
#define NGX_MESSAGE_HANDLER_H_ #define NGX_MESSAGE_HANDLER_H_
+61 -221
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, * http://www.apache.org/licenses/LICENSE-2.0
* software distributed under the License is distributed on an *
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * Unless required by applicable law or agreed to in writing, software
* KIND, either express or implied. See the License for the * distributed under the License is distributed on an "AS IS" BASIS,
* specific language governing permissions and limitations * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* under the License. * See the License for the specific language governing permissions and
* limitations under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
/* /*
* Usage: * Usage:
@@ -87,7 +84,6 @@ extern ngx_module_t ngx_pagespeed;
// Needed for SystemRewriteDriverFactory to use shared memory. // Needed for SystemRewriteDriverFactory to use shared memory.
#define PAGESPEED_SUPPORT_POSIX_SHARED_MEM #define PAGESPEED_SUPPORT_POSIX_SHARED_MEM
#define NGINX_1_13_4 1013004
net_instaweb::NgxRewriteDriverFactory* active_driver_factory = NULL; net_instaweb::NgxRewriteDriverFactory* active_driver_factory = NULL;
@@ -128,7 +124,7 @@ char* string_piece_to_pool_string(ngx_pool_t* pool, StringPiece sp) {
// (potentially) longer string to nginx and want it to take ownership. // (potentially) longer string to nginx and want it to take ownership.
ngx_int_t string_piece_to_buffer_chain( ngx_int_t string_piece_to_buffer_chain(
ngx_pool_t* pool, StringPiece sp, ngx_chain_t** link_ptr, ngx_pool_t* pool, StringPiece sp, ngx_chain_t** link_ptr,
bool send_last_buf, bool send_flush) { bool send_last_buf) {
// Below, *link_ptr will be NULL if we're starting the chain, and the head // Below, *link_ptr will be NULL if we're starting the chain, and the head
// chain link. // chain link.
*link_ptr = NULL; *link_ptr = NULL;
@@ -202,9 +198,6 @@ ngx_int_t string_piece_to_buffer_chain(
CHECK(tail_link != NULL); CHECK(tail_link != NULL);
if (send_flush) {
tail_link->buf->flush = true;
}
if (send_last_buf) { if (send_last_buf) {
tail_link->buf->last_buf = true; tail_link->buf->last_buf = true;
} }
@@ -243,9 +236,6 @@ ngx_http_output_body_filter_pt ngx_http_next_body_filter;
ngx_int_t ps_base_fetch_filter(ngx_http_request_t* r, ngx_chain_t* in) { ngx_int_t ps_base_fetch_filter(ngx_http_request_t* r, ngx_chain_t* in) {
ps_request_ctx_t* ctx = ps_get_request_context(r); ps_request_ctx_t* ctx = ps_get_request_context(r);
if (r->header_only) {
return NGX_OK;
}
if (ctx == NULL || ctx->base_fetch == NULL) { if (ctx == NULL || ctx->base_fetch == NULL) {
return ngx_http_next_body_filter(r, in); return ngx_http_next_body_filter(r, in);
} }
@@ -295,8 +285,7 @@ ngx_int_t ps_base_fetch_handler(ngx_http_request_t* r) {
if (!status_ok && (ctx->base_fetch->base_fetch_type() != kHtmlTransform if (!status_ok && (ctx->base_fetch->base_fetch_type() != kHtmlTransform
&& ctx->base_fetch->base_fetch_type() != kIproLookup)) { && ctx->base_fetch->base_fetch_type() != kIproLookup)) {
ps_release_base_fetch(ctx); ps_release_base_fetch(ctx);
ngx_http_filter_finalize_request(r, NULL, status_code); return ngx_http_filter_finalize_request(r, NULL, status_code);
return NGX_DONE;
} }
if (ctx->preserve_caching_headers != kDontPreserveHeaders) { if (ctx->preserve_caching_headers != kDontPreserveHeaders) {
@@ -396,35 +385,6 @@ namespace {
// //
// Based on ngx_http_add_cache_control. // Based on ngx_http_add_cache_control.
ngx_int_t ps_set_cache_control(ngx_http_request_t* r, char* cache_control) { ngx_int_t ps_set_cache_control(ngx_http_request_t* r, char* cache_control) {
#if defined(nginx_version) && nginx_version >= 1023000
ngx_table_elt_t* cc = r->headers_out.cache_control;
if (cc == NULL) {
cc = reinterpret_cast<ngx_table_elt_t*>(ngx_list_push(&r->headers_out.headers));
if (cc == NULL) {
return NGX_ERROR;
}
r->headers_out.cache_control = cc;
cc->next = NULL;
cc->hash = 1;
ngx_str_set(&cc->key, "Cache-Control");
} else {
for (cc = cc->next; cc; cc = cc->next) {
cc->hash = 0;
}
cc = r->headers_out.cache_control;
cc->next = NULL;
}
cc->value.len = strlen(cache_control);
cc->value.data =
reinterpret_cast<u_char*>(cache_control);
#else
// First strip existing cache-control headers. // First strip existing cache-control headers.
ngx_table_elt_t* header; ngx_table_elt_t* header;
NgxListIterator it(&(r->headers_out.headers.part)); NgxListIterator it(&(r->headers_out.headers.part));
@@ -434,6 +394,7 @@ ngx_int_t ps_set_cache_control(ngx_http_request_t* r, char* cache_control) {
header->hash = 0; header->hash = 0;
} }
} }
// Now add our new cache control header. // Now add our new cache control header.
if (r->headers_out.cache_control.elts == NULL) { if (r->headers_out.cache_control.elts == NULL) {
ngx_int_t rc = ngx_array_init(&r->headers_out.cache_control, r->pool, ngx_int_t rc = ngx_array_init(&r->headers_out.cache_control, r->pool,
@@ -457,54 +418,10 @@ ngx_int_t ps_set_cache_control(ngx_http_request_t* r, char* cache_control) {
cache_control_headers[0]->value.len = strlen(cache_control); cache_control_headers[0]->value.len = strlen(cache_control);
cache_control_headers[0]->value.data = cache_control_headers[0]->value.data =
reinterpret_cast<u_char*>(cache_control); reinterpret_cast<u_char*>(cache_control);
#endif
return NGX_OK; return NGX_OK;
} }
// Returns false if the header wasn't found. Otherwise sets cache_control and
// returns true;
bool ps_get_cache_control(ngx_http_request_t* r, GoogleString* cache_control) {
// Use headers_out.cache_control instead of looking for Cache-Control in
// headers_out.headers, because if an upstream sent multiple Cache-Control
// headers they're already combined in headers_out.cache_control.
#if defined(nginx_version) && nginx_version >= 1023000
ngx_table_elt_t* cc = r->headers_out.cache_control;
bool first_segment = true;
while (cc != NULL) {
if (cc->hash) {
if (first_segment) {
first_segment = false;
} else {
cache_control->append(", ");
}
cache_control->append(reinterpret_cast<char*>(cc->value.data),
cc->value.len);
}
cc = cc->next;
}
#else
auto ccp = static_cast<ngx_table_elt_t**>(r->headers_out.cache_control.elts);
if (ccp == nullptr) {
return false; // Header not present.
}
bool first_segment = true;
for (ngx_uint_t i = 0; i < r->headers_out.cache_control.nelts; i++) {
if (ccp[i]->hash == 0) {
continue; // Elements with a hash of 0 are marked as excluded.
}
if (first_segment) {
first_segment = false;
} else {
cache_control->append(", ");
}
cache_control->append(reinterpret_cast<char*>(ccp[i]->value.data),
ccp[i]->value.len);
}
#endif
return true;
}
template<class Headers> template<class Headers>
void copy_headers_from_table(const ngx_list_t &from, Headers* to) { void copy_headers_from_table(const ngx_list_t &from, Headers* to) {
// Standard nginx idiom for iterating over a list. See ngx_list.h // Standard nginx idiom for iterating over a list. See ngx_list.h
@@ -767,7 +684,7 @@ char* ps_srv_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf);
char* ps_loc_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf); char* ps_loc_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf);
// We want NGX_CONF_MULTI for some very old versions: // We want NGX_CONF_MULTI for some very old versions:
// https://github.com/apache/incubator-pagespeed-ngx/commit/66f1b9aa // https://github.com/pagespeed/ngx_pagespeed/commit/66f1b9aa
// but it's gone in recent revisions, so provide a compat #define if needed // but it's gone in recent revisions, so provide a compat #define if needed
#ifndef NGX_CONF_MULTI #ifndef NGX_CONF_MULTI
#define NGX_CONF_MULTI 0 #define NGX_CONF_MULTI 0
@@ -802,11 +719,6 @@ ngx_command_t ps_commands[] = {
ngx_null_command ngx_null_command
}; };
bool ps_disabled(ps_srv_conf_t* cfg_s) {
return cfg_s->server_context == NULL ||
cfg_s->server_context->config()->unplugged();
}
void ps_ignore_sigpipe() { void ps_ignore_sigpipe() {
struct sigaction act; struct sigaction act;
ngx_memzero(&act, sizeof(act)); ngx_memzero(&act, sizeof(act));
@@ -939,17 +851,18 @@ char* ps_configure(ngx_conf_t* cf,
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>( ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cf->cycle, ngx_pagespeed)); ngx_http_cycle_get_module_main_conf(cf->cycle, ngx_pagespeed));
if (*options == NULL) { if (*options == NULL) {
*options = new NgxRewriteOptions(cfg_m->driver_factory->thread_system()); *options = new NgxRewriteOptions(
cfg_m->driver_factory->thread_system());
} }
ProcessScriptVariablesMode script_mode = bool process_script_variables = dynamic_cast<NgxRewriteDriverFactory*>(
dynamic_cast<NgxRewriteDriverFactory*>(cfg_m->driver_factory) cfg_m->driver_factory)->process_script_variables();
->process_script_variables();
if (script_mode != ProcessScriptVariablesMode::kOff) { if (process_script_variables) {
// To be able to use '$', we map '$ps_dollar' to '$' via a script variable. // To be able to use '$', we map '$ps_dollar' to '$' via a script variable.
ngx_str_t name = ngx_string("ps_dollar"); ngx_str_t name = ngx_string("ps_dollar");
ngx_http_variable_t* var = ngx_http_variable_t* var = ngx_http_add_variable(
ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGEABLE); cf, &name, NGX_HTTP_VAR_CHANGEABLE);
if (var == NULL) { if (var == NULL) {
return const_cast<char*>( return const_cast<char*>(
@@ -960,7 +873,7 @@ char* ps_configure(ngx_conf_t* cf,
const char* status = (*options)->ParseAndSetOptions( const char* status = (*options)->ParseAndSetOptions(
args, n_args, cf->pool, handler, cfg_m->driver_factory, option_scope, cf, args, n_args, cf->pool, handler, cfg_m->driver_factory, option_scope, cf,
script_mode); process_script_variables);
// nginx expects us to return a string literal but doesn't mark it const. // nginx expects us to return a string literal but doesn't mark it const.
return const_cast<char*>(status); return const_cast<char*>(status);
@@ -1074,7 +987,7 @@ void* ps_create_main_conf(ngx_conf_t* cf) {
} }
ps_main_conf_t* cfg_m = ps_create_conf<ps_main_conf_t>(cf); ps_main_conf_t* cfg_m = ps_create_conf<ps_main_conf_t>(cf);
if (cfg_m == NULL) { if (cfg_m == NULL) {
return NULL; return NGX_CONF_ERROR;
} }
CHECK(!factory_deleted); CHECK(!factory_deleted);
NgxRewriteOptions::Initialize(); NgxRewriteOptions::Initialize();
@@ -1095,7 +1008,7 @@ void* ps_create_main_conf(ngx_conf_t* cf) {
void* ps_create_srv_conf(ngx_conf_t* cf) { void* ps_create_srv_conf(ngx_conf_t* cf) {
ps_srv_conf_t* cfg_s = ps_create_conf<ps_srv_conf_t>(cf); ps_srv_conf_t* cfg_s = ps_create_conf<ps_srv_conf_t>(cf);
if (cfg_s == NULL) { if (cfg_s == NULL) {
return NULL; return NGX_CONF_ERROR;
} }
ps_set_conf_cleanup_handler(cf, ps_cleanup_srv_conf, cfg_s); ps_set_conf_cleanup_handler(cf, ps_cleanup_srv_conf, cfg_s);
return cfg_s; return cfg_s;
@@ -1104,7 +1017,7 @@ void* ps_create_srv_conf(ngx_conf_t* cf) {
void* ps_create_loc_conf(ngx_conf_t* cf) { void* ps_create_loc_conf(ngx_conf_t* cf) {
ps_loc_conf_t* cfg_l = ps_create_conf<ps_loc_conf_t>(cf); ps_loc_conf_t* cfg_l = ps_create_conf<ps_loc_conf_t>(cf);
if (cfg_l == NULL) { if (cfg_l == NULL) {
return NULL; return NGX_CONF_ERROR;
} }
ps_set_conf_cleanup_handler(cf, ps_cleanup_loc_conf, cfg_l); ps_set_conf_cleanup_handler(cf, ps_cleanup_loc_conf, cfg_l);
return cfg_l; return cfg_l;
@@ -1184,17 +1097,6 @@ char* ps_merge_srv_conf(ngx_conf_t* cf, void* parent, void* child) {
cfg_m->driver_factory->SetMainConf(parent_cfg_s->options); cfg_m->driver_factory->SetMainConf(parent_cfg_s->options);
cfg_s->server_context = cfg_m->driver_factory->MakeNgxServerContext( cfg_s->server_context = cfg_m->driver_factory->MakeNgxServerContext(
"dummy_hostname", dummy_port); "dummy_hostname", dummy_port);
#if (NGX_HTTP_V2)
// Save the variable index of the "http2" variable, so we can use it
// at request time to lookup whether that's on. We do this conditionally
// since NGINX will complain to the user (at [emerg] level!) if it doesn't
// know about it.
ngx_str_t name = ngx_string("http2");
cfg_s->server_context->set_ngx_http2_variable_index(
ngx_http_get_variable_index(cf, &name));
#endif
// The server context sets some options when we call global_options(). So // The server context sets some options when we call global_options(). So
// let it do that, then merge in options we got from the config file. // let it do that, then merge in options we got from the config file.
// Once we do that we're done with cfg_s->options. // Once we do that we're done with cfg_s->options.
@@ -1205,17 +1107,13 @@ char* ps_merge_srv_conf(ngx_conf_t* cf, void* parent, void* child) {
delete cfg_s->options; delete cfg_s->options;
cfg_s->options = NULL; cfg_s->options = NULL;
if (!cfg_s->server_context->global_options()->unplugged()) { if (cfg_s->server_context->global_options()->enabled()) {
// Validate FileCachePath // Validate FileCachePath
GoogleMessageHandler handler; GoogleMessageHandler handler;
const char* file_cache_path = const char* file_cache_path =
cfg_s->server_context->config()->file_cache_path().c_str(); cfg_s->server_context->config()->file_cache_path().c_str();
if (file_cache_path[0] == '\0') { if (file_cache_path[0] == '\0') {
if (!cfg_s->server_context->global_options()->standby()) { return const_cast<char*>("FileCachePath must be set");
return const_cast<char*>("FileCachePath must be set, even for standby");
} else {
return const_cast<char*>("FileCachePath must be set");
}
} else if (!cfg_m->driver_factory->file_system()->IsDir( } else if (!cfg_m->driver_factory->file_system()->IsDir(
file_cache_path, &handler).is_true()) { file_cache_path, &handler).is_true()) {
return const_cast<char*>( return const_cast<char*>(
@@ -1252,7 +1150,7 @@ char* ps_merge_loc_conf(ngx_conf_t* cf, void* parent, void* child) {
ps_srv_conf_t* cfg_s = static_cast<ps_srv_conf_t*>( ps_srv_conf_t* cfg_s = static_cast<ps_srv_conf_t*>(
ngx_http_conf_get_module_srv_conf(cf, ngx_pagespeed)); ngx_http_conf_get_module_srv_conf(cf, ngx_pagespeed));
if (ps_disabled(cfg_s)) { if (cfg_s->server_context == NULL) {
// Pagespeed options cannot be defined only in location blocks. There must // Pagespeed options cannot be defined only in location blocks. There must
// be at least a single "pagespeed off" in the main block or a server // be at least a single "pagespeed off" in the main block or a server
// block. // block.
@@ -1394,9 +1292,6 @@ ngx_int_t ps_decline_request(ngx_http_request_t* r) {
r->count++; r->count++;
r->phase_handler++; r->phase_handler++;
//restore read_event_handler to what it was in ps_async_wait_response
r->read_event_handler = ngx_http_block_reading;
r->write_event_handler = ngx_http_core_run_phases; r->write_event_handler = ngx_http_core_run_phases;
ngx_http_core_run_phases(r); ngx_http_core_run_phases(r);
ngx_http_run_posted_requests(r->connection); ngx_http_run_posted_requests(r->connection);
@@ -1408,13 +1303,6 @@ ngx_int_t ps_async_wait_response(ngx_http_request_t* r) {
CHECK(ctx != NULL); CHECK(ctx != NULL);
r->count++; r->count++;
// While we wait for PSOL to complete an async operation, there is a chance
// that the underlying connection gets closed, or a http/2 RST_STREAM is
// received before the async operation completes. In that case we don't want
// to continue processing this flow. So we override the requests's read event
// handler with one that will make nginx abort request processing and execute
// our cleanup handlers instead of resuming request processing.
r->read_event_handler = ngx_http_test_reading;
r->write_event_handler = ngx_http_request_empty_handler; r->write_event_handler = ngx_http_request_empty_handler;
ps_set_buffered(r, true); ps_set_buffered(r, true);
// We don't need to add a timer here, as it will be set by nginx. // We don't need to add a timer here, as it will be set by nginx.
@@ -1759,7 +1647,7 @@ void ps_release_request_context(void* data) {
RequestRouting::Response ps_route_request(ngx_http_request_t* r) { RequestRouting::Response ps_route_request(ngx_http_request_t* r) {
ps_srv_conf_t* cfg_s = ps_get_srv_config(r); ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
if (ps_disabled(cfg_s)) { if (!cfg_s->server_context->global_options()->enabled()) {
// Not enabled for this server block. // Not enabled for this server block.
return RequestRouting::kPagespeedDisabled; return RequestRouting::kPagespeedDisabled;
} }
@@ -1901,6 +1789,11 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
options = cfg_s->server_context->global_options(); options = cfg_s->server_context->global_options();
} }
if (!options->enabled()) {
// Disabled via query params or request headers.
return NGX_DECLINED;
}
request_context->set_options(options->ComputeHttpOptions()); request_context->set_options(options->ComputeHttpOptions());
// ps_determine_options modified url, removing any ModPagespeedFoo=Bar query // ps_determine_options modified url, removing any ModPagespeedFoo=Bar query
@@ -1927,14 +1820,6 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
response_category == RequestRouting::kGlobalAdmin || response_category == RequestRouting::kGlobalAdmin ||
response_category == RequestRouting::kCachePurge; response_category == RequestRouting::kCachePurge;
// Normally if we're disabled we won't handle any requests, but if we're in
// standby mode we do want to handle requests for .pagespeed. resources.
if (options->unplugged() ||
(!options->enabled() && !pagespeed_resource)) {
// Disabled via query params or request headers.
return NGX_DECLINED;
}
if (!html_rewrite) { if (!html_rewrite) {
// create request ctx // create request ctx
CHECK(ctx == NULL); CHECK(ctx == NULL);
@@ -1943,7 +1828,6 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
ctx->r = r; ctx->r = r;
ctx->html_rewrite = false; ctx->html_rewrite = false;
ctx->in_place = false; ctx->in_place = false;
ctx->follow_flushes = options->follow_flushes();
ctx->preserve_caching_headers = kDontPreserveHeaders; ctx->preserve_caching_headers = kDontPreserveHeaders;
// See build_context_for_request() in mod_instaweb.cc // See build_context_for_request() in mod_instaweb.cc
@@ -1993,7 +1877,7 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
ResourceFetch::Start( ResourceFetch::Start(
url, url,
custom_options.release() /* null if there aren't custom options */, custom_options.release() /* null if there aren't custom options */,
cfg_s->server_context, ctx->base_fetch); false /* using_spdy */, cfg_s->server_context, ctx->base_fetch);
return ps_async_wait_response(r); return ps_async_wait_response(r);
} else if (is_an_admin_handler) { } else if (is_an_admin_handler) {
ps_create_base_fetch(url.Spec(), ctx, request_context, ps_create_base_fetch(url.Spec(), ctx, request_context,
@@ -2069,7 +1953,7 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
} }
if (html_rewrite && options->IsAllowed(url.Spec())) { if (html_rewrite) {
ps_create_base_fetch(url.Spec(), ctx, request_context, ps_create_base_fetch(url.Spec(), ctx, request_context,
request_headers.release(), kHtmlTransform, options); request_headers.release(), kHtmlTransform, options);
// Do not store driver in request_context, it's not safe. // Do not store driver in request_context, it's not safe.
@@ -2099,7 +1983,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
url, url,
cfg_s->server_context, cfg_s->server_context,
options, options,
ctx->base_fetch); ctx->base_fetch,
false /* requires_blink_cohort (no longer unused) */);
// Will call StartParse etc. The rewrite driver will take care of deleting // Will call StartParse etc. The rewrite driver will take care of deleting
// itself if necessary. // itself if necessary.
@@ -2114,8 +1999,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
if (options->in_place_rewriting_enabled() && if (options->in_place_rewriting_enabled() &&
options->enabled() && options->enabled() &&
options->IsAllowed(url.Spec())) { options->IsAllowed(url.Spec())) {
ps_create_base_fetch(url.Spec(), ctx, request_context, ps_create_base_fetch(url.Spec(), ctx, request_context, request_headers.release(),
request_headers.release(), kIproLookup, options); kIproLookup, options);
// Do not store driver in request_context, it's not safe. // Do not store driver in request_context, it's not safe.
RewriteDriver* driver; RewriteDriver* driver;
@@ -2164,6 +2049,7 @@ void ps_send_to_pagespeed(ngx_http_request_t* r,
int last_buf = 0; int last_buf = 0;
for (cur = in; cur != NULL; cur = cur->next) { for (cur = in; cur != NULL; cur = cur->next) {
last_buf = cur->buf->last_buf; last_buf = cur->buf->last_buf;
// Buffers are not really the last buffer until they've been through // Buffers are not really the last buffer until they've been through
// pagespeed. // pagespeed.
cur->buf->last_buf = 0; cur->buf->last_buf = 0;
@@ -2188,19 +2074,6 @@ void ps_send_to_pagespeed(ngx_http_request_t* r,
} }
} }
} }
if (cur->buf->flush && ctx->follow_flushes) {
// Calling ctx->proxy_fetch->Flush(cfg_s->handler) will be a no-op here,
// unless we have follow_flushes or flush_html enabled. Note that PSOL
// might aggregate multiple flushes into 1, and actually flush a little bit
// later due to html parser state and earlier scheduled operations.
// Also, unless we also set the flush flag on the nginx buffers we won't
// actually flush.
// Note that too many flushes could harm optimization over larger html
// fragments as PSOL gets less context to work with, e.g. it can't combine
// two css files if a flush happens in between.
ctx->proxy_fetch->Flush(cfg_s->handler);
}
// We're done with buffers as we pass them through, so mark them as sent as // We're done with buffers as we pass them through, so mark them as sent as
// we go. // we go.
cur->buf->pos = cur->buf->last; cur->buf->pos = cur->buf->last;
@@ -2209,6 +2082,9 @@ void ps_send_to_pagespeed(ngx_http_request_t* r,
if (last_buf) { if (last_buf) {
ctx->proxy_fetch->Done(true /* success */); ctx->proxy_fetch->Done(true /* success */);
ctx->proxy_fetch = NULL; // ProxyFetch deletes itself on Done(). ctx->proxy_fetch = NULL; // ProxyFetch deletes itself on Done().
} else {
// TODO(jefftk): Decide whether Flush() is warranted here.
ctx->proxy_fetch->Flush(cfg_s->handler);
} }
} }
@@ -2305,31 +2181,6 @@ ngx_int_t ps_etag_header_filter(ngx_http_request_t* r) {
r->gzip_vary = 0; r->gzip_vary = 0;
} }
#endif #endif
if (ctx && ctx->recorder) {
ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
int s_maxage_sec =
cfg_s->server_context->global_options()->EffectiveInPlaceSMaxAgeSec();
if (s_maxage_sec != -1) {
GoogleString existing_cache_control;
bool cache_control_present = ps_get_cache_control(
r, &existing_cache_control);
GoogleString updated_cache_control;
if (ResponseHeaders::ApplySMaxAge(s_maxage_sec,
existing_cache_control,
&updated_cache_control)) {
// We're modifing the cache control header; save a copy first.
// NULL indicates that the header was not present.
ctx->recorder->SaveCacheControl(
cache_control_present ? existing_cache_control.c_str() : NULL);
// Replace the cache-control with our new s-maxage-including one.
ps_set_cache_control(r, string_piece_to_pool_string(
r->pool, updated_cache_control));
}
}
}
return ngx_http_ef_next_header_filter(r); return ngx_http_ef_next_header_filter(r);
} }
@@ -2341,7 +2192,8 @@ ngx_http_output_body_filter_pt ngx_http_next_body_filter;
// nginx so it can send them out to the browser. // nginx so it can send them out to the browser.
ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) { ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) {
ps_srv_conf_t* cfg_s = ps_get_srv_config(r); ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
if (ps_disabled(cfg_s)) { if (cfg_s->server_context == NULL) {
// Pagespeed is on for some server block but not this one.
return ngx_http_next_header_filter(r); return ngx_http_next_header_filter(r);
} }
@@ -2412,7 +2264,7 @@ ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) {
} }
ps_strip_html_headers(r); ps_strip_html_headers(r);
// See https://github.com/apache/incubator-pagespeed-ngx/issues/819 // See https://github.com/pagespeed/ngx_pagespeed/issues/819
ctx->location_field_set = r->headers_out.location != NULL; ctx->location_field_set = r->headers_out.location != NULL;
// TODO(jefftk): is this thread safe? // TODO(jefftk): is this thread safe?
@@ -2425,7 +2277,8 @@ ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) {
ngx_int_t ps_html_rewrite_body_filter(ngx_http_request_t* r, ngx_chain_t* in) { ngx_int_t ps_html_rewrite_body_filter(ngx_http_request_t* r, ngx_chain_t* in) {
ps_srv_conf_t* cfg_s = ps_get_srv_config(r); ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
if (ps_disabled(cfg_s)) { if (cfg_s->server_context == NULL) {
// Pagespeed is on for some server block but not this one.
return ngx_http_next_body_filter(r, in); return ngx_http_next_body_filter(r, in);
} }
@@ -2555,7 +2408,6 @@ ngx_int_t ps_in_place_check_header_filter(ngx_http_request_t* r) {
cache_url.c_str()); cache_url.c_str());
const SystemRewriteOptions* options = SystemRewriteOptions::DynamicCast( const SystemRewriteOptions* options = SystemRewriteOptions::DynamicCast(
ctx->driver->options()); ctx->driver->options());
RequestContextPtr request_context( RequestContextPtr request_context(
cfg_s->server_context->NewRequestContext(r)); cfg_s->server_context->NewRequestContext(r));
request_context->set_options(options->ComputeHttpOptions()); request_context->set_options(options->ComputeHttpOptions());
@@ -2575,7 +2427,7 @@ ngx_int_t ps_in_place_check_header_filter(ngx_http_request_t* r) {
server_context->http_cache(), server_context->http_cache(),
server_context->statistics(), server_context->statistics(),
message_handler); message_handler);
// set in memory flag for in_place_body_filter // set in memory flag for in place_body_filter
r->filter_need_in_memory = 1; r->filter_need_in_memory = 1;
// We don't have the response headers at all yet because we haven't yet gone // We don't have the response headers at all yet because we haven't yet gone
@@ -2659,7 +2511,7 @@ ngx_int_t send_out_headers_and_body(
// Send the body. // Send the body.
ngx_chain_t* out; ngx_chain_t* out;
rc = string_piece_to_buffer_chain( rc = string_piece_to_buffer_chain(
r->pool, output, &out, true /* send_last_buf */, false); r->pool, output, &out, true /* send_last_buf */);
if (rc == NGX_ERROR) { if (rc == NGX_ERROR) {
return NGX_ERROR; return NGX_ERROR;
} }
@@ -2753,7 +2605,8 @@ ngx_int_t ps_simple_handler(ngx_http_request_t* r,
} }
} }
return send_out_headers_and_body(r, response_headers, output); send_out_headers_and_body(r, response_headers, output);
return NGX_OK;
} }
void ps_beacon_handler_helper(ngx_http_request_t* r, void ps_beacon_handler_helper(ngx_http_request_t* r,
@@ -2948,8 +2801,8 @@ ngx_int_t ps_beacon_handler(ngx_http_request_t* r) {
// supply it to the user. // supply it to the user.
ngx_int_t ps_content_handler(ngx_http_request_t* r) { ngx_int_t ps_content_handler(ngx_http_request_t* r) {
ps_srv_conf_t* cfg_s = ps_get_srv_config(r); ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
if (ps_disabled(cfg_s)) { if (cfg_s->server_context == NULL) {
// Pagespeed is not on for this server block. // Pagespeed is on for some server block but not this one.
return NGX_DECLINED; return NGX_DECLINED;
} }
@@ -3068,17 +2921,13 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) {
ph = cmcf->phase_engine.handlers; ph = cmcf->phase_engine.handlers;
i = r->phase_handler; i = r->phase_handler;
// move handlers before try_files && content phase // move handlers before try_files && content phase
// As of nginx 1.13.4 we will be right before the try_files module
#if (nginx_version < NGINX_1_13_4)
while (ph[i + 1].checker != ngx_http_core_try_files_phase && while (ph[i + 1].checker != ngx_http_core_try_files_phase &&
ph[i + 1].checker != ngx_http_core_content_phase) { ph[i + 1].checker != ngx_http_core_content_phase) {
ph[i] = ph[i + 1]; ph[i] = ph[i + 1];
ph[i].next--; ph[i].next--;
i++; i++;
} }
#endif
// insert ps phase handler // insert ps phase handler
ph[i].checker = ps_phase_handler; ph[i].checker = ps_phase_handler;
@@ -3134,17 +2983,8 @@ ngx_int_t ps_init(ngx_conf_t* cf) {
ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>( ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module)); ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module));
int phase = NGX_HTTP_PREACCESS_PHASE;
// As of nginx 1.13.4, try_files has changed.
// https://github.com/nginx/nginx/commit/129b06dc5dfab7b4513a4f274b3778cd9b8a6a22
#if (nginx_version >= NGINX_1_13_4)
phase = NGX_HTTP_PRECONTENT_PHASE;
#endif
ngx_http_handler_pt* h = static_cast<ngx_http_handler_pt*>( ngx_http_handler_pt* h = static_cast<ngx_http_handler_pt*>(
ngx_array_push(&cmcf->phases[phase].handlers)); ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers));
if (h == NULL) { if (h == NULL) {
return NGX_ERROR; return NGX_ERROR;
} }
@@ -3184,7 +3024,7 @@ ngx_int_t ps_init_module(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>( ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed)); ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
// See https://github.com/apache/incubator-pagespeed-ngx/issues/1220 // See https://github.com/pagespeed/ngx_pagespeed/issues/1220
if (cfg_m == NULL) { if (cfg_m == NULL) {
return NGX_OK; return NGX_OK;
} }
+15 -19
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#ifndef NGX_PAGESPEED_H_ #ifndef NGX_PAGESPEED_H_
#define NGX_PAGESPEED_H_ #define NGX_PAGESPEED_H_
@@ -55,7 +52,7 @@ class InPlaceResourceRecorder;
// NGX_DECLINED immediately unless send_last_buf. // NGX_DECLINED immediately unless send_last_buf.
ngx_int_t string_piece_to_buffer_chain( ngx_int_t string_piece_to_buffer_chain(
ngx_pool_t* pool, StringPiece sp, ngx_pool_t* pool, StringPiece sp,
ngx_chain_t** link_ptr, bool send_last_buf, bool send_flush); ngx_chain_t** link_ptr, bool send_last_buf);
StringPiece str_to_string_piece(ngx_str_t s); StringPiece str_to_string_piece(ngx_str_t s);
@@ -112,7 +109,6 @@ typedef struct {
// Location: headers that start with '/' without regarding X-Forwarded-Proto. // Location: headers that start with '/' without regarding X-Forwarded-Proto.
bool location_field_set; bool location_field_set;
bool psol_vary_accept_only; bool psol_vary_accept_only;
bool follow_flushes;
} ps_request_ctx_t; } ps_request_ctx_t;
ps_request_ctx_t* ps_get_request_context(ngx_http_request_t* r); ps_request_ctx_t* ps_get_request_context(ngx_http_request_t* r);
+16 -38
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#include "ngx_rewrite_driver_factory.h" #include "ngx_rewrite_driver_factory.h"
@@ -85,7 +82,7 @@ NgxRewriteDriverFactory::NgxRewriteDriverFactory(
ngx_shared_circular_buffer_(NULL), ngx_shared_circular_buffer_(NULL),
hostname_(hostname.as_string()), hostname_(hostname.as_string()),
port_(port), port_(port),
process_script_variables_mode_(ProcessScriptVariablesMode::kOff), process_script_variables_(false),
process_script_variables_set_(false), process_script_variables_set_(false),
shut_down_(false) { shut_down_(false) {
InitializeDefaultOptions(); InitializeDefaultOptions();
@@ -154,7 +151,7 @@ RewriteOptions* NgxRewriteDriverFactory::NewRewriteOptions() {
// mod_pagespeed does in mod_instaweb.cc:create_dir_config() isn't enough here // mod_pagespeed does in mod_instaweb.cc:create_dir_config() isn't enough here
// -- if you use that instead then ngx_pagespeed doesn't actually end up // -- if you use that instead then ngx_pagespeed doesn't actually end up
// defaulting CoreFilters. // defaulting CoreFilters.
// See: https://github.com/apache/incubator-pagespeed-ngx/issues/1190 // See: https://github.com/pagespeed/ngx_pagespeed/issues/1190
options->SetRewriteLevel(RewriteOptions::kCoreFilters); options->SetRewriteLevel(RewriteOptions::kCoreFilters);
return options; return options;
} }
@@ -269,23 +266,4 @@ void NgxRewriteDriverFactory::InitStats(Statistics* statistics) {
InPlaceResourceRecorder::InitStats(statistics); InPlaceResourceRecorder::InitStats(statistics);
} }
void NgxRewriteDriverFactory::PrepareForkedProcess(const char* name) {
ngx_pid = ngx_getpid(); // Needed for logging to have the right PIDs.
SystemRewriteDriverFactory::PrepareForkedProcess(name);
}
void NgxRewriteDriverFactory::NameProcess(const char* name) {
SystemRewriteDriverFactory::NameProcess(name);
// Superclass set status with prctl. Nginx has a helper function for setting
// argv[0] as well, so let's use that. We'll show up as:
//
// nginx: pagespeed $name
char name_for_setproctitle[32];
snprintf(name_for_setproctitle, sizeof(name_for_setproctitle),
"pagespeed %s", name);
ngx_setproctitle(name_for_setproctitle);
}
} // namespace net_instaweb } // namespace net_instaweb
+19 -32
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#ifndef NGX_REWRITE_DRIVER_FACTORY_H_ #ifndef NGX_REWRITE_DRIVER_FACTORY_H_
#define NGX_REWRITE_DRIVER_FACTORY_H_ #define NGX_REWRITE_DRIVER_FACTORY_H_
@@ -51,12 +48,6 @@ class SlowWorker;
class Statistics; class Statistics;
class SystemThreadSystem; class SystemThreadSystem;
enum ProcessScriptVariablesMode {
kOff,
kLegacyRestricted,
kAll
};
class NgxRewriteDriverFactory : public SystemRewriteDriverFactory { class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
public: public:
// We take ownership of the thread system. // We take ownership of the thread system.
@@ -121,8 +112,8 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
void set_native_fetcher_max_keepalive_requests(int x) { void set_native_fetcher_max_keepalive_requests(int x) {
native_fetcher_max_keepalive_requests_ = x; native_fetcher_max_keepalive_requests_ = x;
} }
ProcessScriptVariablesMode process_script_variables() { bool process_script_variables() {
return process_script_variables_mode_; return process_script_variables_;
} }
void LoggingInit(ngx_log_t* log, bool may_install_crash_handler); void LoggingInit(ngx_log_t* log, bool may_install_crash_handler);
@@ -131,19 +122,15 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
virtual void SetCircularBuffer(SharedCircularBuffer* buffer); virtual void SetCircularBuffer(SharedCircularBuffer* buffer);
bool SetProcessScriptVariables(ProcessScriptVariablesMode mode) { bool SetProcessScriptVariables(bool process_script_variables) {
if (!process_script_variables_set_) { if (!process_script_variables_set_) {
process_script_variables_mode_ = mode; process_script_variables_ = process_script_variables;
process_script_variables_set_ = true; process_script_variables_set_ = true;
return true; return true;
} }
return false; return false;
} }
virtual void PrepareForkedProcess(const char* name);
virtual void NameProcess(const char* name);
private: private:
Timer* timer_; Timer* timer_;
@@ -167,7 +154,7 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
GoogleString hostname_; GoogleString hostname_;
int port_; int port_;
ProcessScriptVariablesMode process_script_variables_mode_; bool process_script_variables_;
bool process_script_variables_set_; bool process_script_variables_set_;
bool shut_down_; bool shut_down_;
+56 -86
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#include "ngx_rewrite_options.h" #include "ngx_rewrite_options.h"
@@ -115,7 +112,7 @@ void NgxRewriteOptions::AddProperties() {
false); false);
add_ngx_option( add_ngx_option(
"", &NgxRewriteOptions::global_statistics_path_, "ngsp", "", &NgxRewriteOptions::global_statistics_path_, "ngsp",
kGlobalStatisticsPath, kProcessScopeStrict, kGlobalStatisticsPath, kProcessScope,
"Set the global statistics path. Ex: /ngx_pagespeed_global_statistics", "Set the global statistics path. Ex: /ngx_pagespeed_global_statistics",
false); false);
add_ngx_option( add_ngx_option(
@@ -130,8 +127,7 @@ void NgxRewriteOptions::AddProperties() {
kServerScope, "Set the admin path. Ex: /pagespeed_admin", false); kServerScope, "Set the admin path. Ex: /pagespeed_admin", false);
add_ngx_option( add_ngx_option(
"", &NgxRewriteOptions::global_admin_path_, "ngap", kGlobalAdminPath, "", &NgxRewriteOptions::global_admin_path_, "ngap", kGlobalAdminPath,
kProcessScopeStrict, kProcessScope, "Set the global admin path. Ex: /pagespeed_global_admin",
"Set the global admin path. Ex: /pagespeed_global_admin",
false); false);
MergeSubclassProperties(ngx_properties_); MergeSubclassProperties(ngx_properties_);
@@ -184,10 +180,10 @@ RewriteOptions::OptionScope NgxRewriteOptions::GetOptionScope(
it != all_options().end(); ++it) { it != all_options().end(); ++it) {
RewriteOptions::OptionBase* option = *it; RewriteOptions::OptionBase* option = *it;
if (option->option_name() == option_name) { if (option->option_name() == option_name) {
// We treat kLegacyProcessScope as kProcessScopeStrict, failing to start // We treat kProcessScope as kProcessScopeStrict, failing to start if an
// if an option is out of place. // option is out of place.
return option->scope() == kLegacyProcessScope ? kProcessScopeStrict return option->scope() == kProcessScope ? kProcessScopeStrict
: option->scope(); : option->scope();
} }
} }
return kDirectoryScope; return kDirectoryScope;
@@ -195,18 +191,15 @@ RewriteOptions::OptionScope NgxRewriteOptions::GetOptionScope(
RewriteOptions::OptionSettingResult NgxRewriteOptions::ParseAndSetOptions0( RewriteOptions::OptionSettingResult NgxRewriteOptions::ParseAndSetOptions0(
StringPiece directive, GoogleString* msg, MessageHandler* handler) { StringPiece directive, GoogleString* msg, MessageHandler* handler) {
EnabledEnum enabled; if (IsDirective(directive, "on")) {
if (!ParseFromString(directive, &enabled)) { set_enabled(RewriteOptions::kEnabledOn);
} else if (IsDirective(directive, "off")) {
set_enabled(RewriteOptions::kEnabledOff);
} else if (IsDirective(directive, "unplugged")) {
set_enabled(RewriteOptions::kEnabledUnplugged);
} else {
return RewriteOptions::kOptionNameUnknown; return RewriteOptions::kOptionNameUnknown;
} }
if (enabled == RewriteOptions::kEnabledOff) {
// In ngx_pagespeed, for historical reasons, we treat "off" as "unplugged".
// Also, "off" is deprecated and people should be using "standby" or
// "unplugged" now depending on which sense they want. See comment on
// RewriteOptions::EnabledEnum.
enabled = RewriteOptions::kEnabledUnplugged;
}
set_enabled(enabled);
return RewriteOptions::kOptionOk; return RewriteOptions::kOptionOk;
} }
@@ -265,8 +258,7 @@ const char* ps_error_string_for_option(
const char* NgxRewriteOptions::ParseAndSetOptions( const char* NgxRewriteOptions::ParseAndSetOptions(
StringPiece* args, int n_args, ngx_pool_t* pool, MessageHandler* handler, StringPiece* args, int n_args, ngx_pool_t* pool, MessageHandler* handler,
NgxRewriteDriverFactory* driver_factory, NgxRewriteDriverFactory* driver_factory,
RewriteOptions::OptionScope scope, ngx_conf_t* cf, RewriteOptions::OptionScope scope, ngx_conf_t* cf, bool compile_scripts) {
ProcessScriptVariablesMode script_mode) {
CHECK_GE(n_args, 1); CHECK_GE(n_args, 1);
StringPiece directive = args[0]; StringPiece directive = args[0];
@@ -282,43 +274,20 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
pool, directive, "cannot be set at this scope."); pool, directive, "cannot be set at this scope.");
} }
bool compile_scripts = false;
if (script_mode != ProcessScriptVariablesMode::kOff) {
// In the old mode we only allowed a few, so restrict to those.
compile_scripts =
StringCaseStartsWith(directive, "LoadFromFile") ||
StringCaseEqual(directive, "EnableFilters") ||
StringCaseEqual(directive, "DisableFilters") ||
StringCaseEqual(directive, "DownstreamCachePurgeLocationPrefix") ||
StringCaseEqual(directive, "DownstreamCachePurgeMethod") ||
StringCaseEqual(directive,
"DownstreamCacheRewrittenPercentageThreshold") ||
StringCaseEqual(directive, "ShardDomain");
// In the new behaviour we also allow scripting of query- and directory-
// scoped options.
compile_scripts |=
script_mode == ProcessScriptVariablesMode::kAll &&
(GetOptionScope(directive) <= RewriteOptions::kDirectoryScope ||
(StringCaseEqual(directive, "Allow") ||
StringCaseEqual(directive, "BlockingRewriteRefererUrls") ||
StringCaseEqual(directive, "Disallow") ||
StringCaseEqual(directive, "DistributableFilters") ||
StringCaseEqual(directive, "Domain") ||
StringCaseEqual(directive, "ExperimentVariable") ||
StringCaseEqual(directive, "ExperimentSpec") ||
StringCaseEqual(directive, "ForbidFilters") ||
StringCaseEqual(directive, "RetainComment") ||
StringCaseEqual(directive, "CustomFetchHeader") ||
StringCaseEqual(directive, "MapOriginDomain") ||
StringCaseEqual(directive, "MapProxyDomain") ||
StringCaseEqual(directive, "MapRewriteDomain") ||
StringCaseEqual(directive, "UrlValuedAttribute") ||
StringCaseEqual(directive, "Library")));
}
ScriptLine* script_line; ScriptLine* script_line;
script_line = NULL; script_line = NULL;
// Note that LoadFromFile should not be scriptable on wildcard hosts,
// as browsers might be able to manipulate its natural use-case: $http_host.
if (!StringCaseStartsWith(directive, "LoadFromFile") &&
!StringCaseEqual(directive, "EnableFilters") &&
!StringCaseEqual(directive, "DisableFilters") &&
!StringCaseEqual(directive, "DownstreamCachePurgeLocationPrefix") &&
!StringCaseEqual(directive, "DownstreamCachePurgeMethod") &&
!StringCaseEqual(directive,
"DownstreamCacheRewrittenPercentageThreshold") &&
!StringCaseEqual(directive, "ShardDomain")){
compile_scripts = false;
}
if (n_args == 1 && StringCaseEqual(directive, "ClearInheritedScripts")) { if (n_args == 1 && StringCaseEqual(directive, "ClearInheritedScripts")) {
clear_inherited_scripts_ = true; clear_inherited_scripts_ = true;
@@ -394,23 +363,24 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
} }
} else if (StringCaseEqual("ProcessScriptVariables", args[0])) { } else if (StringCaseEqual("ProcessScriptVariables", args[0])) {
if (scope == RewriteOptions::kProcessScopeStrict) { if (scope == RewriteOptions::kProcessScopeStrict) {
ProcessScriptVariablesMode mode; if (StringCaseEqual(arg, "on")) {
if (StringCaseEqual(arg, "all")) { if (driver_factory->SetProcessScriptVariables(true)) {
mode = ProcessScriptVariablesMode::kAll; result = RewriteOptions::kOptionOk;
} else if (StringCaseEqual(arg, "on")) { } else {
mode = ProcessScriptVariablesMode::kLegacyRestricted; return const_cast<char*>(
"pagespeed ProcessScriptVariables: can only be set once");
}
} else if (StringCaseEqual(arg, "off")) { } else if (StringCaseEqual(arg, "off")) {
mode = ProcessScriptVariablesMode::kOff; if (driver_factory->SetProcessScriptVariables(false)) {
result = RewriteOptions::kOptionOk;
} else {
return const_cast<char*>(
"pagespeed ProcessScriptVariables: can only be set once");
}
} else { } else {
return const_cast<char*>( return const_cast<char*>(
"pagespeed ProcessScriptVariables: invalid value"); "pagespeed ProcessScriptVariables: invalid value");
} }
if (driver_factory->SetProcessScriptVariables(mode)) {
result = RewriteOptions::kOptionOk;
} else {
return const_cast<char*>(
"pagespeed ProcessScriptVariables: can only be set once");
}
} else { } else {
return const_cast<char*>( return const_cast<char*>(
"ProcessScriptVariables is only allowed at the top level"); "ProcessScriptVariables is only allowed at the top level");
@@ -421,7 +391,7 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
result = driver_factory->ParseAndSetOption1( result = driver_factory->ParseAndSetOption1(
directive, directive,
arg, arg,
scope >= RewriteOptions::kLegacyProcessScope, scope >= RewriteOptions::kProcessScope,
&msg, &msg,
handler); handler);
} }
@@ -434,7 +404,7 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
directive, directive,
args[1], args[1],
args[2], args[2],
scope >= RewriteOptions::kLegacyProcessScope, scope >= RewriteOptions::kProcessScope,
&msg, &msg,
handler); handler);
} }
@@ -506,7 +476,7 @@ bool NgxRewriteOptions::ExecuteScriptVariables(
const char* status = ParseAndSetOptions(args, script_line->n_args(), const char* status = ParseAndSetOptions(args, script_line->n_args(),
r->pool, handler, driver_factory, script_line->scope(), NULL /*cf*/, r->pool, handler, driver_factory, script_line->scope(), NULL /*cf*/,
ProcessScriptVariablesMode::kOff); false /*compile scripts*/);
if (status != NULL) { if (status != NULL) {
script_error = true; script_error = true;
+15 -20
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
// Manage configuration for pagespeed. Compare to ApacheConfig. // Manage configuration for pagespeed. Compare to ApacheConfig.
@@ -32,8 +29,6 @@ extern "C" {
#include <vector> #include <vector>
#include "ngx_rewrite_driver_factory.h"
#include "net/instaweb/rewriter/public/rewrite_options.h" #include "net/instaweb/rewriter/public/rewrite_options.h"
#include "pagespeed/kernel/base/message_handler.h" #include "pagespeed/kernel/base/message_handler.h"
#include "pagespeed/kernel/base/ref_counted_ptr.h" #include "pagespeed/kernel/base/ref_counted_ptr.h"
@@ -136,7 +131,7 @@ class NgxRewriteOptions : public SystemRewriteOptions {
const char* ParseAndSetOptions( const char* ParseAndSetOptions(
StringPiece* args, int n_args, ngx_pool_t* pool, MessageHandler* handler, StringPiece* args, int n_args, ngx_pool_t* pool, MessageHandler* handler,
NgxRewriteDriverFactory* driver_factory, OptionScope scope, NgxRewriteDriverFactory* driver_factory, OptionScope scope,
ngx_conf_t* cf, ProcessScriptVariablesMode script_mode); ngx_conf_t* cf, bool compile_scripts);
bool ExecuteScriptVariables( bool ExecuteScriptVariables(
ngx_http_request_t* r, MessageHandler* handler, ngx_http_request_t* r, MessageHandler* handler,
NgxRewriteDriverFactory* driver_factory); NgxRewriteDriverFactory* driver_factory);
+20 -36
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
#include "ngx_server_context.h" #include "ngx_server_context.h"
@@ -38,8 +35,7 @@ namespace net_instaweb {
NgxServerContext::NgxServerContext( NgxServerContext::NgxServerContext(
NgxRewriteDriverFactory* factory, StringPiece hostname, int port) NgxRewriteDriverFactory* factory, StringPiece hostname, int port)
: SystemServerContext(factory, hostname, port), : SystemServerContext(factory, hostname, port) {
ngx_http2_variable_index_(NGX_ERROR) {
} }
NgxServerContext::~NgxServerContext() { } NgxServerContext::~NgxServerContext() { }
@@ -74,23 +70,11 @@ SystemRequestContext* NgxServerContext::NewRequestContext(
local_ip.len = 0; local_ip.len = 0;
} }
SystemRequestContext* ctx = new SystemRequestContext( return new SystemRequestContext(thread_system()->NewMutex(),
thread_system()->NewMutex(), timer(), timer(),
ps_determine_host(r), local_port, str_to_string_piece(local_ip)); ps_determine_host(r),
local_port,
// See if http2 is in use. str_to_string_piece(local_ip));
if (ngx_http2_variable_index_ >= 0) {
ngx_http_variable_value_t* val =
ngx_http_get_indexed_variable(r, ngx_http2_variable_index_);
if (val != NULL && val->valid) {
StringPiece str_val(reinterpret_cast<char*>(val->data), val->len);
if (str_val == "h2" || str_val == "h2c") {
ctx->set_using_http2(true);
}
}
}
return ctx;
} }
GoogleString NgxServerContext::FormatOption(StringPiece option_name, GoogleString NgxServerContext::FormatOption(StringPiece option_name,
+14 -27
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: jefftk@google.com (Jeff Kaufman)
// Manage pagespeed state across requests. Compare to ApacheResourceManager. // Manage pagespeed state across requests. Compare to ApacheResourceManager.
@@ -61,18 +58,8 @@ class NgxServerContext : public SystemServerContext {
virtual GoogleString FormatOption(StringPiece option_name, StringPiece args); virtual GoogleString FormatOption(StringPiece option_name, StringPiece args);
void set_ngx_http2_variable_index(ngx_int_t idx) {
ngx_http2_variable_index_ = idx;
}
ngx_int_t ngx_http2_variable_index() const {
return ngx_http2_variable_index_;
}
private: private:
NgxRewriteDriverFactory* ngx_factory_; NgxRewriteDriverFactory* ngx_factory_;
// what index the "http2" var is, or NGX_ERROR.
ngx_int_t ngx_http2_variable_index_;
DISALLOW_COPY_AND_ASSIGN(NgxServerContext); DISALLOW_COPY_AND_ASSIGN(NgxServerContext);
}; };
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: x.dinic@gmail.com (Junmin Xiong)
extern "C" { extern "C" {
#include <ngx_http.h> #include <ngx_http.h>
+14 -17
View File
@@ -1,23 +1,20 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Copyright 2012 Google Inc.
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information * Licensed under the Apache License, Version 2.0 (the "License");
* regarding copyright ownership. The ASF licenses this file * you may not use this file except in compliance with the License.
* to you under the Apache License, Version 2.0 (the * You may obtain a copy of the License at
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* software distributed under the License is distributed on an * See the License for the specific language governing permissions and
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * limitations under the License.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
// Author: x.dinic@gmail.com(Junmin Xiong)
// //
// Fetch the resources asynchronously in Nginx. The fetcher is called in // Fetch the resources asynchronously in Nginx. The fetcher is called in
// the rewrite thread. // the rewrite thread.
+59 -155
View File
@@ -1,21 +1,22 @@
#!/bin/bash #!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one #
# or more contributor license agreements. See the NOTICE file # Copyright 2012 Google Inc.
# distributed with this work for additional information #
# regarding copyright ownership. The ASF licenses this file # Licensed under the Apache License, Version 2.0 (the "License");
# to you under the Apache License, Version 2.0 (the # you may not use this file except in compliance with the License.
# "License"); you may not use this file except in compliance # You may obtain a copy of the License at
# with the License. You may obtain a copy of the License at #
# # http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0 #
# # Unless required by applicable law or agreed to in writing, software
# Unless required by applicable law or agreed to in writing, # distributed under the License is distributed on an "AS IS" BASIS,
# software distributed under the License is distributed on an # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # See the License for the specific language governing permissions and
# KIND, either express or implied. See the License for the # limitations under the License.
# specific language governing permissions and limitations #
# under the License. # Author: jefftk@google.com (Jeff Kaufman)
#
#
# Runs pagespeed's generic system test and nginx-specific system tests. Not # Runs pagespeed's generic system test and nginx-specific system tests. Not
# intended to be run on it's own; use run_tests.sh instead. # intended to be run on it's own; use run_tests.sh instead.
# #
@@ -30,13 +31,17 @@
: ${NATIVE_FETCHER:?"Set NATIVE_FETCHER to off or on"} : ${NATIVE_FETCHER:?"Set NATIVE_FETCHER to off or on"}
: ${PRIMARY_PORT:?"Set PRIMARY_PORT"} : ${PRIMARY_PORT:?"Set PRIMARY_PORT"}
: ${SECONDARY_PORT:?"Set SECONDARY_PORT"} : ${SECONDARY_PORT:?"Set SECONDARY_PORT"}
: ${CONTROLLER_PORT:?"Set CONTROLLER_PORT"} : ${RCPORT1:?"Set RCPORT1"}
: ${RCPORT:?"Set RCPORT"} : ${RCPORT2:?"Set RCPORT2"}
: ${RCPORT2:?"Set RCPORT3"}
: ${RCPORT4:?"Set RCPORT4"}
: ${RCPORT5:?"Set RCPORT5"}
: ${RCPORT6:?"Set RCPORT6"}
: ${RCPORT7:?"Set RCPORT7"}
: ${MOD_PAGESPEED_DIR:?"Set MOD_PAGESPEED_DIR"} : ${MOD_PAGESPEED_DIR:?"Set MOD_PAGESPEED_DIR"}
: ${NGINX_EXECUTABLE:?"Set NGINX_EXECUTABLE"} : ${NGINX_EXECUTABLE:?"Set NGINX_EXECUTABLE"}
: ${PAGESPEED_TEST_HOST:?"Set PAGESPEED_TEST_HOST"} : ${PAGESPEED_TEST_HOST:?"Set PAGESPEED_TEST_HOST"}
POSITION_AUX="${POSITION_AUX:-unset}" POSITION_AUX="${POSITION_AUX:-unset}"
RUN_CONTROLLER_TEST="${RUN_CONTROLLER_TEST:-off}"
PRIMARY_HOSTNAME="localhost:$PRIMARY_PORT" PRIMARY_HOSTNAME="localhost:$PRIMARY_PORT"
SECONDARY_HOSTNAME="localhost:$SECONDARY_PORT" SECONDARY_HOSTNAME="localhost:$SECONDARY_PORT"
@@ -48,11 +53,7 @@ rm -rf "$TEST_TMP"
mkdir -p "$TEST_TMP" mkdir -p "$TEST_TMP"
echo TEST_TMP=$TEST_TMP echo TEST_TMP=$TEST_TMP
if [ -d "$MOD_PAGESPEED_DIR/src" ]; then APACHE_DOC_SRC="$MOD_PAGESPEED_DIR/src/install/"
MOD_PAGESPEED_DIR+="/src"
fi
APACHE_DOC_SRC="$MOD_PAGESPEED_DIR/install/"
SERVER_ROOT="$TEST_TMP/root" SERVER_ROOT="$TEST_TMP/root"
echo SERVER_ROOT=$SERVER_ROOT echo SERVER_ROOT=$SERVER_ROOT
rm -rf "$SERVER_ROOT" rm -rf "$SERVER_ROOT"
@@ -153,16 +154,10 @@ function fire_ab_load() {
# stop nginx/valgrind # stop nginx/valgrind
killall -s KILL nginx killall -s KILL nginx
# TODO(oschaaf): Fix waiting for valgrind on 32 bits systems.
killall -s KILL memcheck-amd64- killall -s KILL memcheck-amd64-
killall -s KILL memcheck-x86- while pgrep nginx > /dev/null; do sleep 1; done
SECONDS=0 while pgrep memcheck > /dev/null; do sleep 1; done
while pgrep -x nginx >/dev/null || pgrep memcheck >/dev/null;do
if [ $SECONDS -gt 20 ]; then
echo "Old processes won't die" >&2
exit 1
fi
sleep 1
done
check_simple mkdir -p "$TEST_TMP" check_simple mkdir -p "$TEST_TMP"
PROXY_CACHE="$TEST_TMP/proxycache" PROXY_CACHE="$TEST_TMP/proxycache"
@@ -193,12 +188,6 @@ else
RESOLVER="" RESOLVER=""
fi fi
if [ "$RUN_CONTROLLER_TEST" = "on" ]; then
CONTROLLER="pagespeed ExperimentalCentralControllerPort $CONTROLLER_PORT;"
else
CONTROLLER=""
fi
# set up the config file for the test # set up the config file for the test
PAGESPEED_CONF="$TEST_TMP/pagespeed_test.conf" PAGESPEED_CONF="$TEST_TMP/pagespeed_test.conf"
PAGESPEED_CONF_TEMPLATE="$this_dir/pagespeed_test.conf.template" PAGESPEED_CONF_TEMPLATE="$this_dir/pagespeed_test.conf.template"
@@ -223,10 +212,15 @@ cat $PAGESPEED_CONF_TEMPLATE \
| sed 's#@@SERVER_ROOT@@#'"$SERVER_ROOT"'#' \ | sed 's#@@SERVER_ROOT@@#'"$SERVER_ROOT"'#' \
| sed 's#@@PRIMARY_PORT@@#'"$PRIMARY_PORT"'#' \ | sed 's#@@PRIMARY_PORT@@#'"$PRIMARY_PORT"'#' \
| sed 's#@@SECONDARY_PORT@@#'"$SECONDARY_PORT"'#' \ | sed 's#@@SECONDARY_PORT@@#'"$SECONDARY_PORT"'#' \
| sed 's#@@CONTROLLER@@#'"$CONTROLLER"'#' \
| sed 's#@@NATIVE_FETCHER@@#'"$NATIVE_FETCHER"'#' \ | sed 's#@@NATIVE_FETCHER@@#'"$NATIVE_FETCHER"'#' \
| sed 's#@@RESOLVER@@#'"$RESOLVER"'#' \ | sed 's#@@RESOLVER@@#'"$RESOLVER"'#' \
| sed 's#@@RCPORT@@#'"$RCPORT"'#' \ | sed 's#@@RCPORT1@@#'"$RCPORT1"'#' \
| sed 's#@@RCPORT2@@#'"$RCPORT2"'#' \
| sed 's#@@RCPORT3@@#'"$RCPORT3"'#' \
| sed 's#@@RCPORT4@@#'"$RCPORT4"'#' \
| sed 's#@@RCPORT5@@#'"$RCPORT5"'#' \
| sed 's#@@RCPORT6@@#'"$RCPORT6"'#' \
| sed 's#@@RCPORT7@@#'"$RCPORT7"'#' \
| sed 's#@@PAGESPEED_TEST_HOST@@#'"$PAGESPEED_TEST_HOST"'#' \ | sed 's#@@PAGESPEED_TEST_HOST@@#'"$PAGESPEED_TEST_HOST"'#' \
>> $PAGESPEED_CONF >> $PAGESPEED_CONF
# make sure we substituted all the variables # make sure we substituted all the variables
@@ -238,7 +232,7 @@ if $USE_VALGRIND; then
--show-possibly-lost=no --log-file=$TEST_TMP/valgrind.log \ --show-possibly-lost=no --log-file=$TEST_TMP/valgrind.log \
--suppressions="$this_dir/valgrind.sup" \ --suppressions="$this_dir/valgrind.sup" \
$NGINX_EXECUTABLE -c $PAGESPEED_CONF) & VALGRIND_PID=$! $NGINX_EXECUTABLE -c $PAGESPEED_CONF) & VALGRIND_PID=$!
trap "echo 'terminating valgrind!' && kill -s TERM $VALGRIND_PID" EXIT trap "echo 'terminating valgrind!' && kill -s sigterm $VALGRIND_PID" EXIT
echo "Wait until nginx is ready to accept connections" echo "Wait until nginx is ready to accept connections"
while ! curl -I "http://$PRIMARY_HOSTNAME/mod_pagespeed_example/" 2>/dev/null; do while ! curl -I "http://$PRIMARY_HOSTNAME/mod_pagespeed_example/" 2>/dev/null; do
sleep 0.1; sleep 0.1;
@@ -293,7 +287,7 @@ else
if $USE_VALGRIND; then if $USE_VALGRIND; then
# Clear valgrind trap # Clear valgrind trap
trap - EXIT trap - EXIT
echo "To end valgrind, run 'kill -s TERM $VALGRIND_PID'" echo "To end valgrind, run 'kill -s quit $VALGRIND_PID'"
fi fi
echo "Not running tests; commence manual testing" echo "Not running tests; commence manual testing"
exit 4 exit 4
@@ -307,16 +301,8 @@ CACHE_PURGE_METHODS="PURGE GET"
SERVER_NAME=nginx SERVER_NAME=nginx
# TODO(cheesy): add an nginx controller test variant. Actually requires some
# thought as we don't currently have a multi-phase test flow in ngx_pagespeeed,
# as far as I can tell, and we really have to update the config and restart
# since the controller is a global setting.
RUN_CONTROLLER_TEST=${RUN_CONTROLLER_TEST:-off}
# run generic system tests # run generic system tests
PAGESPEED_DIR="$MOD_PAGESPEED_DIR/pagespeed" SYSTEM_TEST_FILE="$MOD_PAGESPEED_DIR/src/pagespeed/system/system_test.sh"
SYSTEM_TEST_FILE="$PAGESPEED_DIR/system/system_test.sh"
REMOTE_CONFIG_TEST_FILE="$PAGESPEED_DIR/system/remote_config_test.sh"
if [ ! -e "$SYSTEM_TEST_FILE" ] ; then if [ ! -e "$SYSTEM_TEST_FILE" ] ; then
echo "Not finding $SYSTEM_TEST_FILE -- is mod_pagespeed not in a parallel" echo "Not finding $SYSTEM_TEST_FILE -- is mod_pagespeed not in a parallel"
@@ -329,8 +315,7 @@ BEACON_HANDLER="ngx_pagespeed_beacon"
STATISTICS_HANDLER="ngx_pagespeed_statistics" STATISTICS_HANDLER="ngx_pagespeed_statistics"
GLOBAL_STATISTICS_HANDLER="ngx_pagespeed_global_statistics" GLOBAL_STATISTICS_HANDLER="ngx_pagespeed_global_statistics"
MESSAGES_HANDLER="ngx_pagespeed_message" MESSAGES_HANDLER="ngx_pagespeed_message"
STATISTICS_URL=http://$PRIMARY_HOSTNAME/$STATISTICS_HANDLER STATISTICS_URL=http://$PRIMARY_HOSTNAME/ngx_pagespeed_statistics
GLOBAL_STATISTICS_URL=http://$PRIMARY_HOSTNAME/$GLOBAL_STATISTICS_HANDLER
# An expected failure can be indicated like: "~In-place resource optimization~" # An expected failure can be indicated like: "~In-place resource optimization~"
PAGESPEED_EXPECTED_FAILURES=" PAGESPEED_EXPECTED_FAILURES="
@@ -359,6 +344,7 @@ if $USE_VALGRIND; then
~combine_css Maximum size of combined CSS.~ ~combine_css Maximum size of combined CSS.~
~prioritize_critical_css~ ~prioritize_critical_css~
~prioritize_critical_css Able to read POST data from temp file.~ ~prioritize_critical_css Able to read POST data from temp file.~
~IPRO flow uses cache as expected.~
~IPRO flow doesn't copy uncacheable resources multiple times.~ ~IPRO flow doesn't copy uncacheable resources multiple times.~
~inline_unauthorized_resources allows unauthorized css selectors~ ~inline_unauthorized_resources allows unauthorized css selectors~
" "
@@ -369,14 +355,6 @@ fi
set -- "$PRIMARY_HOSTNAME" set -- "$PRIMARY_HOSTNAME"
source $SYSTEM_TEST_FILE source $SYSTEM_TEST_FILE
# If we were only asked to run a single test, it ran in SYSTEM_TEST_FILE, so
# we're done now and should exit.
if [ -n ${TEST_TO_RUN+x} ]; then
check_failures_and_exit
fi
source $REMOTE_CONFIG_TEST_FILE
# nginx-specific system tests # nginx-specific system tests
start_test Test pagespeed directive inside if block inside location block. start_test Test pagespeed directive inside if block inside location block.
@@ -612,93 +590,30 @@ check test $(scrape_stat image_rewrite_total_original_bytes) -ge 10000
# happens both before and after. # happens both before and after.
start_test "Reload config" start_test "Reload config"
function find_exactly_once {
test $(grep -c "$1") -eq 1
}
if [ "$RUN_CONTROLLER_TEST" = "on" ]; then
function check_process_names() {
if ! $USE_VALGRIND; then
# There should be one babysitter and controller running. Under valgrind
# process labels are confused, so skip the check then.
running=$(ps auxww | grep 'ngin[x]')
check_from "$running" find_exactly_once "nginx: pagespeed babysitter"
check_from "$running" find_exactly_once "nginx: pagespeed controller"
fi
}
check_process_names
fi
# Fire up some heavy load if ab is available to test a stressed reload. # Fire up some heavy load if ab is available to test a stressed reload.
# TODO(oschaaf): make sure we wait for the new worker to get ready to accept # TODO(oschaaf): make sure we wait for the new worker to get ready to accept
# requests. # requests.
fire_ab_load fire_ab_load
URL="$EXAMPLE_ROOT/styles/W.rewrite_css_images.css.pagespeed.cf.Hash.css" check wget $EXAMPLE_ROOT/styles/W.rewrite_css_images.css.pagespeed.cf.Hash.css \
check wget "$URL" -O /dev/null -O /dev/null
check_simple "$NGINX_EXECUTABLE" -s reload -c "$PAGESPEED_CONF" check_simple "$NGINX_EXECUTABLE" -s reload -c "$PAGESPEED_CONF"
# Wait for the new worker process with the new configuration to get ready, or # Wait for the new worker process with the new configuration to get ready, or
# else the sudden reset of the shared mem statistics/cache might catch upcoming # else the sudden reset of the shared mem statistics/cache might catch upcoming
# tests unaware. # tests unaware.
function wait_for_new_worker() { while [ $(scrape_stat image_rewrite_total_original_bytes) -gt 0 ]
while [ $(scrape_stat image_rewrite_total_original_bytes) -gt 0 ]; do do
echo "Waiting for new worker to get ready..." echo "Waiting for new worker to get ready..."
sleep .1 sleep .1
done done
}
wait_for_new_worker check wget $EXAMPLE_ROOT/styles/W.rewrite_css_images.css.pagespeed.cf.Hash.css \
check wget "$URL" -O /dev/null -O /dev/null
if [ "$AB_PID" != "0" ]; then if [ "$AB_PID" != "0" ]; then
echo "Kill ab (pid: $AB_PID)" echo "Kill ab (pid: $AB_PID)"
kill -s KILL $AB_PID &>/dev/null || true kill -s KILL $AB_PID &>/dev/null || true
fi fi
# There should still be just one babysitter and controller running.
if [ "$RUN_CONTROLLER_TEST" = "on" ]; then
check_process_names
check grep "Writing a byte to a pipe to tell the old controller to exit." \
$ERROR_LOG
check grep "Root process is starting a new controller; shutting down." \
$ERROR_LOG
fi
start_test "Shared memory checkpointing"
# We do two tests here:
# 1. Metadata cache: check that an IPRO'd image is still fully optimized after a
# restart.
# 2. Property cache: prioritize critical CSS persists beacon results across
# restarts.
IPRO_URL="$EXAMPLE_ROOT/images/Cuppa.png"
# Checkpoint beacon results to disk if we haven't already.
check wget "$IPRO_URL" -O /dev/null
test_prioritize_critical_css
sleep 2
check wget "$IPRO_URL" -O /dev/null
test_prioritize_critical_css
# Reload nginx again.
check_simple "$NGINX_EXECUTABLE" -s reload -c "$PAGESPEED_CONF"
wait_for_new_worker
# The image should be fully optimized.
OUT=$($CURL -sS -D- -o/dev/null "$IPRO_URL")
check_from "$OUT" grep ^X-Original-Content-Length:
check_from "$OUT" grep ^Content-Length:
content_length=$(echo "$OUT" | grep ^Content-Length: | grep -o [0-9]*)
original_content_length=$(echo "$OUT" | grep ^X-Original-Content-Length: \
| grep -o [0-9]*)
check [ "$original_content_length" -gt "$content_length" ]
# The beacon responses are stored in the metadata cache, so this can only pass
# if we persisted the metadata across restarts.
test_prioritize_critical_css_final
# This is dependent upon having a beacon handler. # This is dependent upon having a beacon handler.
test_filter add_instrumentation beacons load. test_filter add_instrumentation beacons load.
@@ -1194,7 +1109,7 @@ OUT=$($WGET_DUMP --header=Host:response-header-disable.example.com $URL)
check_not_from "$OUT" egrep -qi 'addInstrumentationInit' check_not_from "$OUT" egrep -qi 'addInstrumentationInit'
# TODO(jmaessen, jefftk): Port proxying tests, which rely on pointing a # TODO(jmaessen, jefftk): Port proxying tests, which rely on pointing a
# MapProxyDomain construct at a static server. Perhaps $HOSTNAME will # MapProxyDomain construct at a static server. Perhaps localhost:8050 will
# serve, but the tests need to use different urls then. For mod_pagespeed these # serve, but the tests need to use different urls then. For mod_pagespeed these
# tests immediately precede the "scrape_secondary_stat" definition in # tests immediately precede the "scrape_secondary_stat" definition in
# system_test.sh. # system_test.sh.
@@ -1346,6 +1261,10 @@ OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) || tr
# We ignored the exit code, check if we got a 404 response. # We ignored the exit code, check if we got a 404 response.
check_from "$OUT" fgrep -qi '404' check_from "$OUT" fgrep -qi '404'
if false; then
# This test fails on 1.11, but passes on trunk. While 2b4c097 fixed most users,
# it's still possible to get two Vary: Accept-Encoding headers in this test, so
# disable it for now.
start_test Single Vary: Accept-Encoding header in IPRO flow start_test Single Vary: Accept-Encoding header in IPRO flow
URL=http://psol-vary.example.com/mod_pagespeed_example/styles/index_style.css URL=http://psol-vary.example.com/mod_pagespeed_example/styles/index_style.css
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
@@ -1362,15 +1281,7 @@ OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
MATCHES=$(echo "$OUT" | grep -c "Vary: Accept-Encoding") || true MATCHES=$(echo "$OUT" | grep -c "Vary: Accept-Encoding") || true
check [ $MATCHES -eq 1 ] check [ $MATCHES -eq 1 ]
start_test Follow flushes can be turned off. fi
echo "Check that FollowFlushes off outputs a single chunk"
check_flushing noflush 5.4 1
start_test Special responses from php are handled OK.
URL="http://special-response.example.com/A.foo.css.pagespeed.cf.0.css"
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -S --content-on-error $URL 2>&1) || true
check_from "$OUT" fgrep -qi '404'
check_from "$OUT" fgrep -q "PHP with a call to flush"
start_test Shutting down. start_test Shutting down.
@@ -1378,8 +1289,7 @@ start_test Shutting down.
fire_ab_load fire_ab_load
if $USE_VALGRIND; then if $USE_VALGRIND; then
# SIGQUIT requests a graceful shutdown. kill -s quit $VALGRIND_PID
kill -s QUIT $VALGRIND_PID
while pgrep memcheck > /dev/null; do sleep 1; done while pgrep memcheck > /dev/null; do sleep 1; done
# Clear the previously set trap, we don't need it anymore. # Clear the previously set trap, we don't need it anymore.
trap - EXIT trap - EXIT
@@ -1388,12 +1298,12 @@ if $USE_VALGRIND; then
check_not [ -s "$TEST_TMP/valgrind.log" ] check_not [ -s "$TEST_TMP/valgrind.log" ]
else else
check_simple "$NGINX_EXECUTABLE" -s quit -c "$PAGESPEED_CONF" check_simple "$NGINX_EXECUTABLE" -s quit -c "$PAGESPEED_CONF"
while pgrep -x nginx > /dev/null; do sleep 1; done while pgrep nginx > /dev/null; do sleep 1; done
fi fi
if [ "$AB_PID" != "0" ]; then if [ "$AB_PID" != "0" ]; then
echo "Kill ab (pid: $AB_PID)" echo "Kill ab (pid: $AB_PID)"
kill -s KILL $AB_PID &>/dev/null || true killall -s KILL $AB_PID &>/dev/null || true
fi fi
start_test Logged output looks healthy. start_test Logged output looks healthy.
@@ -1420,8 +1330,6 @@ OUT=$(cat "$ERROR_LOG" \
| grep -v "\\[warn\\].*Resource based on.*ngx_pagespeed_statistics.*" \ | grep -v "\\[warn\\].*Resource based on.*ngx_pagespeed_statistics.*" \
| grep -v "\\[warn\\].*Canceling 1 functions on sequence Shutdown.*" \ | grep -v "\\[warn\\].*Canceling 1 functions on sequence Shutdown.*" \
| grep -v "\\[warn\\].*using uninitialized.*" \ | grep -v "\\[warn\\].*using uninitialized.*" \
| grep -v "\\[warn\\].*Controller process .* exited with wait status 9" \
| grep -v "\\[warn\\].*Controller process .* exited with wait status 15" \
| grep -v "\\[error\\].*BadName*" \ | grep -v "\\[error\\].*BadName*" \
| grep -v "\\[error\\].*/mod_pagespeed/bad*" \ | grep -v "\\[error\\].*/mod_pagespeed/bad*" \
| grep -v "\\[error\\].*doesnotexist.css.*" \ | grep -v "\\[error\\].*doesnotexist.css.*" \
@@ -1430,7 +1338,7 @@ OUT=$(cat "$ERROR_LOG" \
| grep -v "\\[error\\].*forbidden.example.com*" \ | grep -v "\\[error\\].*forbidden.example.com*" \
| grep -v "\\[error\\].*custom-paths.example.com*" \ | grep -v "\\[error\\].*custom-paths.example.com*" \
| grep -v "\\[error\\].*bogus_format*" \ | grep -v "\\[error\\].*bogus_format*" \
| grep -v "\\[error\\].*/install/foo*" \ | grep -v "\\[error\\].*src/install/foo*" \
| grep -v "\\[error\\].*recv() failed*" \ | grep -v "\\[error\\].*recv() failed*" \
| grep -v "\\[error\\].*send() failed*" \ | grep -v "\\[error\\].*send() failed*" \
| grep -v "\\[error\\].*Invalid url requested: js_defer.js.*" \ | grep -v "\\[error\\].*Invalid url requested: js_defer.js.*" \
@@ -1450,12 +1358,8 @@ OUT=$(cat "$ERROR_LOG" \
| grep -v "\\[warn\\].*remote\.cfg.*" \ | grep -v "\\[warn\\].*remote\.cfg.*" \
| grep -v "\\[warn\\].*end token not received.*" \ | grep -v "\\[warn\\].*end token not received.*" \
| grep -v "\\[warn\\].*failed to hook next event.*" \ | grep -v "\\[warn\\].*failed to hook next event.*" \
| grep -v "\\[warn\\].*Fetch timed out:.*" \
| grep -v "\\[warn\\].*Controller process .* exited with status code.*" \
| grep -v "\\[warn\\].*Rewrite.*failed.*.pagespeed....0.foo.*" \ | grep -v "\\[warn\\].*Rewrite.*failed.*.pagespeed....0.foo.*" \
| grep -v "\\[warn\\].*A.blue.css.*but cannot access the original.*" \ | grep -v "\\[warn\\].*A.blue.css.*but cannot access the original.*" \
| grep -v "\\[warn\\].*Adding function to sequence.*" \
| grep -v "\\[warn\\].*special-response.*foo.css.*but cannot access the original.*" \
|| true) || true)
check [ -z "$OUT" ] check [ -z "$OUT" ]
+13 -336
View File
@@ -1,20 +1,3 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# nginx_system_test.sh makes a few substitutions to pagespeed_test.conf.template # nginx_system_test.sh makes a few substitutions to pagespeed_test.conf.template
# file to generate @@TEST_TMP@@/pagespeed_test.conf # file to generate @@TEST_TMP@@/pagespeed_test.conf
@@ -47,7 +30,7 @@ http {
proxy_cache_path "@@PROXY_CACHE@@" levels=1:2 keys_zone=htmlcache:60m inactive=90m max_size=50m; proxy_cache_path "@@PROXY_CACHE@@" levels=1:2 keys_zone=htmlcache:60m inactive=90m max_size=50m;
proxy_temp_path "@@TMP_PROXY_CACHE@@"; proxy_temp_path "@@TMP_PROXY_CACHE@@";
pagespeed ProcessScriptVariables all; pagespeed ProcessScriptVariables on;
pagespeed StatisticsPath /ngx_pagespeed_statistics; pagespeed StatisticsPath /ngx_pagespeed_statistics;
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics; pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
pagespeed ConsolePath /pagespeed_console; pagespeed ConsolePath /pagespeed_console;
@@ -80,12 +63,6 @@ http {
pagespeed CreateSharedMemoryMetadataCache "@@SHM_CACHE@@" 8192; pagespeed CreateSharedMemoryMetadataCache "@@SHM_CACHE@@" 8192;
pagespeed BlockingRewriteKey psatest; pagespeed BlockingRewriteKey psatest;
# We need to checkpoint more frequently than usual so that our checkpointing
# test will definitly have seen one of these intervals and so not be flaky.
# This needs to have a 1s interval because the checkpointing test has a 2s
# sleep.
pagespeed ShmMetadataCacheCheckpointIntervalSec 1;
# CriticalImagesBeaconEnabled is now on by default, but we disable in testing. # CriticalImagesBeaconEnabled is now on by default, but we disable in testing.
# With this option enabled, the inline image system test will currently fail. # With this option enabled, the inline image system test will currently fail.
# When critical image beaconing is enabled, only critical images are inlined. # When critical image beaconing is enabled, only critical images are inlined.
@@ -102,19 +79,6 @@ http {
pagespeed StatisticsLogging on; pagespeed StatisticsLogging on;
pagespeed LogDir "@@TEST_TMP@@/logdir"; pagespeed LogDir "@@TEST_TMP@@/logdir";
# Expanded to CentralControllerPort directive when RUN_CONTROLLER_TEST=on
@@CONTROLLER@@
server {
# This is the default vhost for @@SECONDARY_PORT@@
# Your request will land here when you pass in an unknown host.
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name default.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel CoreFilters;
}
server { server {
# Sets up a logical home-page server on # Sets up a logical home-page server on
# max-cacheable-content-length.example.com. This server is only used to # max-cacheable-content-length.example.com. This server is only used to
@@ -131,70 +95,6 @@ http {
pagespeed MaxCacheableContentLength 85; pagespeed MaxCacheableContentLength 85;
} }
# Test how load from file handles maximum sizes.
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name lff-large-files.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed MaxCacheableContentLength 4096;
pagespeed LoadFromFile
"http://lff-large-files.example.com/"
"@@SERVER_ROOT@@/";
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name lff-large-files-no-fallback.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed MaxCacheableContentLength 4096;
# http://lff-large-files-no-fallback.example.com/foo.css won't load, because
# we've configured a LoadFromFile pattern that doesn't match the path the
# webserver would take.
pagespeed LoadFromFile
"http://lff-large-files-no-fallback.example.com/"
"@@SERVER_ROOT@@/mod_pagespeed_example/styles/";
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name pagespeed-off.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed off;
pagespeed EnableFilters collapse_whitespace;
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name pagespeed-on.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed on;
pagespeed EnableFilters collapse_whitespace;
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name pagespeed-standby.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed standby;
pagespeed EnableFilters collapse_whitespace;
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name pagespeed-unplugged.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed unplugged;
pagespeed EnableFilters collapse_whitespace;
}
pagespeed UseNativeFetcher "@@NATIVE_FETCHER@@"; pagespeed UseNativeFetcher "@@NATIVE_FETCHER@@";
@@RESOLVER@@ @@RESOLVER@@
@@ -237,7 +137,7 @@ http {
# inline_images (ii), defer_javascript (dj), webp (jw) and lossless_webp # inline_images (ii), defer_javascript (dj), webp (jw) and lossless_webp
# (ws). # (ws).
if ($http_user_agent ~* if ($http_user_agent ~*
"Chrome/[2][3-9]+\.|Chrome/[3-9][0-9]+\.|Chrome/[0-9]{3,}\.") { "Chrome/[2][3-9]+\.|Chrome/[[3-9][0-9]+\.|Chrome/[0-9]{3,}\.") {
set $ps_capability_list "ll,ii,dj,jw,ws:"; set $ps_capability_list "ll,ii,dj,jw,ws:";
} }
# Cache-fragment 3: This fragment contains (a) Desktop User-Agents that # Cache-fragment 3: This fragment contains (a) Desktop User-Agents that
@@ -295,7 +195,7 @@ http {
# Block 6: Location block with proxy_cache directives. # Block 6: Location block with proxy_cache directives.
location /mod_pagespeed_test/cachable_rewritten_html/ { location /mod_pagespeed_test/cachable_rewritten_html/ {
# 1: Upstream PageSpeed server is running at localhost:@@PRIMARY_PORT@@. # 1: Upstream PageSpeed server is running at localhost:8050.
proxy_pass http://localhost:@@PRIMARY_PORT@@; proxy_pass http://localhost:@@PRIMARY_PORT@@;
# 2: Use htmlcache as the zone for caching. # 2: Use htmlcache as the zone for caching.
proxy_cache htmlcache; proxy_cache htmlcache;
@@ -435,29 +335,6 @@ http {
"id=1;percent=100;matches_device_type=mobile;enable=recompress_images"; "id=1;percent=100;matches_device_type=mobile;enable=recompress_images";
} }
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name experiment.ajax.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel CoreFilters;
pagespeed DisableFilters add_instrumentation;
pagespeed JsInlineMaxBytes 1;
pagespeed RunExperiment on;
pagespeed UseAnalyticsJs false;
pagespeed ExperimentSpec "id=1;percent=100;level=CoreFilters;enable=collapse_whitespace;options=JsInlineMaxBytes=1";
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name ajax.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel CoreFilters;
pagespeed EnableFilters add_instrumentation;
pagespeed JsInlineMaxBytes 1;
}
server { server {
listen @@SECONDARY_PORT@@; listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@; listen [::]:@@SECONDARY_PORT@@;
@@ -1307,7 +1184,7 @@ http {
listen [::]:@@SECONDARY_PORT@@; listen [::]:@@SECONDARY_PORT@@;
server_name remote-config.example.com; server_name remote-config.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@"; pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/standard"; pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT1@@/remote.cfg";
pagespeed RemoteConfigurationTimeoutMs 1500; pagespeed RemoteConfigurationTimeoutMs 1500;
} }
server { server {
@@ -1315,8 +1192,7 @@ http {
listen [::]:@@SECONDARY_PORT@@; listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-partially-invalid.example.com; server_name remote-config-partially-invalid.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@"; pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT2@@/remote.cfg";
"http://127.0.0.1:@@RCPORT@@/partly-invalid";
pagespeed RemoteConfigurationTimeoutMs 1500; pagespeed RemoteConfigurationTimeoutMs 1500;
} }
server { server {
@@ -1324,7 +1200,7 @@ http {
listen [::]:@@SECONDARY_PORT@@; listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-invalid.example.com; server_name remote-config-invalid.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@"; pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/invalid"; pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT3@@/remote.cfg";
pagespeed RemoteConfigurationTimeoutMs 1500; pagespeed RemoteConfigurationTimeoutMs 1500;
} }
server { server {
@@ -1332,7 +1208,7 @@ http {
listen [::]:@@SECONDARY_PORT@@; listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-failed-fetch.example.com; server_name remote-config-failed-fetch.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@"; pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/fail-future"; pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT5@@/remote.cfg";
pagespeed RemoteConfigurationTimeoutMs 1500; pagespeed RemoteConfigurationTimeoutMs 1500;
} }
server { server {
@@ -1340,7 +1216,7 @@ http {
listen [::]:@@SECONDARY_PORT@@; listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-slow-fetch.example.com; server_name remote-config-slow-fetch.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@"; pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/timeout"; pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT6@@/remote.cfg";
pagespeed RemoteConfigurationTimeoutMs 1500; pagespeed RemoteConfigurationTimeoutMs 1500;
} }
server { server {
@@ -1348,41 +1224,7 @@ http {
listen [::]:@@SECONDARY_PORT@@; listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-experiment.example.com; server_name remote-config-experiment.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@"; pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/experiment"; pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT7@@/remote.cfg";
pagespeed RemoteConfigurationTimeoutMs 1500;
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-slightly-slow-fetch.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl
"http://127.0.0.1:@@RCPORT@@/slightly-slow";
pagespeed RemoteConfigurationTimeoutMs 1500;
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-slightly-slow-expired-fetch.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/slow-expired";
pagespeed RemoteConfigurationTimeoutMs 1500;
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-forbidden.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/forbidden";
pagespeed RemoteConfigurationTimeoutMs 1500;
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name remote-config-initially-forbidden.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RemoteConfigurationUrl
"http://127.0.0.1:@@RCPORT@@/forbidden-once";
pagespeed RemoteConfigurationTimeoutMs 1500; pagespeed RemoteConfigurationTimeoutMs 1500;
} }
@@ -1411,17 +1253,6 @@ http {
add_header 'X-Accel-Redirect' 'blablabla'; add_header 'X-Accel-Redirect' 'blablabla';
} }
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name map-static-domain.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed MapRewriteDomain http://static-cdn.example.com
http://map-static-domain.example.com;
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters defer_javascript,rewrite_domains;
}
# Proxy + IPRO a gzip'd file for testing Issue 896. # Proxy + IPRO a gzip'd file for testing Issue 896.
server { server {
listen @@SECONDARY_PORT@@; listen @@SECONDARY_PORT@@;
@@ -1727,61 +1558,7 @@ http {
pagespeed InPlaceResourceOptimization on; pagespeed InPlaceResourceOptimization on;
pagespeed FileCachePath "@@FILE_CACHE@@"; pagespeed FileCachePath "@@FILE_CACHE@@";
} }
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name flush.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed RewriteDeadlinePerFlushMs 1;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffering off;
}
}
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name noflush.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed RewriteDeadlinePerFlushMs 1;
pagespeed FollowFlushes off;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffering off;
}
}
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name special-response.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
error_page 404 /mod_pagespeed_test/php_withflush.php;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
}
}
server { server {
pagespeed on; pagespeed on;
listen @@SECONDARY_PORT@@; listen @@SECONDARY_PORT@@;
@@ -1791,46 +1568,6 @@ http {
pagespeed RewriteLevel PassThrough; pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters debug; pagespeed EnableFilters debug;
} }
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name broken-fetch.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@/broken-fetch";
# Set up a fetch proxy that will 404 every request.
pagespeed FetchProxy "brokenfetch.example.com:1111";
# Prevent loopback fetch by explicitly authorizing the domain. Loopback
# fetches would work, and for this test, we're trying to have fetches fail,
# so they are instead picked up by the ipro recorder.
pagespeed Domain http://broken-fetch.example.com;
pagespeed InPlaceResourceOptimization on;
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_javascript;
pagespeed DisableFilters add_instrumentation;
pagespeed CriticalImagesBeaconEnabled false;
}
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name image-rewrite-with-flush.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed UrlValuedAttribute li data-thumb image;
pagespeed EnableFilters core;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffering off;
}
}
server { server {
listen @@PRIMARY_PORT@@; listen @@PRIMARY_PORT@@;
listen [::]:@@PRIMARY_PORT@@; listen [::]:@@PRIMARY_PORT@@;
@@ -1844,14 +1581,6 @@ http {
} }
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
# TODO(oschaaf): The following breaks nginx starting up, as the bad header
# value gets rejected during configuration parsing. However, we can't easily
# build a test for that right now.
# pagespeed AddResourceHeader "X-Fo\n\no" "Bar";
# pagespeed AddResourceHeader "X-Foo" "Ba\nr";
# For testing that AddResourceHeader gets passed through
pagespeed AddResourceHeader "X-Foo" "Bar";
add_header "" ""; add_header "" "";
} }
@@ -1903,8 +1632,6 @@ http {
pagespeed Library 43 1o978_K0_LNE5_ystNklf pagespeed Library 43 1o978_K0_LNE5_ystNklf
http://www.modpagespeed.com/rewrite_javascript.js; http://www.modpagespeed.com/rewrite_javascript.js;
pagespeed RetainComment " google_ad_section*"; pagespeed RetainComment " google_ad_section*";
pagespeed PermitIdsForCssCombining "allowed-to-combine-1-*";
pagespeed PermitIdsForCssCombining "allowed-to-combine-2-*";
# Test proxying of non-.pagespeed. resources. # Test proxying of non-.pagespeed. resources.
pagespeed MapProxyDomain http://localhost:@@PRIMARY_PORT@@/modpagespeed_http pagespeed MapProxyDomain http://localhost:@@PRIMARY_PORT@@/modpagespeed_http
@@ -2032,59 +1759,12 @@ http {
expires 5m; expires 5m;
} }
location /mod_pagespeed_test/example.json {
expires 10m;
}
location /mod_pagespeed_test/ipro/cc200/ {
add_header "Cache-Control" "max-age=200";
}
location /mod_pagespeed_test/ipro/cc200p/ {
add_header "Cache-Control" "private, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200nc/ {
add_header "Cache-Control" "no-cache, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200ns/ {
add_header "Cache-Control" "no-store, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200nt/ {
add_header "Cache-Control" "no-transform, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200sma5/ {
add_header "Cache-Control" "s-maxage=5, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200sma50/ {
add_header "Cache-Control" "s-maxage=50, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200sma50nsp/ {
add_header "Cache-Control" "s-maxage=50,max-age=200";
}
location /mod_pagespeed_test/ipro/cc9/ {
add_header "Cache-Control" "max-age=9";
}
location /mod_pagespeed_test/ipro/cc200cc9/ {
add_header "Cache-Control" "max-age=200, max-age=9";
}
location /mod_pagespeed_test/ipro/cc200sma50sma5/ {
add_header "Cache-Control" "max-age=200, s-maxage=50, s-maxage=5";
}
location /mod_pagespeed_test/ipro/cc200sma50cc9/ {
add_header "Cache-Control" "max-age=200, s-maxage=50, max-age=9";
}
location /mod_pagespeed_test/ipro/cc200sma50cc9nsp/ {
add_header "Cache-Control" "max-age=200,s-maxage=50,max-age=9";
}
location /mod_pagespeed_test/ipro/cc200sma50sma51/ {
add_header "Cache-Control" "max-age=200, s-maxage=50, s-maxage=51";
}
location /mod_pagespeed_test/ipro/wait/ { location /mod_pagespeed_test/ipro/wait/ {
# TODO(jmarantz): ModPagespeedInPlaceWaitForOptimized should be superfluous, # TODO(jmarantz): ModPagespeedInPlaceWaitForOptimized should be superfluous,
# or made equivalent to ModPagespeedInPlaceRewriteDeadlineMs -1, which waits # or made equivalent to ModPagespeedInPlaceRewriteDeadlineMs -1, which waits
# forever. Otherwise ModPagespeedInPlaceRewriteDeadlineMs should just have # forever. Otherwise ModPagespeedInPlaceRewriteDeadlineMs should just have
# the specified deadline. # the specified deadline.
# # See https://github.com/apache/incubator-pagespeed-mod/issues/1171 for more # # See https://github.com/pagespeed/mod_pagespeed/issues/1171 for more
# detailed discussion. # detailed discussion.
pagespeed InPlaceWaitForOptimized on; pagespeed InPlaceWaitForOptimized on;
} }
@@ -2119,9 +1799,7 @@ http {
} }
location /mod_pagespeed_test/ipro/instant/deadline/ { location /mod_pagespeed_test/ipro/instant/deadline/ {
set $ps_deadline -1; pagespeed InPlaceRewriteDeadlineMs -1;
pagespeed ImageRecompressionQuality $ps_deadline;
pagespeed InPlaceRewriteDeadlineMs $ps_deadline;
} }
# Test to make sure that user-authenticated resources do not get cached and # Test to make sure that user-authenticated resources do not get cached and
@@ -2169,10 +1847,9 @@ http {
pagespeed FetchHttps enable; pagespeed FetchHttps enable;
location /mod_pagespeed_test/https_fetch/ { location /mod_pagespeed_test/https_fetch/ {
pagespeed DisableFilters inline_images; pagespeed DisableFilters inline_images;
set $ps_gstatic "https://www.gstatic.com/psa/static";
pagespeed MapProxyDomain pagespeed MapProxyDomain
http://localhost:@@PRIMARY_PORT@@/https_gstatic_dot_com http://localhost:@@PRIMARY_PORT@@/https_gstatic_dot_com
$ps_gstatic; https://www.gstatic.com/psa/static;
} }
location /mod_pagespeed_test/strip_subresource_hints/default/ { location /mod_pagespeed_test/strip_subresource_hints/default/ {
@@ -2219,6 +1896,7 @@ http {
"@@SERVER_ROOT@@/mod_pagespeed_test/load_from_file/file_dir/httponly/"; "@@SERVER_ROOT@@/mod_pagespeed_test/load_from_file/file_dir/httponly/";
pagespeed LoadFromFileRuleMatch Disallow \.ssp.css$ps_dollar; pagespeed LoadFromFileRuleMatch Disallow \.ssp.css$ps_dollar;
pagespeed LoadFromFileRuleMatch Allow exception\.ssp\.css$ps_dollar; pagespeed LoadFromFileRuleMatch Allow exception\.ssp\.css$ps_dollar;
#charset koi8-r; #charset koi8-r;
#access_log logs/host.access.log main; #access_log logs/host.access.log main;
@@ -2265,7 +1943,6 @@ http {
image/svg+xml svg svgz; image/svg+xml svg svgz;
image/webp webp; image/webp webp;
application/json json;
application/java-archive jar war ear; application/java-archive jar war ear;
application/mac-binhex40 hqx; application/mac-binhex40 hqx;
application/msword doc; application/msword doc;
+44 -46
View File
@@ -1,21 +1,21 @@
#!/bin/bash #!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one #
# or more contributor license agreements. See the NOTICE file # Copyright 2013 Google Inc.
# distributed with this work for additional information #
# regarding copyright ownership. The ASF licenses this file # Licensed under the Apache License, Version 2.0 (the "License");
# to you under the Apache License, Version 2.0 (the # you may not use this file except in compliance with the License.
# "License"); you may not use this file except in compliance # You may obtain a copy of the License at
# with the License. You may obtain a copy of the License at #
# # http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0 #
# # Unless required by applicable law or agreed to in writing, software
# Unless required by applicable law or agreed to in writing, # distributed under the License is distributed on an "AS IS" BASIS,
# software distributed under the License is distributed on an # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # See the License for the specific language governing permissions and
# KIND, either express or implied. See the License for the # limitations under the License.
# specific language governing permissions and limitations #
# under the License. # Author: jefftk@google.com (Jeff Kaufman)
#
# Runs ngx_pagespeed system tests. # Runs ngx_pagespeed system tests.
# #
# Exits with status 0 if all tests pass. # Exits with status 0 if all tests pass.
@@ -23,19 +23,12 @@
# Exits with status 2 if command line args are wrong. # Exits with status 2 if command line args are wrong.
# #
# Usage: # Usage:
# ./run_tests.sh # ./run_tests.sh primary_port secondary_port mod_pagespeed_dir ngx_binary
# Or: # pagespeed_test_host
# ./run_tests.sh /path/to/mod_pagespeed /path/to/nginx/binary # Example:
# ./run_tests.sh 8050 8051 /path/to/mod_pagespeed /path/to/nginx/binary
# selfsigned.modpagespeed.com
# #
# If you built ngx_pagespeed with "scripts/build_ngx_pagespeed.sh --devel" then
# you don't need to pass any arguments to run_tests.sh. Otherwise, you'll need
# to tell it where to find a mod_pagespeed checkout (for example html files etc)
# and the nginx binary to test.
#
# By default the test script uses several ports. If you have a port conflict
# and need to override one you can do that by setting the relevant environment
# variable. For example:
# PRIMARY_PORT=1234 ./run_tests.sh /.../mod_pagespeed /.../nginx/binary
# Normally we test only with the native fetcher off. Set # Normally we test only with the native fetcher off. Set
# TEST_NATIVE_FETCHER=true to also test the native fetcher, set # TEST_NATIVE_FETCHER=true to also test the native fetcher, set
@@ -52,28 +45,28 @@ RUN_TESTS=${RUN_TESTS:-true}
# true. # true.
USE_VALGRIND=${USE_VALGRIND:-false} USE_VALGRIND=${USE_VALGRIND:-false}
if [ "$#" -eq 0 ]; then if [ "$#" -ne 5 ] ; then
MOD_PAGESPEED_DIR="testing-dependencies/mod_pagespeed/" echo "Usage: $0 primary_port secondary_port mod_pagespeed_dir"
NGINX_EXECUTABLE="nginx/sbin/nginx" echo " nginx_executable"
elif [ "$#" -eq 2 ]; then
MOD_PAGESPEED_DIR="$1"
NGINX_EXECUTABLE="$2"
else
echo "Usage: $0 [mod_pagespeed_dir nginx_executable]"
exit 2 exit 2
fi fi
: ${PRIMARY_PORT:=8050} PRIMARY_PORT="$1"
: ${SECONDARY_PORT:=8051} SECONDARY_PORT="$2"
: ${CONTROLLER_PORT:=8053} MOD_PAGESPEED_DIR="$3"
: ${RCPORT:=9991} NGINX_EXECUTABLE="$4"
: ${PAGESPEED_TEST_HOST:=selfsigned.modpagespeed.com} PAGESPEED_TEST_HOST="$5"
: ${PHP_PORT:=9000} RCPORT1=9991
RCPORT2=9992
RCPORT3=9993
RCPORT4=9994
RCPORT5=9995
RCPORT6=9996
RCPORT7=9997
this_dir="$( cd $(dirname "$0") && pwd)" this_dir="$( cd $(dirname "$0") && pwd)"
function run_test_checking_failure() { function run_test_checking_failure() {
"$MOD_PAGESPEED_DIR/install/start_php.sh" "$PHP_PORT"
USE_VALGRIND="$USE_VALGRIND" \ USE_VALGRIND="$USE_VALGRIND" \
PRIMARY_PORT="$PRIMARY_PORT" \ PRIMARY_PORT="$PRIMARY_PORT" \
SECONDARY_PORT="$SECONDARY_PORT" \ SECONDARY_PORT="$SECONDARY_PORT" \
@@ -81,8 +74,13 @@ function run_test_checking_failure() {
NGINX_EXECUTABLE="$NGINX_EXECUTABLE" \ NGINX_EXECUTABLE="$NGINX_EXECUTABLE" \
PAGESPEED_TEST_HOST="$PAGESPEED_TEST_HOST" \ PAGESPEED_TEST_HOST="$PAGESPEED_TEST_HOST" \
RUN_TESTS="$RUN_TESTS" \ RUN_TESTS="$RUN_TESTS" \
CONTROLLER_PORT="$CONTROLLER_PORT" \ RCPORT1="$RCPORT1" \
RCPORT="$RCPORT" \ RCPORT2="$RCPORT2" \
RCPORT3="$RCPORT3" \
RCPORT4="$RCPORT4" \
RCPORT5="$RCPORT5" \
RCPORT6="$RCPORT6" \
RCPORT7="$RCPORT7" \
bash "$this_dir/nginx_system_test.sh" bash "$this_dir/nginx_system_test.sh"
STATUS=$? STATUS=$?
echo "With $@ setup." echo "With $@ setup."
+17 -45
View File
@@ -1,19 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one # Copyright 2013 Google Inc.
# or more contributor license agreements. See the NOTICE file #
# distributed with this work for additional information # Licensed under the Apache License, Version 2.0 (the "License");
# regarding copyright ownership. The ASF licenses this file # you may not use this file except in compliance with the License.
# to you under the Apache License, Version 2.0 (the # You may obtain a copy of the License at
# "License"); you may not use this file except in compliance #
# with the License. You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0
# #
# http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software
# # distributed under the License is distributed on an "AS IS" BASIS,
# Unless required by applicable law or agreed to in writing, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# software distributed under the License is distributed on an # See the License for the specific language governing permissions and
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # limitations under the License.
# KIND, either express or implied. See the License for the #
# specific language governing permissions and limitations # Author: oschaaf@we-amp.com (Otto van der Schaaf)
# under the License
# The first few suppressions can be found in other modules # The first few suppressions can be found in other modules
# and easily found when searched for, and seem false positives. # and easily found when searched for, and seem false positives.
@@ -101,7 +101,7 @@
fun:ngx_process_events_and_timers fun:ngx_process_events_and_timers
fun:ngx_worker_process_cycle fun:ngx_worker_process_cycle
} }
# Mentioned in https://github.com/apache/incubator-pagespeed-ngx/issues/103 # Mentioned in https://github.com/pagespeed/ngx_pagespeed/issues/103
# Assuming a false postives as the issue is closed. # Assuming a false postives as the issue is closed.
{ {
<nginx false positive> <nginx false positive>
@@ -163,31 +163,3 @@
fun:_ZN3re23DFA10AddToQueueEPNS0_5WorkqEij fun:_ZN3re23DFA10AddToQueueEPNS0_5WorkqEij
... ...
} }
{
<re2 uninitialized value in optimized code>
Memcheck:Value8
fun:_ZNK3re210SparseSetTIvE8containsEi
...
}
{
<re2 uninitialized value in optimized code>
Memcheck:Cond
fun:_ZNK3re210SparseSetTIvE8containsEi
...
}
{
<re2 uninitialized value in optimized code>
Memcheck:Value8
fun:_ZNK3re211SparseArrayIiE9has_indexEi
...
}
{
<re2 uninitialized value in optimized code>
Memcheck:Cond
fun:_ZNK3re211SparseArrayIiE9has_indexEi
...
}