Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f75e891b74 | |||
| 4e2eb3de85 | |||
| c56611b6f4 | |||
| 7e25a0dc13 | |||
| acbd179cb1 | |||
| 46bc8ac065 | |||
| 2af2035bbd | |||
| 61f36e0b98 | |||
| 9711b52270 | |||
| 07a6647b65 | |||
| 787239d429 | |||
| e0a3bf223a | |||
| 21f9b5c9e3 | |||
| ff8969770d | |||
| b26e174d8b | |||
| 026f86dfc2 | |||
| 0db78f6e8c | |||
| 4af79a1e2b | |||
| ed20dabf66 | |||
| 067764aa92 | |||
| 84ab39e8e3 | |||
| 2cfbec12c5 | |||
| 9fd8c6f1bb | |||
| 1051a90c4e | |||
| 21a4a83b77 | |||
| 2b4c097d48 | |||
| 181875e80b | |||
| 371293af48 | |||
| ba78a8542b | |||
| 306cdf358a | |||
| 8ff08ed7e9 | |||
| fab4aac24e | |||
| 88e3d48d23 | |||
| 4ec7afe5a8 | |||
| 751f532162 | |||
| fbde0ace7e | |||
| 13e99f631b | |||
| 1c6c9f1a32 | |||
| daa6031294 | |||
| 5446303610 | |||
| 6c3cc29def | |||
| 17e8c7535a | |||
| 01e458ca0d | |||
| cd8c45fc86 | |||
| 9d6bfad665 | |||
| c253c3ba80 | |||
| 8c7c8a843a |
@@ -29,8 +29,8 @@ if [ "$mod_pagespeed_dir" = "unset" ] ; then
|
|||||||
echo " You need to separately download the pagespeed library:"
|
echo " You need to separately download the pagespeed library:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " $ cd /path/to/ngx_pagespeed"
|
echo " $ cd /path/to/ngx_pagespeed"
|
||||||
echo " $ wget https://dl.google.com/dl/page-speed/psol/1.10.33.0.tar.gz"
|
echo " $ wget https://dl.google.com/dl/page-speed/psol/1.11.33.4.tar.gz"
|
||||||
echo " $ tar -xzvf 1.10.33.0.tar.gz # expands to psol/"
|
echo " $ tar -xzvf 1.11.33.4.tar.gz # expands to psol/"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Or see the installation instructions:"
|
echo " Or see the installation instructions:"
|
||||||
echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build"
|
echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build"
|
||||||
@@ -80,10 +80,8 @@ ps_maybe_gpp_base=`basename $CC| sed s/gcc/g++/`
|
|||||||
ps_maybe_gpp="`dirname $CC`/$ps_maybe_gpp_base"
|
ps_maybe_gpp="`dirname $CC`/$ps_maybe_gpp_base"
|
||||||
if [ -n "$NGX_GCC_VER" -a \( -x "$ps_maybe_gpp" \) ]; then
|
if [ -n "$NGX_GCC_VER" -a \( -x "$ps_maybe_gpp" \) ]; then
|
||||||
LINK=$ps_maybe_gpp
|
LINK=$ps_maybe_gpp
|
||||||
NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT -lstdc++"
|
|
||||||
else
|
|
||||||
pagespeed_libs="-lstdc++"
|
|
||||||
fi
|
fi
|
||||||
|
pagespeed_libs="-lstdc++"
|
||||||
|
|
||||||
# The compiler needs to know that __sync_add_and_fetch_4 is ok,
|
# The compiler needs to know that __sync_add_and_fetch_4 is ok,
|
||||||
# and this requires an instruction that didn't exist on i586 or i386.
|
# and this requires an instruction that didn't exist on i586 or i386.
|
||||||
@@ -118,6 +116,13 @@ case "$NGX_GCC_VER" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# workaround for a bug in nginx-1.9.11, see:
|
||||||
|
# http://hg.nginx.org/nginx/rev/ff1e625ae55b
|
||||||
|
NGX_VERSION=`grep nginx_version src/core/nginx.h | sed -e 's/^.* \(.*\)$/\1/'`
|
||||||
|
if [ "$NGX_VERSION" = "1009011" ]; then
|
||||||
|
CFLAGS="$CFLAGS -Wno-write-strings"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$WNO_ERROR" = "YES" ]; then
|
if [ "$WNO_ERROR" = "YES" ]; then
|
||||||
CFLAGS="$CFLAGS -Wno-error"
|
CFLAGS="$CFLAGS -Wno-error"
|
||||||
fi
|
fi
|
||||||
@@ -152,17 +157,18 @@ pagespeed_include="\
|
|||||||
$mod_pagespeed_dir/third_party/chromium/src \
|
$mod_pagespeed_dir/third_party/chromium/src \
|
||||||
$mod_pagespeed_dir/third_party/google-sparsehash/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/protobuf/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 \
|
||||||
$mod_pagespeed_dir/out/$buildtype/obj/gen/protoc_out/instaweb \
|
$mod_pagespeed_dir/out/$buildtype/obj/gen/protoc_out/instaweb \
|
||||||
$mod_pagespeed_dir/third_party/apr/src/include \
|
$mod_pagespeed_dir/third_party/apr/src/include \
|
||||||
$mod_pagespeed_dir/third_party/aprutil/src/include \
|
$mod_pagespeed_dir/third_party/aprutil/src/include \
|
||||||
$mod_pagespeed_dir/third_party/apr/gen/arch/$os_name/$arch_name/include \
|
$mod_pagespeed_dir/third_party/apr/gen/arch/$os_name/$arch_name/include \
|
||||||
$mod_pagespeed_dir/third_party/aprutil/gen/arch/$os_name/$arch_name/include"
|
$mod_pagespeed_dir/third_party/aprutil/gen/arch/$os_name/$arch_name/include \
|
||||||
|
$mod_pagespeed_dir/url"
|
||||||
ngx_feature_path="$pagespeed_include"
|
ngx_feature_path="$pagespeed_include"
|
||||||
|
|
||||||
pagespeed_libs="$pagespeed_libs $psol_binary -lrt -pthread -lm"
|
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="
|
||||||
|
|
||||||
@@ -186,65 +192,7 @@ ngx_feature_test="
|
|||||||
# Test whether we have pagespeed and can compile and link against it.
|
# Test whether we have pagespeed and can compile and link against it.
|
||||||
. "$ngx_addon_dir/cpp_feature"
|
. "$ngx_addon_dir/cpp_feature"
|
||||||
|
|
||||||
if [ $ngx_found = yes ]; then
|
if [ $ngx_found = no ]; then
|
||||||
ps_src="$ngx_addon_dir/src"
|
|
||||||
ngx_addon_name=ngx_pagespeed
|
|
||||||
NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
|
|
||||||
$ps_src/log_message_handler.h \
|
|
||||||
$ps_src/ngx_base_fetch.h \
|
|
||||||
$ps_src/ngx_caching_headers.h \
|
|
||||||
$ps_src/ngx_event_connection.h \
|
|
||||||
$ps_src/ngx_fetch.h \
|
|
||||||
$ps_src/ngx_gzip_setter.h \
|
|
||||||
$ps_src/ngx_list_iterator.h \
|
|
||||||
$ps_src/ngx_message_handler.h \
|
|
||||||
$ps_src/ngx_pagespeed.h \
|
|
||||||
$ps_src/ngx_rewrite_driver_factory.h \
|
|
||||||
$ps_src/ngx_rewrite_options.h \
|
|
||||||
$ps_src/ngx_server_context.h \
|
|
||||||
$ps_src/ngx_url_async_fetcher.h \
|
|
||||||
$psol_binary"
|
|
||||||
NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
|
|
||||||
$ps_src/log_message_handler.cc \
|
|
||||||
$ps_src/ngx_base_fetch.cc \
|
|
||||||
$ps_src/ngx_caching_headers.cc \
|
|
||||||
$ps_src/ngx_event_connection.cc \
|
|
||||||
$ps_src/ngx_fetch.cc \
|
|
||||||
$ps_src/ngx_gzip_setter.cc \
|
|
||||||
$ps_src/ngx_list_iterator.cc \
|
|
||||||
$ps_src/ngx_message_handler.cc \
|
|
||||||
$ps_src/ngx_pagespeed.cc \
|
|
||||||
$ps_src/ngx_rewrite_driver_factory.cc \
|
|
||||||
$ps_src/ngx_rewrite_options.cc \
|
|
||||||
$ps_src/ngx_server_context.cc \
|
|
||||||
$ps_src/ngx_url_async_fetcher.cc"
|
|
||||||
# Save our sources in a separate var since we may need it in config.make
|
|
||||||
PS_NGX_SRCS="$NGX_ADDON_SRCS"
|
|
||||||
|
|
||||||
if [ "$position_aux" = "true" ] ; then
|
|
||||||
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES $ngx_addon_name"
|
|
||||||
else
|
|
||||||
# Make pagespeed run immediately before gzip and Brotli.
|
|
||||||
if echo $HTTP_FILTER_MODULES | grep ngx_http_brotli_filter_module >/dev/null; then
|
|
||||||
module=ngx_http_brotli_filter_module
|
|
||||||
elif [ $HTTP_GZIP = YES ]; then
|
|
||||||
module=$HTTP_GZIP_FILTER_MODULE
|
|
||||||
else
|
|
||||||
module=$HTTP_RANGE_HEADER_FILTER_MODULE
|
|
||||||
fi
|
|
||||||
|
|
||||||
HTTP_FILTER_MODULES=$(echo $HTTP_FILTER_MODULES |\
|
|
||||||
sed "s/$module/$module $ngx_addon_name/")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make the etag header filter run immediately before range header filter.
|
|
||||||
HTTP_FILTER_MODULES=$(echo $HTTP_FILTER_MODULES |\
|
|
||||||
sed "s/$HTTP_RANGE_HEADER_FILTER_MODULE/$HTTP_RANGE_HEADER_FILTER_MODULE ngx_pagespeed_etag_filter/")
|
|
||||||
|
|
||||||
CORE_LIBS="$CORE_LIBS $pagespeed_libs"
|
|
||||||
CORE_INCS="$CORE_INCS $pagespeed_include"
|
|
||||||
echo "List of modules (in reverse order of applicability): "$HTTP_FILTER_MODULES
|
|
||||||
else
|
|
||||||
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 obj/autoconf.err for more details.
|
Look in obj/autoconf.err for more details.
|
||||||
@@ -252,6 +200,115 @@ END
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ps_src="$ngx_addon_dir/src"
|
||||||
|
ngx_addon_name=ngx_pagespeed
|
||||||
|
NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
|
||||||
|
$ps_src/log_message_handler.h \
|
||||||
|
$ps_src/ngx_base_fetch.h \
|
||||||
|
$ps_src/ngx_caching_headers.h \
|
||||||
|
$ps_src/ngx_event_connection.h \
|
||||||
|
$ps_src/ngx_fetch.h \
|
||||||
|
$ps_src/ngx_gzip_setter.h \
|
||||||
|
$ps_src/ngx_list_iterator.h \
|
||||||
|
$ps_src/ngx_message_handler.h \
|
||||||
|
$ps_src/ngx_pagespeed.h \
|
||||||
|
$ps_src/ngx_rewrite_driver_factory.h \
|
||||||
|
$ps_src/ngx_rewrite_options.h \
|
||||||
|
$ps_src/ngx_server_context.h \
|
||||||
|
$ps_src/ngx_url_async_fetcher.h \
|
||||||
|
$psol_binary"
|
||||||
|
NPS_SRCS=" \
|
||||||
|
$ps_src/log_message_handler.cc \
|
||||||
|
$ps_src/ngx_base_fetch.cc \
|
||||||
|
$ps_src/ngx_caching_headers.cc \
|
||||||
|
$ps_src/ngx_event_connection.cc \
|
||||||
|
$ps_src/ngx_fetch.cc \
|
||||||
|
$ps_src/ngx_gzip_setter.cc \
|
||||||
|
$ps_src/ngx_list_iterator.cc \
|
||||||
|
$ps_src/ngx_message_handler.cc \
|
||||||
|
$ps_src/ngx_pagespeed.cc \
|
||||||
|
$ps_src/ngx_rewrite_driver_factory.cc \
|
||||||
|
$ps_src/ngx_rewrite_options.cc \
|
||||||
|
$ps_src/ngx_server_context.cc \
|
||||||
|
$ps_src/ngx_url_async_fetcher.cc"
|
||||||
|
# Save our sources in a separate var since we may need it in config.make
|
||||||
|
PS_NGX_SRCS="$NGX_ADDON_SRCS \
|
||||||
|
$NPS_SRCS"
|
||||||
|
|
||||||
|
# Make pagespeed run immediately before gzip and Brotli.
|
||||||
|
if echo $HTTP_FILTER_MODULES | grep ngx_http_brotli_filter_module >/dev/null; then
|
||||||
|
next=ngx_http_brotli_filter_module
|
||||||
|
elif [ $HTTP_GZIP = YES ]; then
|
||||||
|
next=ngx_http_gzip_filter_module
|
||||||
|
else
|
||||||
|
next=ngx_http_range_header_filter_module
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$ngx_module_link" ]; then
|
||||||
|
# nginx-1.9.11+
|
||||||
|
ngx_module_type=HTTP_FILTER
|
||||||
|
ngx_module_name="ngx_pagespeed ngx_pagespeed_etag_filter"
|
||||||
|
ngx_module_incs="$ngx_feature_path"
|
||||||
|
ngx_module_deps=
|
||||||
|
ngx_module_srcs="$NPS_SRCS"
|
||||||
|
ngx_module_libs="$ngx_feature_libs"
|
||||||
|
ngx_module_order="ngx_http_range_header_filter_module\
|
||||||
|
ngx_pagespeed_etag_filter\
|
||||||
|
ngx_http_gzip_filter_module \
|
||||||
|
ngx_http_brotli_filter_module \
|
||||||
|
ngx_pagespeed \
|
||||||
|
ngx_http_postpone_filter_module \
|
||||||
|
ngx_http_ssi_filter_module \
|
||||||
|
ngx_http_charset_filter_module \
|
||||||
|
ngx_http_xslt_filter_module \
|
||||||
|
ngx_http_image_filter_module \
|
||||||
|
ngx_http_sub_filter_module \
|
||||||
|
ngx_http_addition_filter_module \
|
||||||
|
ngx_http_gunzip_filter_module \
|
||||||
|
ngx_http_userid_filter_module \
|
||||||
|
ngx_http_headers_filter_module"
|
||||||
|
|
||||||
|
. auto/module
|
||||||
|
|
||||||
|
if [ $ngx_module_link != DYNAMIC ]; then
|
||||||
|
# ngx_module_order doesn't work with static modules,
|
||||||
|
# so we must re-order filters here.
|
||||||
|
if [ "$position_aux" = "true" ] ; then
|
||||||
|
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES $ngx_addon_name"
|
||||||
|
else
|
||||||
|
HTTP_FILTER_MODULES=$(echo $HTTP_FILTER_MODULES \
|
||||||
|
| sed "s/ngx_pagespeed//" \
|
||||||
|
| sed "s/$next/$next ngx_pagespeed/")
|
||||||
|
fi
|
||||||
|
# Make the etag header filter run immediately before range header filter.
|
||||||
|
HTTP_FILTER_MODULES=$(echo $HTTP_FILTER_MODULES \
|
||||||
|
| sed "s/ngx_pagespeed_etag_filter//" \
|
||||||
|
| sed "s/ngx_http_range_header_filter_module/ngx_http_range_header_filter_module ngx_pagespeed_etag_filter/")
|
||||||
|
else
|
||||||
|
# config.make is not executed for dynamic modules
|
||||||
|
CFLAGS="$CFLAGS -Wno-c++11-extensions"
|
||||||
|
if [ "$position_aux" = "true" ] ; then
|
||||||
|
ngx_module_type=HTTP_AUX_FILTER
|
||||||
|
ngx_module_order=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
CORE_LIBS="$CORE_LIBS $pagespeed_libs"
|
||||||
|
CORE_INCS="$CORE_INCS $pagespeed_include"
|
||||||
|
NGX_ADDON_SRCS="$PS_NGX_SRCS"
|
||||||
|
if [ "$position_aux" = "true" ] ; then
|
||||||
|
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES $ngx_addon_name"
|
||||||
|
else
|
||||||
|
HTTP_FILTER_MODULES=$(echo $HTTP_FILTER_MODULES | sed "s/$next/$next $ngx_addon_name/")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make the etag header filter run immediately before range header filter.
|
||||||
|
HTTP_FILTER_MODULES=$(echo $HTTP_FILTER_MODULES |\
|
||||||
|
sed "s/ngx_http_range_header_filter_module/ngx_http_range_header_filter_module ngx_pagespeed_etag_filter/")
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "List of modules (in reverse order of applicability): "$HTTP_FILTER_MODULES
|
||||||
|
|
||||||
# Test whether the compiler is compatible
|
# Test whether the compiler is compatible
|
||||||
ngx_feature="psol-compiler-compat"
|
ngx_feature="psol-compiler-compat"
|
||||||
ngx_feature_name=""
|
ngx_feature_name=""
|
||||||
|
|||||||
+55
-8
@@ -12,9 +12,12 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* Author: jefftk@google.com (Jeff Kaufman)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Author: jefftk@google.com (Jeff Kaufman)
|
#include "ngx_pagespeed.h" // Must come first, see comments in CollectHeaders.
|
||||||
|
|
||||||
#include <unistd.h> //for usleep
|
#include <unistd.h> //for usleep
|
||||||
|
|
||||||
#include "ngx_base_fetch.h"
|
#include "ngx_base_fetch.h"
|
||||||
@@ -23,6 +26,8 @@
|
|||||||
|
|
||||||
#include "ngx_pagespeed.h"
|
#include "ngx_pagespeed.h"
|
||||||
|
|
||||||
|
#include "net/instaweb/rewriter/public/rewrite_driver.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"
|
||||||
#include "pagespeed/kernel/base/google_message_handler.h"
|
#include "pagespeed/kernel/base/google_message_handler.h"
|
||||||
#include "pagespeed/kernel/base/message_handler.h"
|
#include "pagespeed/kernel/base/message_handler.h"
|
||||||
@@ -38,14 +43,18 @@ const char kDone = 'D';
|
|||||||
NgxEventConnection* NgxBaseFetch::event_connection = NULL;
|
NgxEventConnection* NgxBaseFetch::event_connection = NULL;
|
||||||
int NgxBaseFetch::active_base_fetches = 0;
|
int NgxBaseFetch::active_base_fetches = 0;
|
||||||
|
|
||||||
NgxBaseFetch::NgxBaseFetch(ngx_http_request_t* r,
|
NgxBaseFetch::NgxBaseFetch(StringPiece url,
|
||||||
|
ngx_http_request_t* r,
|
||||||
NgxServerContext* server_context,
|
NgxServerContext* server_context,
|
||||||
const RequestContextPtr& request_ctx,
|
const RequestContextPtr& request_ctx,
|
||||||
PreserveCachingHeaders preserve_caching_headers,
|
PreserveCachingHeaders preserve_caching_headers,
|
||||||
NgxBaseFetchType base_fetch_type)
|
NgxBaseFetchType base_fetch_type,
|
||||||
|
const RewriteOptions* options)
|
||||||
: AsyncFetch(request_ctx),
|
: AsyncFetch(request_ctx),
|
||||||
|
url_(url.data(), url.size()),
|
||||||
request_(r),
|
request_(r),
|
||||||
server_context_(server_context),
|
server_context_(server_context),
|
||||||
|
options_(options),
|
||||||
done_called_(false),
|
done_called_(false),
|
||||||
last_buf_sent_(false),
|
last_buf_sent_(false),
|
||||||
references_(2),
|
references_(2),
|
||||||
@@ -118,6 +127,8 @@ const char* BaseFetchTypeToCStr(NgxBaseFetchType type) {
|
|||||||
return "can't get here";
|
return "can't get here";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(oschaaf): replace the ngx_log_error with VLOGS or pass in a
|
||||||
|
// MessageHandler and use that.
|
||||||
void NgxBaseFetch::ReadCallback(const ps_event_data& data) {
|
void NgxBaseFetch::ReadCallback(const ps_event_data& data) {
|
||||||
NgxBaseFetch* base_fetch = reinterpret_cast<NgxBaseFetch*>(data.sender);
|
NgxBaseFetch* base_fetch = reinterpret_cast<NgxBaseFetch*>(data.sender);
|
||||||
ngx_http_request_t* r = base_fetch->request();
|
ngx_http_request_t* r = base_fetch->request();
|
||||||
@@ -138,19 +149,40 @@ void NgxBaseFetch::ReadCallback(const ps_event_data& data) {
|
|||||||
if (refcount == 0 || detached) {
|
if (refcount == 0 || detached) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ps_request_ctx_t* ctx = ps_get_request_context(r);
|
ps_request_ctx_t* ctx = ps_get_request_context(r);
|
||||||
|
|
||||||
CHECK(data.sender == ctx->base_fetch);
|
// If our request context was zeroed, skip this event.
|
||||||
CHECK(r->count > 0) << "r->count: " << r->count;
|
// See https://github.com/pagespeed/ngx_pagespeed/issues/1081
|
||||||
|
if (ctx == NULL) {
|
||||||
|
// Should not happen normally, when it does this message will cause our
|
||||||
|
// system tests to fail.
|
||||||
|
ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0,
|
||||||
|
"pagespeed [%p] skipping event: request context gone", r);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normally we expect the sender to equal the active NgxBaseFetch instance.
|
||||||
|
DCHECK(data.sender == ctx->base_fetch);
|
||||||
|
|
||||||
|
// If someone changed our request context or NgxBaseFetch, skip processing.
|
||||||
|
if (data.sender != ctx->base_fetch) {
|
||||||
|
ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0,
|
||||||
|
"pagespeed [%p] skipping event: event originating from disassociated"
|
||||||
|
" NgxBaseFetch instance.", r);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
|
bool run_posted = true;
|
||||||
// If we are unlucky enough to have our connection finalized mid-ipro-lookup,
|
// If we are unlucky enough to have our connection finalized mid-ipro-lookup,
|
||||||
// we must enter a different flow. Also see ps_in_place_check_header_filter().
|
// we must enter a different flow. Also see ps_in_place_check_header_filter().
|
||||||
if ((ctx->base_fetch->base_fetch_type_ != kIproLookup)
|
if ((ctx->base_fetch->base_fetch_type_ != kIproLookup)
|
||||||
&& r->connection->error) {
|
&& r->connection->error) {
|
||||||
ngx_log_error(NGX_LOG_DEBUG, ngx_cycle->log, 0,
|
ngx_log_error(NGX_LOG_DEBUG, ngx_cycle->log, 0,
|
||||||
"pagespeed [%p] request already finalized", r);
|
"pagespeed [%p] request already finalized %d", r, r->count);
|
||||||
rc = NGX_ERROR;
|
rc = NGX_ERROR;
|
||||||
|
run_posted = false;
|
||||||
} else {
|
} else {
|
||||||
rc = ps_base_fetch::ps_base_fetch_handler(r);
|
rc = ps_base_fetch::ps_base_fetch_handler(r);
|
||||||
}
|
}
|
||||||
@@ -163,8 +195,11 @@ void NgxBaseFetch::ReadCallback(const ps_event_data& data) {
|
|||||||
|
|
||||||
ngx_connection_t* c = r->connection;
|
ngx_connection_t* c = r->connection;
|
||||||
ngx_http_finalize_request(r, rc);
|
ngx_http_finalize_request(r, rc);
|
||||||
// See http://forum.nginx.org/read.php?2,253006,253061
|
|
||||||
ngx_http_run_posted_requests(c);
|
if (run_posted) {
|
||||||
|
// See http://forum.nginx.org/read.php?2,253006,253061
|
||||||
|
ngx_http_run_posted_requests(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NgxBaseFetch::Lock() {
|
void NgxBaseFetch::Lock() {
|
||||||
@@ -223,6 +258,13 @@ ngx_int_t NgxBaseFetch::CollectAccumulatedWrites(ngx_chain_t** link_ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngx_int_t NgxBaseFetch::CollectHeaders(ngx_http_headers_out_t* headers_out) {
|
ngx_int_t NgxBaseFetch::CollectHeaders(ngx_http_headers_out_t* headers_out) {
|
||||||
|
// nginx defines _FILE_OFFSET_BITS to 64, which changes the size of off_t.
|
||||||
|
// If a standard header is accidentally included before the nginx header,
|
||||||
|
// on a 32-bit system off_t will be 4 bytes and we don't assign all the
|
||||||
|
// bits of content_length_n. Sanity check that did not happen.
|
||||||
|
// This could use static_assert, but this file is not built with --std=c++11.
|
||||||
|
bool sanity_check_off_t[sizeof(off_t) == 8 ? 1 : -1] __attribute__ ((unused));
|
||||||
|
|
||||||
const ResponseHeaders* pagespeed_headers = response_headers();
|
const ResponseHeaders* pagespeed_headers = response_headers();
|
||||||
|
|
||||||
if (content_length_known()) {
|
if (content_length_known()) {
|
||||||
@@ -305,4 +347,9 @@ void NgxBaseFetch::HandleDone(bool success) {
|
|||||||
DecrefAndDeleteIfUnreferenced();
|
DecrefAndDeleteIfUnreferenced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NgxBaseFetch::IsCachedResultValid(const ResponseHeaders& headers) {
|
||||||
|
return OptionsAwareHTTPCacheCallback::IsCacheValid(
|
||||||
|
url_, *options_, request_context(), headers);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace net_instaweb
|
} // namespace net_instaweb
|
||||||
|
|||||||
+12
-2
@@ -43,6 +43,9 @@
|
|||||||
// events it handles.
|
// events it handles.
|
||||||
//
|
//
|
||||||
// When the last reference is dropped, this class will delete itself.
|
// When the last reference is dropped, this class will delete itself.
|
||||||
|
//
|
||||||
|
// TODO(jmarantz): consider sharing the cache-invalidation infrastructure
|
||||||
|
// with ApacheFetch, using a common base class.
|
||||||
|
|
||||||
#ifndef NGX_BASE_FETCH_H_
|
#ifndef NGX_BASE_FETCH_H_
|
||||||
#define NGX_BASE_FETCH_H_
|
#define NGX_BASE_FETCH_H_
|
||||||
@@ -59,6 +62,7 @@ extern "C" {
|
|||||||
#include "ngx_server_context.h"
|
#include "ngx_server_context.h"
|
||||||
|
|
||||||
#include "net/instaweb/http/public/async_fetch.h"
|
#include "net/instaweb/http/public/async_fetch.h"
|
||||||
|
#include "net/instaweb/rewriter/public/rewrite_options.h"
|
||||||
#include "pagespeed/kernel/base/string.h"
|
#include "pagespeed/kernel/base/string.h"
|
||||||
#include "pagespeed/kernel/http/headers.h"
|
#include "pagespeed/kernel/http/headers.h"
|
||||||
|
|
||||||
@@ -74,10 +78,12 @@ enum NgxBaseFetchType {
|
|||||||
|
|
||||||
class NgxBaseFetch : public AsyncFetch {
|
class NgxBaseFetch : public AsyncFetch {
|
||||||
public:
|
public:
|
||||||
NgxBaseFetch(ngx_http_request_t* r, NgxServerContext* server_context,
|
NgxBaseFetch(StringPiece url, ngx_http_request_t* r,
|
||||||
|
NgxServerContext* server_context,
|
||||||
const RequestContextPtr& request_ctx,
|
const RequestContextPtr& request_ctx,
|
||||||
PreserveCachingHeaders preserve_caching_headers,
|
PreserveCachingHeaders preserve_caching_headers,
|
||||||
NgxBaseFetchType base_fetch_type);
|
NgxBaseFetchType base_fetch_type,
|
||||||
|
const RewriteOptions* options);
|
||||||
virtual ~NgxBaseFetch();
|
virtual ~NgxBaseFetch();
|
||||||
|
|
||||||
// Statically initializes event_connection, require for PSOL and nginx to
|
// Statically initializes event_connection, require for PSOL and nginx to
|
||||||
@@ -125,6 +131,8 @@ 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_; }
|
||||||
|
|
||||||
|
virtual bool IsCachedResultValid(const ResponseHeaders& headers);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler);
|
virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler);
|
||||||
virtual bool HandleFlush(MessageHandler* handler);
|
virtual bool HandleFlush(MessageHandler* handler);
|
||||||
@@ -156,9 +164,11 @@ class NgxBaseFetch : public AsyncFetch {
|
|||||||
// Live count of NgxBaseFetch instances that are currently in use.
|
// Live count of NgxBaseFetch instances that are currently in use.
|
||||||
static int active_base_fetches;
|
static int active_base_fetches;
|
||||||
|
|
||||||
|
GoogleString url_;
|
||||||
ngx_http_request_t* request_;
|
ngx_http_request_t* request_;
|
||||||
GoogleString buffer_;
|
GoogleString buffer_;
|
||||||
NgxServerContext* server_context_;
|
NgxServerContext* server_context_;
|
||||||
|
const RewriteOptions* options_;
|
||||||
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,
|
||||||
|
|||||||
+5
-3
@@ -315,7 +315,9 @@ bool NgxFetch::Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ParseUrl()) {
|
if (!ParseUrl()) {
|
||||||
message_handler_->Message(kError, "NgxFetch: ParseUrl() failed");
|
message_handler_->Message(kError,
|
||||||
|
"NgxFetch: ParseUrl() failed for [%s]:%s",
|
||||||
|
str_url_.c_str(), url_.err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -938,8 +940,8 @@ void NgxFetch::FixUserAgent() {
|
|||||||
user_agent += "NgxNativeFetcher";
|
user_agent += "NgxNativeFetcher";
|
||||||
}
|
}
|
||||||
GoogleString version = StrCat(
|
GoogleString version = StrCat(
|
||||||
" ", kModPagespeedSubrequestUserAgent,
|
" (", kModPagespeedSubrequestUserAgent,
|
||||||
"/" MOD_PAGESPEED_VERSION_STRING "-" LASTCHANGE_STRING);
|
"/" MOD_PAGESPEED_VERSION_STRING "-" LASTCHANGE_STRING ")");
|
||||||
if (!StringPiece(user_agent).ends_with(version)) {
|
if (!StringPiece(user_agent).ends_with(version)) {
|
||||||
user_agent += version;
|
user_agent += version;
|
||||||
}
|
}
|
||||||
|
|||||||
+87
-54
@@ -284,7 +284,8 @@ ngx_int_t ps_base_fetch_handler(ngx_http_request_t* r) {
|
|||||||
// modules running after us to manipulate those responses.
|
// modules running after us to manipulate those responses.
|
||||||
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)) {
|
||||||
return status_code;
|
ps_release_base_fetch(ctx);
|
||||||
|
return ngx_http_filter_finalize_request(r, NULL, status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->preserve_caching_headers != kDontPreserveHeaders) {
|
if (ctx->preserve_caching_headers != kDontPreserveHeaders) {
|
||||||
@@ -302,6 +303,12 @@ ngx_int_t ps_base_fetch_handler(ngx_http_request_t* r) {
|
|||||||
STR_CASE_EQ_LITERAL(header->key, "Last-Modified") ||
|
STR_CASE_EQ_LITERAL(header->key, "Last-Modified") ||
|
||||||
STR_CASE_EQ_LITERAL(header->key, "Expires"))))) {
|
STR_CASE_EQ_LITERAL(header->key, "Expires"))))) {
|
||||||
header->hash = 0;
|
header->hash = 0;
|
||||||
|
if (STR_CASE_EQ_LITERAL(header->key, "Location")) {
|
||||||
|
// There's a possible issue with the location header, where setting
|
||||||
|
// the hash to 0 is not enough. See:
|
||||||
|
// https://github.com/nginx/nginx/blob/master/src/http/ngx_http_header_filter_module.c#L314
|
||||||
|
r->headers_out.location = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -452,11 +459,6 @@ void copy_response_headers_from_ngx(const ngx_http_request_t* r,
|
|||||||
|
|
||||||
headers->set_status_code(r->headers_out.status);
|
headers->set_status_code(r->headers_out.status);
|
||||||
|
|
||||||
if (r->headers_out.location != NULL) {
|
|
||||||
headers->Add(HttpAttributes::kLocation,
|
|
||||||
str_to_string_piece(r->headers_out.location->value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Manually copy over the content type because it's not included in
|
// Manually copy over the content type because it's not included in
|
||||||
// request_->headers_out.headers.
|
// request_->headers_out.headers.
|
||||||
headers->Add(HttpAttributes::kContentType,
|
headers->Add(HttpAttributes::kContentType,
|
||||||
@@ -464,7 +466,8 @@ void copy_response_headers_from_ngx(const ngx_http_request_t* r,
|
|||||||
|
|
||||||
// When we don't have a date header, set one with the current time.
|
// When we don't have a date header, set one with the current time.
|
||||||
if (headers->Lookup1(HttpAttributes::kDate) == NULL) {
|
if (headers->Lookup1(HttpAttributes::kDate) == NULL) {
|
||||||
headers->SetDate(ngx_current_msec);
|
PosixTimer timer;
|
||||||
|
headers->SetDate(timer.NowMs());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(oschaaf): ComputeCaching should be called in setupforhtml()?
|
// TODO(oschaaf): ComputeCaching should be called in setupforhtml()?
|
||||||
@@ -490,6 +493,10 @@ ngx_int_t copy_response_headers_to_ngx(
|
|||||||
|
|
||||||
ngx_int_t i;
|
ngx_int_t i;
|
||||||
for (i = 0 ; i < pagespeed_headers.NumAttributes() ; i++) {
|
for (i = 0 ; i < pagespeed_headers.NumAttributes() ; i++) {
|
||||||
|
// For IPRO cache misses, these gs_ variables may point to freed memory
|
||||||
|
// when nginx writes the headers to the output as the NgxBaseFetch instance
|
||||||
|
// that owns this memory gets released during request processing. So we
|
||||||
|
// copy these strings later on.
|
||||||
const GoogleString& name_gs = pagespeed_headers.Name(i);
|
const GoogleString& name_gs = pagespeed_headers.Name(i);
|
||||||
const GoogleString& value_gs = pagespeed_headers.Value(i);
|
const GoogleString& value_gs = pagespeed_headers.Value(i);
|
||||||
|
|
||||||
@@ -510,6 +517,9 @@ ngx_int_t copy_response_headers_to_ngx(
|
|||||||
} // else we don't preserve any headers.
|
} // else we don't preserve any headers.
|
||||||
|
|
||||||
ngx_str_t name, value;
|
ngx_str_t name, value;
|
||||||
|
value.len = value_gs.size();
|
||||||
|
value.data = reinterpret_cast<u_char*>(
|
||||||
|
string_piece_to_pool_string(r->pool, value_gs.c_str()));
|
||||||
|
|
||||||
// To prevent the gzip module from clearing weak etags, we output them
|
// To prevent the gzip module from clearing weak etags, we output them
|
||||||
// using a different name here. The etag header filter module runs behind
|
// using a different name here. The etag header filter module runs behind
|
||||||
@@ -520,11 +530,15 @@ ngx_int_t copy_response_headers_to_ngx(
|
|||||||
name.data = reinterpret_cast<u_char*>(
|
name.data = reinterpret_cast<u_char*>(
|
||||||
const_cast<char*>(kInternalEtagName));
|
const_cast<char*>(kInternalEtagName));
|
||||||
} else {
|
} else {
|
||||||
name.len = name_gs.length();
|
name.len = name_gs.size();
|
||||||
name.data = reinterpret_cast<u_char*>(const_cast<char*>(name_gs.data()));
|
name.data = reinterpret_cast<u_char*>(
|
||||||
|
string_piece_to_pool_string(r->pool, name_gs.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case string_piece_to_pool_string failed:
|
||||||
|
if (name.data == NULL || value.data == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
value.len = value_gs.length();
|
|
||||||
value.data = reinterpret_cast<u_char*>(const_cast<char*>(value_gs.data()));
|
|
||||||
|
|
||||||
// TODO(jefftk): If we're setting a cache control header we'd like to
|
// TODO(jefftk): If we're setting a cache control header we'd like to
|
||||||
// prevent any downstream code from changing it. Specifically, if we're
|
// prevent any downstream code from changing it. Specifically, if we're
|
||||||
@@ -535,24 +549,17 @@ ngx_int_t copy_response_headers_to_ngx(
|
|||||||
// net/instaweb/apache/header_util:AddResponseHeadersToRequest
|
// net/instaweb/apache/header_util:AddResponseHeadersToRequest
|
||||||
|
|
||||||
// Make copies of name and value to put into headers_out.
|
// Make copies of name and value to put into headers_out.
|
||||||
|
|
||||||
u_char* value_s = ngx_pstrdup(r->pool, &value);
|
|
||||||
if (value_s == NULL) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (STR_EQ_LITERAL(name, "Cache-Control")) {
|
if (STR_EQ_LITERAL(name, "Cache-Control")) {
|
||||||
ps_set_cache_control(r, const_cast<char*>(value_gs.c_str()));
|
ps_set_cache_control(r, reinterpret_cast<char*>(value.data));
|
||||||
continue;
|
continue;
|
||||||
} else if (STR_EQ_LITERAL(name, "Content-Type")) {
|
} else if (STR_EQ_LITERAL(name, "Content-Type")) {
|
||||||
// Unlike all the other headers, content_type is just a string.
|
// Unlike all the other headers, content_type is just a string.
|
||||||
headers_out->content_type.data = value_s;
|
headers_out->content_type = value;
|
||||||
headers_out->content_type.len = value.len;
|
|
||||||
|
|
||||||
// We should not include the charset when determining content_type_len, so
|
// We should not include the charset when determining content_type_len, so
|
||||||
// scan for the ';' that marks the start of the charset part.
|
// scan for the ';' that marks the start of the charset part.
|
||||||
for (ngx_uint_t i = 0; i < value.len; i++) {
|
for (ngx_uint_t i = 0; i < value.len; i++) {
|
||||||
if (value_s[i] == ';') {
|
if (value.data[i] == ';') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
headers_out->content_type_len = i + 1;
|
headers_out->content_type_len = i + 1;
|
||||||
@@ -570,11 +577,10 @@ ngx_int_t copy_response_headers_to_ngx(
|
|||||||
continue;
|
continue;
|
||||||
} else if (STR_EQ_LITERAL(name, "Transfer-Encoding")) {
|
} else if (STR_EQ_LITERAL(name, "Transfer-Encoding")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (STR_EQ_LITERAL(name, "Vary") && value.len
|
||||||
|
&& STR_EQ_LITERAL(value, "Accept-Encoding")) {
|
||||||
u_char* name_s = ngx_pstrdup(r->pool, &name);
|
ps_request_ctx_t* ctx = ps_get_request_context(r);
|
||||||
if (name_s == NULL) {
|
ctx->psol_vary_accept_only = true;
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_table_elt_t* header = static_cast<ngx_table_elt_t*>(
|
ngx_table_elt_t* header = static_cast<ngx_table_elt_t*>(
|
||||||
@@ -584,10 +590,10 @@ ngx_int_t copy_response_headers_to_ngx(
|
|||||||
}
|
}
|
||||||
|
|
||||||
header->hash = 1; // Include this header in the output.
|
header->hash = 1; // Include this header in the output.
|
||||||
|
header->key.data = name.data;
|
||||||
header->key.len = name.len;
|
header->key.len = name.len;
|
||||||
header->key.data = name_s;
|
header->value.data = value.data;
|
||||||
header->value.len = value.len;
|
header->value.len = value.len;
|
||||||
header->value.data = value_s;
|
|
||||||
|
|
||||||
// Populate the shortcuts to commonly used headers.
|
// Populate the shortcuts to commonly used headers.
|
||||||
if (STR_EQ_LITERAL(name, "Date")) {
|
if (STR_EQ_LITERAL(name, "Date")) {
|
||||||
@@ -636,7 +642,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
// If pagespeed is configured in some server block but not this one our
|
// If pagespeed is configured in some server block but not this one our
|
||||||
// per-request code will be invoked but server context will be null. In those
|
// per-request code will be invoked but server context will be null. In those
|
||||||
// cases we neet to short circuit, not changing anything. Currently our
|
// cases we need to short circuit, not changing anything. Currently our
|
||||||
// header filter, body filter, and content handler all do this, but if anyone
|
// header filter, body filter, and content handler all do this, but if anyone
|
||||||
// adds another way for nginx to give us a request to process we need to check
|
// adds another way for nginx to give us a request to process we need to check
|
||||||
// there as well.
|
// there as well.
|
||||||
@@ -677,6 +683,13 @@ char* ps_main_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf);
|
|||||||
char* ps_srv_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf);
|
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:
|
||||||
|
// https://github.com/pagespeed/ngx_pagespeed/commit/66f1b9aa
|
||||||
|
// but it's gone in recent revisions, so provide a compat #define if needed
|
||||||
|
#ifndef NGX_CONF_MULTI
|
||||||
|
#define NGX_CONF_MULTI 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO(jud): Verify that all the offsets should be NGX_HTTP_SRV_CONF_OFFSET and
|
// TODO(jud): Verify that all the offsets should be NGX_HTTP_SRV_CONF_OFFSET and
|
||||||
// not NGX_HTTP_LOC_CONF_OFFSET or NGX_HTTP_MAIN_CONF_OFFSET.
|
// not NGX_HTTP_LOC_CONF_OFFSET or NGX_HTTP_MAIN_CONF_OFFSET.
|
||||||
ngx_command_t ps_commands[] = {
|
ngx_command_t ps_commands[] = {
|
||||||
@@ -986,6 +999,7 @@ void* ps_create_main_conf(ngx_conf_t* cf) {
|
|||||||
"" /* hostname, not used */,
|
"" /* hostname, not used */,
|
||||||
-1 /* port, not used */);
|
-1 /* port, not used */);
|
||||||
active_driver_factory = cfg_m->driver_factory;
|
active_driver_factory = cfg_m->driver_factory;
|
||||||
|
active_driver_factory->LoggingInit(ngx_cycle->log, false);
|
||||||
cfg_m->driver_factory->Init();
|
cfg_m->driver_factory->Init();
|
||||||
ps_set_conf_cleanup_handler(cf, ps_cleanup_main_conf, cfg_m);
|
ps_set_conf_cleanup_handler(cf, ps_cleanup_main_conf, cfg_m);
|
||||||
return cfg_m;
|
return cfg_m;
|
||||||
@@ -1080,7 +1094,7 @@ char* ps_merge_srv_conf(ngx_conf_t* cf, void* parent, void* child) {
|
|||||||
|
|
||||||
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_conf_get_module_main_conf(cf, ngx_pagespeed));
|
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
|
||||||
cfg_m->driver_factory->set_main_conf(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);
|
||||||
// The server context sets some options when we call global_options(). So
|
// The server context sets some options when we call global_options(). So
|
||||||
@@ -1268,6 +1282,7 @@ ngx_int_t ps_decline_request(ngx_http_request_t* r) {
|
|||||||
ctx->driver->Cleanup();
|
ctx->driver->Cleanup();
|
||||||
ctx->driver = NULL;
|
ctx->driver = NULL;
|
||||||
ctx->location_field_set = false;
|
ctx->location_field_set = false;
|
||||||
|
ctx->psol_vary_accept_only = false;
|
||||||
|
|
||||||
// re init ctx
|
// re init ctx
|
||||||
ctx->html_rewrite = true;
|
ctx->html_rewrite = true;
|
||||||
@@ -1574,10 +1589,12 @@ void ps_release_base_fetch(ps_request_ctx_t* ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(chaizhenhua): merge into NgxBaseFetch ctor
|
// TODO(chaizhenhua): merge into NgxBaseFetch ctor
|
||||||
void ps_create_base_fetch(ps_request_ctx_t* ctx,
|
void ps_create_base_fetch(StringPiece url,
|
||||||
RequestContextPtr request_context,
|
ps_request_ctx_t* ctx,
|
||||||
RequestHeaders* request_headers,
|
RequestContextPtr request_context,
|
||||||
NgxBaseFetchType type) {
|
RequestHeaders* request_headers,
|
||||||
|
NgxBaseFetchType type,
|
||||||
|
const RewriteOptions* options) {
|
||||||
CHECK(ctx->base_fetch == NULL) << "Pre-existing base fetch!";
|
CHECK(ctx->base_fetch == NULL) << "Pre-existing base fetch!";
|
||||||
|
|
||||||
ngx_http_request_t* r = ctx->r;
|
ngx_http_request_t* r = ctx->r;
|
||||||
@@ -1587,9 +1604,9 @@ void ps_create_base_fetch(ps_request_ctx_t* ctx,
|
|||||||
// it, and call Done() on the associated parent (Proxy or Resource) fetch. If
|
// it, and call Done() on the associated parent (Proxy or Resource) fetch. If
|
||||||
// we fail before creating the associated fetch then we need to call Done() on
|
// we fail before creating the associated fetch then we need to call Done() on
|
||||||
// the BaseFetch ourselves.
|
// the BaseFetch ourselves.
|
||||||
ctx->base_fetch = new NgxBaseFetch(r, cfg_s->server_context,
|
ctx->base_fetch = new NgxBaseFetch(url, r, cfg_s->server_context, request_context,
|
||||||
request_context,
|
ctx->preserve_caching_headers, type,
|
||||||
ctx->preserve_caching_headers, type);
|
options);
|
||||||
ctx->base_fetch->SetRequestHeadersTakingOwnership(request_headers);
|
ctx->base_fetch->SetRequestHeadersTakingOwnership(request_headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1838,6 +1855,7 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
|
|||||||
ctx->recorder = NULL;
|
ctx->recorder = NULL;
|
||||||
ctx->url_string = url_string;
|
ctx->url_string = url_string;
|
||||||
ctx->location_field_set = false;
|
ctx->location_field_set = false;
|
||||||
|
ctx->psol_vary_accept_only = false;
|
||||||
|
|
||||||
// Set up a cleanup handler on the request.
|
// Set up a cleanup handler on the request.
|
||||||
ngx_http_cleanup_t* cleanup = ngx_http_cleanup_add(r, 0);
|
ngx_http_cleanup_t* cleanup = ngx_http_cleanup_add(r, 0);
|
||||||
@@ -1853,16 +1871,17 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
|
|||||||
if (pagespeed_resource) {
|
if (pagespeed_resource) {
|
||||||
// TODO(jefftk): Set using_spdy appropriately. See
|
// TODO(jefftk): Set using_spdy appropriately. See
|
||||||
// ProxyInterface::ProxyRequestCallback
|
// ProxyInterface::ProxyRequestCallback
|
||||||
ps_create_base_fetch(ctx, request_context, request_headers.release(),
|
ps_create_base_fetch(url.Spec(), ctx, request_context,
|
||||||
kPageSpeedResource);
|
request_headers.release(), kPageSpeedResource,
|
||||||
|
options);
|
||||||
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 */,
|
||||||
false /* using_spdy */, 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(ctx, request_context, request_headers.release(),
|
ps_create_base_fetch(url.Spec(), ctx, request_context,
|
||||||
kAdminPage);
|
request_headers.release(), kAdminPage, options);
|
||||||
QueryParams query_params;
|
QueryParams query_params;
|
||||||
query_params.ParseFromUrl(url);
|
query_params.ParseFromUrl(url);
|
||||||
|
|
||||||
@@ -1910,8 +1929,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
|
|||||||
|
|
||||||
if (options->domain_lawyer()->MapOriginUrl(
|
if (options->domain_lawyer()->MapOriginUrl(
|
||||||
url, &mapped_url, &host_header, &is_proxy) && is_proxy) {
|
url, &mapped_url, &host_header, &is_proxy) && is_proxy) {
|
||||||
ps_create_base_fetch(ctx, request_context, request_headers.release(),
|
ps_create_base_fetch(url.Spec(), ctx, request_context,
|
||||||
kPageSpeedProxy);
|
request_headers.release(), kPageSpeedProxy, options);
|
||||||
|
|
||||||
RewriteDriver* driver;
|
RewriteDriver* driver;
|
||||||
if (custom_options.get() == NULL) {
|
if (custom_options.get() == NULL) {
|
||||||
@@ -1935,8 +1954,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (html_rewrite) {
|
if (html_rewrite) {
|
||||||
ps_create_base_fetch(ctx, request_context, request_headers.release(),
|
ps_create_base_fetch(url.Spec(), ctx, request_context,
|
||||||
kHtmlTransform);
|
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.
|
||||||
RewriteDriver* driver;
|
RewriteDriver* driver;
|
||||||
|
|
||||||
@@ -1980,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(ctx, request_context, request_headers.release(),
|
ps_create_base_fetch(url.Spec(), ctx, request_context, request_headers.release(),
|
||||||
kIproLookup);
|
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;
|
||||||
@@ -2155,6 +2174,13 @@ ngx_int_t ps_etag_header_filter(ngx_http_request_t* r) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ps_request_ctx_t* ctx = ps_get_request_context(r);
|
||||||
|
#if (NGX_HTTP_GZIP)
|
||||||
|
if (ctx && ctx->psol_vary_accept_only) {
|
||||||
|
r->gzip_vary = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return ngx_http_ef_next_header_filter(r);
|
return ngx_http_ef_next_header_filter(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2478,8 +2504,8 @@ ngx_int_t send_out_headers_and_body(
|
|||||||
|
|
||||||
rc = ngx_http_send_header(r);
|
rc = ngx_http_send_header(r);
|
||||||
|
|
||||||
if (rc != NGX_OK) {
|
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
|
||||||
return NGX_ERROR;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the body.
|
// Send the body.
|
||||||
@@ -2916,7 +2942,7 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) {
|
|||||||
ngx_int_t ps_etag_filter_init(ngx_conf_t* cf) {
|
ngx_int_t ps_etag_filter_init(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_conf_get_module_main_conf(cf, ngx_pagespeed));
|
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
|
||||||
if (cfg_m->driver_factory != NULL) {
|
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
|
||||||
ngx_http_ef_next_header_filter = ngx_http_top_header_filter;
|
ngx_http_ef_next_header_filter = ngx_http_top_header_filter;
|
||||||
ngx_http_top_header_filter = ps_etag_header_filter;
|
ngx_http_top_header_filter = ps_etag_header_filter;
|
||||||
}
|
}
|
||||||
@@ -2998,6 +3024,11 @@ 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/pagespeed/ngx_pagespeed/issues/1220
|
||||||
|
if (cfg_m == NULL) {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
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_cycle_get_module_main_conf(cycle, ngx_http_core_module));
|
ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module));
|
||||||
ngx_http_core_srv_conf_t** cscfp = static_cast<ngx_http_core_srv_conf_t**>(
|
ngx_http_core_srv_conf_t** cscfp = static_cast<ngx_http_core_srv_conf_t**>(
|
||||||
@@ -3051,7 +3082,7 @@ ngx_int_t ps_init_module(ngx_cycle_t* cycle) {
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_m->driver_factory->LoggingInit(cycle->log);
|
cfg_m->driver_factory->LoggingInit(cycle->log, true);
|
||||||
cfg_m->driver_factory->RootInit();
|
cfg_m->driver_factory->RootInit();
|
||||||
} else {
|
} else {
|
||||||
delete cfg_m->driver_factory;
|
delete cfg_m->driver_factory;
|
||||||
@@ -3065,7 +3096,9 @@ void ps_exit_child_process(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));
|
||||||
NgxBaseFetch::Terminate();
|
NgxBaseFetch::Terminate();
|
||||||
cfg_m->driver_factory->ShutDown();
|
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
|
||||||
|
cfg_m->driver_factory->ShutDown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when nginx forks worker processes. No threads should be started
|
// Called when nginx forks worker processes. No threads should be started
|
||||||
@@ -3073,7 +3106,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
|
|||||||
ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
|
ngx_int_t ps_init_child_process(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));
|
||||||
if (cfg_m->driver_factory == NULL) {
|
if (cfg_m == NULL || cfg_m->driver_factory == NULL) {
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3083,7 +3116,7 @@ ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
|
|||||||
|
|
||||||
// ChildInit() will initialise all ServerContexts, which we need to
|
// ChildInit() will initialise all ServerContexts, which we need to
|
||||||
// create ProxyFetchFactories below
|
// create ProxyFetchFactories below
|
||||||
cfg_m->driver_factory->LoggingInit(cycle->log);
|
cfg_m->driver_factory->LoggingInit(cycle->log, true);
|
||||||
cfg_m->driver_factory->ChildInit();
|
cfg_m->driver_factory->ChildInit();
|
||||||
|
|
||||||
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*>(
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ typedef struct {
|
|||||||
// we should mirror that when we write it back. nginx may absolutify
|
// we should mirror that when we write it back. nginx may absolutify
|
||||||
// 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;
|
||||||
} 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);
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ NgxRewriteDriverFactory::NgxRewriteDriverFactory(
|
|||||||
SystemThreadSystem* system_thread_system, StringPiece hostname, int port)
|
SystemThreadSystem* system_thread_system, StringPiece hostname, int port)
|
||||||
: SystemRewriteDriverFactory(process_context, system_thread_system,
|
: SystemRewriteDriverFactory(process_context, system_thread_system,
|
||||||
NULL /* default shared memory runtime */, hostname, port),
|
NULL /* default shared memory runtime */, hostname, port),
|
||||||
main_conf_(NULL),
|
|
||||||
threads_started_(false),
|
threads_started_(false),
|
||||||
ngx_message_handler_(
|
ngx_message_handler_(
|
||||||
new NgxMessageHandler(timer(), thread_system()->NewMutex())),
|
new NgxMessageHandler(timer(), thread_system()->NewMutex())),
|
||||||
@@ -148,10 +147,19 @@ NamedLockManager* NgxRewriteDriverFactory::DefaultLockManager() {
|
|||||||
|
|
||||||
RewriteOptions* NgxRewriteDriverFactory::NewRewriteOptions() {
|
RewriteOptions* NgxRewriteDriverFactory::NewRewriteOptions() {
|
||||||
NgxRewriteOptions* options = new NgxRewriteOptions(thread_system());
|
NgxRewriteOptions* options = new NgxRewriteOptions(thread_system());
|
||||||
|
// TODO(jefftk): figure out why using SetDefaultRewriteLevel like
|
||||||
|
// 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
|
||||||
|
// defaulting CoreFilters.
|
||||||
|
// See: https://github.com/pagespeed/ngx_pagespeed/issues/1190
|
||||||
options->SetRewriteLevel(RewriteOptions::kCoreFilters);
|
options->SetRewriteLevel(RewriteOptions::kCoreFilters);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RewriteOptions* NgxRewriteDriverFactory::NewRewriteOptionsForQuery() {
|
||||||
|
return new NgxRewriteOptions(thread_system());
|
||||||
|
}
|
||||||
|
|
||||||
bool NgxRewriteDriverFactory::CheckResolver() {
|
bool NgxRewriteDriverFactory::CheckResolver() {
|
||||||
if (use_native_fetcher_ && resolver_ == NULL) {
|
if (use_native_fetcher_ && resolver_ == NULL) {
|
||||||
return false;
|
return false;
|
||||||
@@ -208,10 +216,19 @@ void NgxRewriteDriverFactory::StartThreads() {
|
|||||||
threads_started_ = true;
|
threads_started_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NgxRewriteDriverFactory::LoggingInit(ngx_log_t* log) {
|
void NgxRewriteDriverFactory::SetMainConf(NgxRewriteOptions* main_options) {
|
||||||
|
// Propagate process-scope options from the copy we had during nginx option
|
||||||
|
// parsing to our own.
|
||||||
|
if (main_options != NULL) {
|
||||||
|
default_options()->MergeOnlyProcessScopeOptions(*main_options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NgxRewriteDriverFactory::LoggingInit(
|
||||||
|
ngx_log_t* log, bool may_install_crash_handler) {
|
||||||
log_ = log;
|
log_ = log;
|
||||||
net_instaweb::log_message_handler::Install(log);
|
net_instaweb::log_message_handler::Install(log);
|
||||||
if (install_crash_handler()) {
|
if (may_install_crash_handler && install_crash_handler()) {
|
||||||
NgxMessageHandler::InstallCrashHandler(log);
|
NgxMessageHandler::InstallCrashHandler(log);
|
||||||
}
|
}
|
||||||
ngx_message_handler_->set_log(log);
|
ngx_message_handler_->set_log(log);
|
||||||
|
|||||||
@@ -63,8 +63,9 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
|
|||||||
virtual Timer* DefaultTimer();
|
virtual Timer* DefaultTimer();
|
||||||
virtual NamedLockManager* DefaultLockManager();
|
virtual NamedLockManager* DefaultLockManager();
|
||||||
// Create a new RewriteOptions. In this implementation it will be an
|
// Create a new RewriteOptions. In this implementation it will be an
|
||||||
// NgxRewriteOptions.
|
// NgxRewriteOptions, and it will have CoreFilters explicitly set.
|
||||||
virtual RewriteOptions* NewRewriteOptions();
|
virtual RewriteOptions* NewRewriteOptions();
|
||||||
|
virtual RewriteOptions* NewRewriteOptionsForQuery();
|
||||||
virtual ServerContext* NewDecodingServerContext();
|
virtual ServerContext* NewDecodingServerContext();
|
||||||
// Check resolver configured or not.
|
// Check resolver configured or not.
|
||||||
bool CheckResolver();
|
bool CheckResolver();
|
||||||
@@ -90,7 +91,7 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
|
|||||||
InitStats(statistics);
|
InitStats(statistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_main_conf(NgxRewriteOptions* main_conf) { main_conf_ = main_conf; }
|
void SetMainConf(NgxRewriteOptions* main_conf);
|
||||||
|
|
||||||
void set_resolver(ngx_resolver_t* resolver) {
|
void set_resolver(ngx_resolver_t* resolver) {
|
||||||
resolver_ = resolver;
|
resolver_ = resolver;
|
||||||
@@ -115,7 +116,7 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
|
|||||||
return process_script_variables_;
|
return process_script_variables_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoggingInit(ngx_log_t* log);
|
void LoggingInit(ngx_log_t* log, bool may_install_crash_handler);
|
||||||
|
|
||||||
virtual void ShutDownMessageHandlers();
|
virtual void ShutDownMessageHandlers();
|
||||||
|
|
||||||
@@ -133,10 +134,6 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
|
|||||||
private:
|
private:
|
||||||
Timer* timer_;
|
Timer* timer_;
|
||||||
|
|
||||||
// main_conf will have only options set in the main block. It may be NULL,
|
|
||||||
// and we do not take ownership.
|
|
||||||
NgxRewriteOptions* main_conf_;
|
|
||||||
|
|
||||||
bool threads_started_;
|
bool threads_started_;
|
||||||
NgxMessageHandler* ngx_message_handler_;
|
NgxMessageHandler* ngx_message_handler_;
|
||||||
NgxMessageHandler* ngx_html_parse_message_handler_;
|
NgxMessageHandler* ngx_html_parse_message_handler_;
|
||||||
|
|||||||
@@ -46,7 +46,23 @@ POSITION_AUX="${POSITION_AUX:-unset}"
|
|||||||
PRIMARY_HOSTNAME="localhost:$PRIMARY_PORT"
|
PRIMARY_HOSTNAME="localhost:$PRIMARY_PORT"
|
||||||
SECONDARY_HOSTNAME="localhost:$SECONDARY_PORT"
|
SECONDARY_HOSTNAME="localhost:$SECONDARY_PORT"
|
||||||
|
|
||||||
SERVER_ROOT="$MOD_PAGESPEED_DIR/src/install/"
|
this_dir="$( cd $(dirname "$0") && pwd)"
|
||||||
|
echo this_dir=$this_dir
|
||||||
|
TEST_TMP="$this_dir/tmp"
|
||||||
|
rm -rf "$TEST_TMP"
|
||||||
|
mkdir -p "$TEST_TMP"
|
||||||
|
echo TEST_TMP=$TEST_TMP
|
||||||
|
|
||||||
|
APACHE_DOC_SRC="$MOD_PAGESPEED_DIR/src/install/"
|
||||||
|
SERVER_ROOT="$TEST_TMP/root"
|
||||||
|
echo SERVER_ROOT=$SERVER_ROOT
|
||||||
|
rm -rf "$SERVER_ROOT"
|
||||||
|
mkdir -p "$SERVER_ROOT"
|
||||||
|
export APACHE_DOC_ROOT="$SERVER_ROOT"
|
||||||
|
|
||||||
|
mkdir -p "$APACHE_DOC_ROOT"
|
||||||
|
make -f "$APACHE_DOC_SRC/Makefile.tests" setup_doc_root \
|
||||||
|
INSTALL_DATA_DIR="$APACHE_DOC_SRC"
|
||||||
|
|
||||||
# We need check and check_not before we source SYSTEM_TEST_FILE that provides
|
# We need check and check_not before we source SYSTEM_TEST_FILE that provides
|
||||||
# them.
|
# them.
|
||||||
@@ -136,8 +152,6 @@ function fire_ab_load() {
|
|||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
|
|
||||||
this_dir="$( cd $(dirname "$0") && pwd)"
|
|
||||||
|
|
||||||
# stop nginx/valgrind
|
# stop nginx/valgrind
|
||||||
killall -s KILL nginx
|
killall -s KILL nginx
|
||||||
# TODO(oschaaf): Fix waiting for valgrind on 32 bits systems.
|
# TODO(oschaaf): Fix waiting for valgrind on 32 bits systems.
|
||||||
@@ -145,8 +159,6 @@ killall -s KILL memcheck-amd64-
|
|||||||
while pgrep nginx > /dev/null; do sleep 1; done
|
while pgrep nginx > /dev/null; do sleep 1; done
|
||||||
while pgrep memcheck > /dev/null; do sleep 1; done
|
while pgrep memcheck > /dev/null; do sleep 1; done
|
||||||
|
|
||||||
TEST_TMP="$this_dir/tmp"
|
|
||||||
rm -r "$TEST_TMP"
|
|
||||||
check_simple mkdir -p "$TEST_TMP"
|
check_simple mkdir -p "$TEST_TMP"
|
||||||
PROXY_CACHE="$TEST_TMP/proxycache"
|
PROXY_CACHE="$TEST_TMP/proxycache"
|
||||||
TMP_PROXY_CACHE="$TEST_TMP/tmpproxycache"
|
TMP_PROXY_CACHE="$TEST_TMP/tmpproxycache"
|
||||||
@@ -552,7 +564,7 @@ fetch_until "$URL" "fgrep -c .pagespeed." 1 --header=Host:www.google.com
|
|||||||
|
|
||||||
# If this accepts the Host header and fetches from google.com it will fail with
|
# If this accepts the Host header and fetches from google.com it will fail with
|
||||||
# a 404. Instead it should use a loopback fetch and succeed.
|
# a 404. Instead it should use a loopback fetch and succeed.
|
||||||
URL="$HOSTNAME/mod_pagespeed_example/.pagespeed.ce.8CfGBvwDhH.css"
|
URL="$HOSTNAME/mod_pagespeed_example/styles/big.css.pagespeed.ce.8CfGBvwDhH.css"
|
||||||
check wget -O /dev/null --header=Host:www.google.com "$URL"
|
check wget -O /dev/null --header=Host:www.google.com "$URL"
|
||||||
|
|
||||||
start_test statistics load
|
start_test statistics load
|
||||||
@@ -646,14 +658,14 @@ check touch "$SECONDARY_CACHE/cache.flush"
|
|||||||
check touch "$IPRO_CACHE/cache.flush"
|
check touch "$IPRO_CACHE/cache.flush"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
CACHE_TESTING_DIR="$SERVER_ROOT/mod_pagespeed_test/cache_flush/"
|
CACHE_TESTING_DIR="$SERVER_ROOT/cache_flush/"
|
||||||
CACHE_TESTING_TMPDIR="$CACHE_TESTING_DIR/$$"
|
CACHE_TESTING_TMPDIR="$CACHE_TESTING_DIR/$$"
|
||||||
mkdir "$CACHE_TESTING_TMPDIR"
|
mkdir "$CACHE_TESTING_TMPDIR"
|
||||||
cp "$CACHE_TESTING_DIR/cache_flush_test.html" "$CACHE_TESTING_TMPDIR/"
|
cp "$CACHE_TESTING_DIR/cache_flush_test.html" "$CACHE_TESTING_TMPDIR/"
|
||||||
CSS_FILE="$CACHE_TESTING_TMPDIR/update.css"
|
CSS_FILE="$CACHE_TESTING_TMPDIR/update.css"
|
||||||
echo ".class myclass { color: $COLOR0; }" > "$CSS_FILE"
|
echo ".class myclass { color: $COLOR0; }" > "$CSS_FILE"
|
||||||
|
|
||||||
URL_PATH="mod_pagespeed_test/cache_flush/$$/cache_flush_test.html"
|
URL_PATH="cache_flush/$$/cache_flush_test.html"
|
||||||
|
|
||||||
URL="$SECONDARY_HOSTNAME/$URL_PATH"
|
URL="$SECONDARY_HOSTNAME/$URL_PATH"
|
||||||
CACHE_A="--header=Host:cache_a.example.com"
|
CACHE_A="--header=Host:cache_a.example.com"
|
||||||
@@ -1241,6 +1253,36 @@ check_from "$OUT" fgrep -qi '404'
|
|||||||
MATCHES=$(echo "$OUT" | grep -c "Cache-Control: override") || true
|
MATCHES=$(echo "$OUT" | grep -c "Cache-Control: override") || true
|
||||||
check [ $MATCHES -eq 1 ]
|
check [ $MATCHES -eq 1 ]
|
||||||
|
|
||||||
|
start_test Custom 404 does not crash.
|
||||||
|
URL=http://custom404.example.com/mod_pagespeed_test/
|
||||||
|
URL+=A.doesnotexist.css.pagespeed.cf.0.css
|
||||||
|
# The 404 response makes wget exit with an error code, which we ignore.
|
||||||
|
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) || true
|
||||||
|
# We ignored the exit code, check if we got a 404 response.
|
||||||
|
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
|
||||||
|
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)
|
||||||
|
# First hit will be recorded and passed on untouched
|
||||||
|
MATCHES=$(echo "$OUT" | grep -c "Vary: Accept-Encoding") || true
|
||||||
|
check [ $MATCHES -eq 1 ]
|
||||||
|
|
||||||
|
# Fetch until we get a fully optimized response
|
||||||
|
http_proxy=$SECONDARY_HOSTNAME \
|
||||||
|
fetch_until $URL "fgrep -c W/\"PSA" 1 --save-headers
|
||||||
|
|
||||||
|
# Test the optimized response.
|
||||||
|
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
|
||||||
|
MATCHES=$(echo "$OUT" | grep -c "Vary: Accept-Encoding") || true
|
||||||
|
check [ $MATCHES -eq 1 ]
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
start_test Shutting down.
|
start_test Shutting down.
|
||||||
|
|
||||||
# Fire up some heavy load if ab is available to test a stressed shutdown
|
# Fire up some heavy load if ab is available to test a stressed shutdown
|
||||||
@@ -1316,6 +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\\].*Rewrite.*failed.*.pagespeed....0.foo.*" \
|
||||||
|
| grep -v "\\[warn\\].*A.blue.css.*but cannot access the original.*" \
|
||||||
|| true)
|
|| true)
|
||||||
|
|
||||||
check [ -z "$OUT" ]
|
check [ -z "$OUT" ]
|
||||||
|
|||||||
@@ -564,6 +564,10 @@ http {
|
|||||||
pagespeed UrlValuedAttribute img alt-src Image;
|
pagespeed UrlValuedAttribute img alt-src Image;
|
||||||
pagespeed UrlValuedAttribute video alt-a Image;
|
pagespeed UrlValuedAttribute video alt-a Image;
|
||||||
pagespeed UrlValuedAttribute video alt-b Image;
|
pagespeed UrlValuedAttribute video alt-b Image;
|
||||||
|
pagespeed UrlValuedAttribute link data-stylesheet Stylesheet;
|
||||||
|
pagespeed UrlValuedAttribute span data-stylesheet-a Stylesheet;
|
||||||
|
pagespeed UrlValuedAttribute span data-stylesheet-b Stylesheet;
|
||||||
|
pagespeed UrlValuedAttribute span data-stylesheet-c Stylesheet;
|
||||||
|
|
||||||
# Also test that we can redefine spec-defined attributes.
|
# Also test that we can redefine spec-defined attributes.
|
||||||
pagespeed UrlValuedAttribute blockquote cite Image;
|
pagespeed UrlValuedAttribute blockquote cite Image;
|
||||||
@@ -703,7 +707,44 @@ http {
|
|||||||
pagespeed EnableFilters rewrite_images,rewrite_css;
|
pagespeed EnableFilters rewrite_images,rewrite_css;
|
||||||
pagespeed EnableFilters convert_to_webp_lossless;
|
pagespeed EnableFilters convert_to_webp_lossless;
|
||||||
pagespeed EnableFilters in_place_optimize_for_browser;
|
pagespeed EnableFilters in_place_optimize_for_browser;
|
||||||
|
pagespeed JpegRecompressionQuality 75;
|
||||||
|
pagespeed WebpRecompressionQuality 70;
|
||||||
pagespeed InPlaceResourceOptimization on;
|
pagespeed InPlaceResourceOptimization on;
|
||||||
|
pagespeed AllowVaryOn "Accept";
|
||||||
|
pagespeed FileCachePath "@@IPRO_CACHE@@";
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen @@SECONDARY_PORT@@;
|
||||||
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
|
server_name ipro-for-browser-vary-on-auto.example.com;
|
||||||
|
root "@@SERVER_ROOT@@/mod_pagespeed_example";
|
||||||
|
pagespeed EnableFilters rewrite_images,rewrite_css;
|
||||||
|
pagespeed EnableFilters convert_to_webp_animated;
|
||||||
|
pagespeed EnableFilters convert_to_webp_lossless;
|
||||||
|
pagespeed EnableFilters in_place_optimize_for_browser;
|
||||||
|
pagespeed InPlaceResourceOptimization on;
|
||||||
|
# pagespeed AllowVaryOn "Accept"; # Default is "Auto".
|
||||||
|
pagespeed ImageRecompressionQuality 90;
|
||||||
|
pagespeed JpegRecompressionQuality 75;
|
||||||
|
pagespeed JpegRecompressionQualityForSmallScreens 55;
|
||||||
|
pagespeed JpegQualityForSaveData 35;
|
||||||
|
pagespeed WebpRecompressionQuality 70;
|
||||||
|
pagespeed WebpRecompressionQualityForSmallScreens 50;
|
||||||
|
pagespeed WebpQualityForSaveData 30;
|
||||||
|
pagespeed WebpAnimatedRecompressionQuality 60;
|
||||||
|
pagespeed FileCachePath "@@IPRO_CACHE@@";
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen @@SECONDARY_PORT@@;
|
||||||
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
|
server_name ipro-for-browser-vary-on-none.example.com;
|
||||||
|
root "@@SERVER_ROOT@@/mod_pagespeed_example";
|
||||||
|
pagespeed EnableFilters rewrite_images,in_place_optimize_for_browser;
|
||||||
|
pagespeed InPlaceResourceOptimization on;
|
||||||
|
pagespeed AllowVaryOn "None";
|
||||||
|
pagespeed ImageRecompressionQuality 75;
|
||||||
pagespeed FileCachePath "@@IPRO_CACHE@@";
|
pagespeed FileCachePath "@@IPRO_CACHE@@";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,7 +812,7 @@ http {
|
|||||||
server_name www.example.com;
|
server_name www.example.com;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
|
|
||||||
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@;
|
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
|
||||||
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
||||||
pagespeed RewriteLevel PassThrough;
|
pagespeed RewriteLevel PassThrough;
|
||||||
pagespeed EnableFilters rewrite_css,rewrite_images;
|
pagespeed EnableFilters rewrite_css,rewrite_images;
|
||||||
@@ -785,7 +826,7 @@ http {
|
|||||||
server_name origin.example.com;
|
server_name origin.example.com;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
|
|
||||||
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@;
|
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
|
||||||
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
||||||
pagespeed RewriteLevel PassThrough;
|
pagespeed RewriteLevel PassThrough;
|
||||||
pagespeed EnableFilters rewrite_css,rewrite_images;
|
pagespeed EnableFilters rewrite_css,rewrite_images;
|
||||||
@@ -799,7 +840,7 @@ http {
|
|||||||
server_name cdn.example.com;
|
server_name cdn.example.com;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
|
|
||||||
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@;
|
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
|
||||||
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
||||||
pagespeed RewriteLevel PassThrough;
|
pagespeed RewriteLevel PassThrough;
|
||||||
pagespeed EnableFilters rewrite_css,rewrite_images;
|
pagespeed EnableFilters rewrite_css,rewrite_images;
|
||||||
@@ -967,6 +1008,14 @@ http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen @@SECONDARY_PORT@@;
|
||||||
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
|
server_name custom404.example.com;
|
||||||
|
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||||
|
error_page 404 /404.html;
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen @@SECONDARY_PORT@@;
|
listen @@SECONDARY_PORT@@;
|
||||||
listen [::]:@@SECONDARY_PORT@@;
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
@@ -1221,6 +1270,44 @@ http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen @@SECONDARY_PORT@@;
|
||||||
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
|
server_name compressedcache.example.com;
|
||||||
|
pagespeed on;
|
||||||
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
|
pagespeed EnableFilters rewrite_css;
|
||||||
|
pagespeed HttpCacheCompressionLevel 9;
|
||||||
|
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 {
|
||||||
|
listen @@SECONDARY_PORT@@;
|
||||||
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
|
server_name uncompressedcache.example.com;
|
||||||
|
pagespeed on;
|
||||||
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
|
pagespeed EnableFilters rewrite_css;
|
||||||
|
pagespeed HttpCacheCompressionLevel 0;
|
||||||
|
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 @@SECONDARY_PORT@@;
|
listen @@SECONDARY_PORT@@;
|
||||||
listen [::]:@@SECONDARY_PORT@@;
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
@@ -1283,7 +1370,7 @@ http {
|
|||||||
listen [::]:@@SECONDARY_PORT@@;
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
server_name proxy-post-origin.example.com;
|
server_name proxy-post-origin.example.com;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
root "@@SERVER_ROOT@@";
|
root "@@SERVER_ROOT@@/";
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
@@ -1301,7 +1388,7 @@ http {
|
|||||||
listen [::]:@@SECONDARY_PORT@@;
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
server_name script-filters.example.com;
|
server_name script-filters.example.com;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
root "@@SERVER_ROOT@@";
|
root "@@SERVER_ROOT@@/";
|
||||||
set $filters "";
|
set $filters "";
|
||||||
set $domain_shards "cdn1.example.com,cdn2.example.com";
|
set $domain_shards "cdn1.example.com,cdn2.example.com";
|
||||||
if ($http_X_Script) {
|
if ($http_X_Script) {
|
||||||
@@ -1323,7 +1410,7 @@ http {
|
|||||||
pagespeed EnableCachePurge on;
|
pagespeed EnableCachePurge on;
|
||||||
|
|
||||||
pagespeed PurgeMethod PURGE;
|
pagespeed PurgeMethod PURGE;
|
||||||
root "@@SERVER_ROOT@@/mod_pagespeed_test/purge";
|
root "@@SERVER_ROOT@@/purge";
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@_purge";
|
pagespeed FileCachePath "@@FILE_CACHE@@_purge";
|
||||||
pagespeed DisableFilters add_instrumentation;
|
pagespeed DisableFilters add_instrumentation;
|
||||||
pagespeed RewriteLevel PassThrough;
|
pagespeed RewriteLevel PassThrough;
|
||||||
@@ -1339,7 +1426,7 @@ http {
|
|||||||
pagespeed EnableCachePurge on;
|
pagespeed EnableCachePurge on;
|
||||||
|
|
||||||
pagespeed PurgeMethod PURGE;
|
pagespeed PurgeMethod PURGE;
|
||||||
root "@@SERVER_ROOT@@/mod_pagespeed_test/purge";
|
root "@@SERVER_ROOT@@/purge";
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@_dir_on";
|
pagespeed FileCachePath "@@FILE_CACHE@@_dir_on";
|
||||||
pagespeed DisableFilters add_instrumentation;
|
pagespeed DisableFilters add_instrumentation;
|
||||||
pagespeed RewriteLevel PassThrough;
|
pagespeed RewriteLevel PassThrough;
|
||||||
@@ -1357,7 +1444,7 @@ http {
|
|||||||
pagespeed InPlaceResourceOptimization off;
|
pagespeed InPlaceResourceOptimization off;
|
||||||
pagespeed off;
|
pagespeed off;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
root "@@SERVER_ROOT@@";
|
root "@@SERVER_ROOT@@/";
|
||||||
location /mod_pagespeed_test/nostore {
|
location /mod_pagespeed_test/nostore {
|
||||||
add_header "Cache-Control" "max-age=12345";
|
add_header "Cache-Control" "max-age=12345";
|
||||||
add_header "Cache-Control" "public, no-store";
|
add_header "Cache-Control" "public, no-store";
|
||||||
@@ -1372,7 +1459,7 @@ http {
|
|||||||
pagespeed InPlaceResourceOptimization off;
|
pagespeed InPlaceResourceOptimization off;
|
||||||
pagespeed off;
|
pagespeed off;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
root "@@SERVER_ROOT@@";
|
root "@@SERVER_ROOT@@/";
|
||||||
location / {
|
location / {
|
||||||
add_header "PageSpeedFilters" "add_instrumentation";
|
add_header "PageSpeedFilters" "add_instrumentation";
|
||||||
}
|
}
|
||||||
@@ -1385,7 +1472,7 @@ http {
|
|||||||
pagespeed InPlaceResourceOptimization off;
|
pagespeed InPlaceResourceOptimization off;
|
||||||
pagespeed off;
|
pagespeed off;
|
||||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
root "@@SERVER_ROOT@@";
|
root "@@SERVER_ROOT@@/";
|
||||||
location / {
|
location / {
|
||||||
add_header "PageSpeed" "off";
|
add_header "PageSpeed" "off";
|
||||||
}
|
}
|
||||||
@@ -1463,7 +1550,24 @@ http {
|
|||||||
pagespeed GlobalAdminDomains
|
pagespeed GlobalAdminDomains
|
||||||
Allow everything-explicitly-allowed.example.com;
|
Allow everything-explicitly-allowed.example.com;
|
||||||
}
|
}
|
||||||
|
server {
|
||||||
|
listen @@SECONDARY_PORT@@;
|
||||||
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
|
server_name psol-vary.example.com;
|
||||||
|
pagespeed on;
|
||||||
|
pagespeed InPlaceResourceOptimization on;
|
||||||
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
pagespeed on;
|
||||||
|
listen @@SECONDARY_PORT@@;
|
||||||
|
listen [::]:@@SECONDARY_PORT@@;
|
||||||
|
server_name debug-filters.example.com;
|
||||||
|
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||||
|
pagespeed RewriteLevel PassThrough;
|
||||||
|
pagespeed EnableFilters debug;
|
||||||
|
}
|
||||||
server {
|
server {
|
||||||
listen @@PRIMARY_PORT@@;
|
listen @@PRIMARY_PORT@@;
|
||||||
listen [::]:@@PRIMARY_PORT@@;
|
listen [::]:@@PRIMARY_PORT@@;
|
||||||
@@ -1702,7 +1806,7 @@ http {
|
|||||||
# optimized.
|
# optimized.
|
||||||
location /mod_pagespeed_test/auth/ {
|
location /mod_pagespeed_test/auth/ {
|
||||||
auth_basic "Restricted";
|
auth_basic "Restricted";
|
||||||
auth_basic_user_file "@@SERVER_ROOT@@mod_pagespeed_test/auth/passwd.conf";
|
auth_basic_user_file "@@SERVER_ROOT@@/mod_pagespeed_test/auth/passwd.conf";
|
||||||
}
|
}
|
||||||
|
|
||||||
location /mod_pagespeed_test/ipro/cookie/ {
|
location /mod_pagespeed_test/ipro/cookie/ {
|
||||||
@@ -1748,6 +1852,25 @@ http {
|
|||||||
https://www.gstatic.com/psa/static;
|
https://www.gstatic.com/psa/static;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /mod_pagespeed_test/strip_subresource_hints/default/ {
|
||||||
|
pagespeed DisableFilters add_instrumentation;
|
||||||
|
pagespeed RewriteLevel CoreFilters;
|
||||||
|
pagespeed DisAllow *dontrewriteme*;
|
||||||
|
}
|
||||||
|
location /mod_pagespeed_test/strip_subresource_hints/default_passthrough/ {
|
||||||
|
pagespeed DisableFilters add_instrumentation;
|
||||||
|
pagespeed RewriteLevel PassThrough;
|
||||||
|
}
|
||||||
|
location /mod_pagespeed_test/strip_subresource_hints/preserve_on/ {
|
||||||
|
pagespeed DisableFilters add_instrumentation;
|
||||||
|
pagespeed PreserveSubresourceHints on;
|
||||||
|
pagespeed RewriteLevel CoreFilters;
|
||||||
|
}
|
||||||
|
location /mod_pagespeed_test/strip_subresource_hints/preserve_off/ {
|
||||||
|
pagespeed DisableFilters add_instrumentation;
|
||||||
|
pagespeed PreserveSubresourceHints off;
|
||||||
|
pagespeed RewriteLevel CoreFilters;
|
||||||
|
}
|
||||||
# $host implicitly tests script variable support. I'd love to test it more
|
# $host implicitly tests script variable support. I'd love to test it more
|
||||||
# directly, but so far this is the best I've come up with and duplicating
|
# directly, but so far this is the best I've come up with and duplicating
|
||||||
# the test doesn't seem to make sense.
|
# the test doesn't seem to make sense.
|
||||||
@@ -1755,6 +1878,11 @@ http {
|
|||||||
"http://$host:@@PRIMARY_PORT@@/mod_pagespeed_test/ipro/instant/"
|
"http://$host:@@PRIMARY_PORT@@/mod_pagespeed_test/ipro/instant/"
|
||||||
"@@SERVER_ROOT@@/mod_pagespeed_test/ipro/instant/";
|
"@@SERVER_ROOT@@/mod_pagespeed_test/ipro/instant/";
|
||||||
|
|
||||||
|
location /mod_pagespeed_test/public/ {
|
||||||
|
add_header "Cache-Control" "public, max-age=600";
|
||||||
|
pagespeed PreserveUrlRelativity off;
|
||||||
|
}
|
||||||
|
|
||||||
pagespeed EnableFilters remove_comments;
|
pagespeed EnableFilters remove_comments;
|
||||||
|
|
||||||
# Test LoadFromFile mapping by mapping one dir to another.
|
# Test LoadFromFile mapping by mapping one dir to another.
|
||||||
|
|||||||
+4
-2
@@ -23,9 +23,11 @@
|
|||||||
# 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 primary_port secondary_port mod_pagespeed_dir pagespeed_test_host
|
# ./run_tests.sh primary_port secondary_port mod_pagespeed_dir ngx_binary
|
||||||
|
# pagespeed_test_host
|
||||||
# Example:
|
# Example:
|
||||||
# ./run_tests.sh 8050 8051 /path/to/mod_pagespeed www.modpagespeed.com
|
# ./run_tests.sh 8050 8051 /path/to/mod_pagespeed /path/to/nginx/binary
|
||||||
|
# selfsigned.modpagespeed.com
|
||||||
#
|
#
|
||||||
|
|
||||||
# Normally we test only with the native fetcher off. Set
|
# Normally we test only with the native fetcher off. Set
|
||||||
|
|||||||
Reference in New Issue
Block a user