Initial commit
This commit is contained in:
Executable
+1464
@@ -0,0 +1,1464 @@
|
||||
#!/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)
|
||||
#
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Exits with status 0 if all tests pass.
|
||||
# Exits with status 1 immediately if any test fails.
|
||||
# Exits with status 2 if command line args are wrong.
|
||||
# Exits with status 3 if all failures were expected.
|
||||
# Exits with status 4 if instructed not to run any tests.
|
||||
|
||||
# Inherits the following from environment variables:
|
||||
: ${USE_VALGRIND:?"Set USE_VALGRIND to true or false"}
|
||||
: ${NATIVE_FETCHER:?"Set NATIVE_FETCHER to off or on"}
|
||||
: ${PRIMARY_PORT:?"Set PRIMARY_PORT"}
|
||||
: ${SECONDARY_PORT:?"Set SECONDARY_PORT"}
|
||||
: ${CONTROLLER_PORT:?"Set CONTROLLER_PORT"}
|
||||
: ${RCPORT:?"Set RCPORT"}
|
||||
: ${MOD_PAGESPEED_DIR:?"Set MOD_PAGESPEED_DIR"}
|
||||
: ${NGINX_EXECUTABLE:?"Set NGINX_EXECUTABLE"}
|
||||
: ${PAGESPEED_TEST_HOST:?"Set PAGESPEED_TEST_HOST"}
|
||||
POSITION_AUX="${POSITION_AUX:-unset}"
|
||||
RUN_CONTROLLER_TEST="${RUN_CONTROLLER_TEST:-off}"
|
||||
|
||||
PRIMARY_HOSTNAME="localhost:$PRIMARY_PORT"
|
||||
SECONDARY_HOSTNAME="localhost:$SECONDARY_PORT"
|
||||
|
||||
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
|
||||
|
||||
if [ -d "$MOD_PAGESPEED_DIR/src" ]; then
|
||||
MOD_PAGESPEED_DIR+="/src"
|
||||
fi
|
||||
|
||||
APACHE_DOC_SRC="$MOD_PAGESPEED_DIR/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
|
||||
# them.
|
||||
function handle_failure_simple() {
|
||||
echo "FAIL"
|
||||
exit 1
|
||||
}
|
||||
function check_simple() {
|
||||
echo " check" "$@"
|
||||
"$@" || handle_failure_simple
|
||||
}
|
||||
function check_not_simple() {
|
||||
echo " check_not" "$@"
|
||||
"$@" && handle_failure_simple
|
||||
}
|
||||
|
||||
# Argument list:
|
||||
# host_name, path, post-data
|
||||
# Runs 5 keepalive requests both with and without gzip for a few times.
|
||||
# Curl will use keepalive when running multiple request with one command.
|
||||
# When post-data is empty, a get request will be executed.
|
||||
function keepalive_test() {
|
||||
HOST_NAME=$1
|
||||
URL="$SECONDARY_HOSTNAME$2"
|
||||
CURL_LOG_FILE="$1.curl.log"
|
||||
NGX_LOG_FILE="$1.error.log"
|
||||
POST_DATA=$3
|
||||
|
||||
for ((i=0; i < 10; i++)); do
|
||||
for accept_encoding in "" "gzip"; do
|
||||
if [ -z "$POST_DATA" ]; then
|
||||
curl -m 2 -S -s -v -H "Accept-Encoding: $accept_encoding" \
|
||||
-H "Host: $HOST_NAME" $URL $URL $URL $URL $URL > /dev/null \
|
||||
2>>"$TEST_TMP/$CURL_LOG_FILE" || true
|
||||
else
|
||||
curl -X POST --data "$POST_DATA" -m 2 -S -s -v \
|
||||
-H "Accept-Encoding: $accept_encoding" -H "Host: $HOST_NAME"\
|
||||
$URL $URL $URL $URL $URL > /dev/null \
|
||||
2>>"$TEST_TMP/$CURL_LOG_FILE" || true
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Filter the curl output from unimportant messages
|
||||
OUT=$(cat "$TEST_TMP/$CURL_LOG_FILE"\
|
||||
| grep -v "^[<>]"\
|
||||
| grep -v "^{ \\[data not shown"\
|
||||
| grep -v "^\\* About to connect"\
|
||||
| grep -v "^\\* Closing"\
|
||||
| grep -v "^\\* Connected to"\
|
||||
| grep -v "^\\* Re-using"\
|
||||
| grep -v "^\\* Connection.*left intact"\
|
||||
| grep -v "^} \\[data not shown"\
|
||||
| grep -v "^\\* upload completely sent off"\
|
||||
| grep -v "^\\* Found bundle for host"\
|
||||
| grep -v "^\\* connected"\
|
||||
| grep -v "^\\* Found bundle for host"\
|
||||
| grep -v "^\\* Adding handle"\
|
||||
| grep -v "^\\* Curl_addHandleToPipeline"\
|
||||
| grep -v "^\\* - Conn "\
|
||||
| grep -v "^\\* Server "\
|
||||
| grep -v "^\\* Trying.*\\.\\.\\."\
|
||||
| grep -v "^\\* Hostname was NOT found in DNS cache" \
|
||||
|| true)
|
||||
|
||||
# Nothing should remain after that.
|
||||
check [ -z "$OUT" ]
|
||||
|
||||
# Filter the nginx log from our vhost from unimportant messages.
|
||||
OUT=$(cat "$TEST_TMP/$NGX_LOG_FILE"\
|
||||
| grep -v "closed keepalive connection$" \
|
||||
| grep -v ".*Cache Flush.*" \
|
||||
|| true)
|
||||
|
||||
# Nothing should remain after that.
|
||||
check [ -z "$OUT" ]
|
||||
}
|
||||
|
||||
function fire_ab_load() {
|
||||
AB_PID="0"
|
||||
if hash ab 2>/dev/null; then
|
||||
ab -n 10000 -k -c 100 http://$PRIMARY_HOSTNAME/ &>/dev/null & AB_PID=$!
|
||||
# Sleep to allow some queueing up of requests
|
||||
else
|
||||
echo "ab is not available, not able to test stressed shutdown and reload."
|
||||
fi
|
||||
sleep 2
|
||||
}
|
||||
|
||||
# stop nginx/valgrind
|
||||
killall -s KILL nginx
|
||||
killall -s KILL memcheck-amd64-
|
||||
killall -s KILL memcheck-x86-
|
||||
SECONDS=0
|
||||
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"
|
||||
PROXY_CACHE="$TEST_TMP/proxycache"
|
||||
TMP_PROXY_CACHE="$TEST_TMP/tmpproxycache"
|
||||
ERROR_LOG="$TEST_TMP/error.log"
|
||||
ACCESS_LOG="$TEST_TMP/access.log"
|
||||
|
||||
# Check that we do ok with directories that already exist.
|
||||
FILE_CACHE="$TEST_TMP/file-cache"
|
||||
check_simple mkdir "$FILE_CACHE"
|
||||
|
||||
# And directories that don't.
|
||||
SECONDARY_CACHE="$TEST_TMP/file-cache/secondary/"
|
||||
IPRO_CACHE="$TEST_TMP/file-cache/ipro/"
|
||||
SHM_CACHE="$TEST_TMP/file-cache/intermediate/directories/with_shm/"
|
||||
|
||||
VALGRIND_OPTIONS=""
|
||||
|
||||
if $USE_VALGRIND; then
|
||||
DAEMON=off
|
||||
else
|
||||
DAEMON=on
|
||||
fi
|
||||
|
||||
if [ "$NATIVE_FETCHER" = "on" ]; then
|
||||
RESOLVER="resolver 8.8.8.8;"
|
||||
else
|
||||
RESOLVER=""
|
||||
fi
|
||||
|
||||
if [ "$RUN_CONTROLLER_TEST" = "on" ]; then
|
||||
CONTROLLER="pagespeed ExperimentalCentralControllerPort $CONTROLLER_PORT;"
|
||||
else
|
||||
CONTROLLER=""
|
||||
fi
|
||||
|
||||
# set up the config file for the test
|
||||
PAGESPEED_CONF="$TEST_TMP/pagespeed_test.conf"
|
||||
PAGESPEED_CONF_TEMPLATE="$this_dir/pagespeed_test.conf.template"
|
||||
# check for config file template
|
||||
check_simple test -e "$PAGESPEED_CONF_TEMPLATE"
|
||||
# create PAGESPEED_CONF by substituting on PAGESPEED_CONF_TEMPLATE
|
||||
echo > $PAGESPEED_CONF <<EOF
|
||||
This file is automatically generated from $PAGESPEED_CONF_TEMPLATE"
|
||||
by nginx_system_test.sh; don't edit here."
|
||||
EOF
|
||||
cat $PAGESPEED_CONF_TEMPLATE \
|
||||
| sed 's#@@DAEMON@@#'"$DAEMON"'#' \
|
||||
| sed 's#@@TEST_TMP@@#'"$TEST_TMP/"'#' \
|
||||
| sed 's#@@PROXY_CACHE@@#'"$PROXY_CACHE/"'#' \
|
||||
| sed 's#@@TMP_PROXY_CACHE@@#'"$TMP_PROXY_CACHE/"'#' \
|
||||
| sed 's#@@ERROR_LOG@@#'"$ERROR_LOG"'#' \
|
||||
| sed 's#@@ACCESS_LOG@@#'"$ACCESS_LOG"'#' \
|
||||
| sed 's#@@FILE_CACHE@@#'"$FILE_CACHE/"'#' \
|
||||
| sed 's#@@SECONDARY_CACHE@@#'"$SECONDARY_CACHE/"'#' \
|
||||
| sed 's#@@IPRO_CACHE@@#'"$IPRO_CACHE/"'#' \
|
||||
| sed 's#@@SHM_CACHE@@#'"$SHM_CACHE/"'#' \
|
||||
| sed 's#@@SERVER_ROOT@@#'"$SERVER_ROOT"'#' \
|
||||
| sed 's#@@PRIMARY_PORT@@#'"$PRIMARY_PORT"'#' \
|
||||
| sed 's#@@SECONDARY_PORT@@#'"$SECONDARY_PORT"'#' \
|
||||
| sed 's#@@CONTROLLER@@#'"$CONTROLLER"'#' \
|
||||
| sed 's#@@NATIVE_FETCHER@@#'"$NATIVE_FETCHER"'#' \
|
||||
| sed 's#@@RESOLVER@@#'"$RESOLVER"'#' \
|
||||
| sed 's#@@RCPORT@@#'"$RCPORT"'#' \
|
||||
| sed 's#@@PAGESPEED_TEST_HOST@@#'"$PAGESPEED_TEST_HOST"'#' \
|
||||
>> $PAGESPEED_CONF
|
||||
# make sure we substituted all the variables
|
||||
check_not_simple grep @@ $PAGESPEED_CONF
|
||||
|
||||
# start nginx with new config
|
||||
if $USE_VALGRIND; then
|
||||
(valgrind -q --leak-check=full --gen-suppressions=all \
|
||||
--show-possibly-lost=no --log-file=$TEST_TMP/valgrind.log \
|
||||
--suppressions="$this_dir/valgrind.sup" \
|
||||
$NGINX_EXECUTABLE -c $PAGESPEED_CONF) & VALGRIND_PID=$!
|
||||
trap "echo 'terminating valgrind!' && kill -s TERM $VALGRIND_PID" EXIT
|
||||
echo "Wait until nginx is ready to accept connections"
|
||||
while ! curl -I "http://$PRIMARY_HOSTNAME/mod_pagespeed_example/" 2>/dev/null; do
|
||||
sleep 0.1;
|
||||
done
|
||||
echo "Valgrind (pid:$VALGRIND_PID) is logging to $TEST_TMP/valgrind.log"
|
||||
else
|
||||
TRACE_FILE="$TEST_TMP/conf_loading_trace"
|
||||
$NGINX_EXECUTABLE -c $PAGESPEED_CONF >& "$TRACE_FILE"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "FAIL"
|
||||
cat $TRACE_FILE
|
||||
if [[ $(grep -c "unknown directive \"proxy_cache_purge\"" $TRACE_FILE) == 1 ]]; then
|
||||
echo "This test requires proxy_cache_purge. One way to do this:"
|
||||
echo "Run git clone https://github.com/FRiCKLE/ngx_cache_purge.git"
|
||||
echo "And compile nginx with the additional ngx_cache_purge module."
|
||||
fi
|
||||
rm $TRACE_FILE
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Helper methods used by downstream caching tests.
|
||||
|
||||
# Helper method that does a wget and verifies that the rewriting status matches
|
||||
# the $1 argument that is passed to this method.
|
||||
check_rewriting_status() {
|
||||
$WGET $WGET_ARGS $CACHABLE_HTML_LOC > $OUT_CONTENTS_FILE
|
||||
if $1; then
|
||||
check zgrep -q "pagespeed.ic" $OUT_CONTENTS_FILE
|
||||
else
|
||||
check_not zgrep -q "pagespeed.ic" $OUT_CONTENTS_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper method that obtains a gzipped response and verifies that rewriting
|
||||
# has happened. Also takes an extra parameter that identifies extra headers
|
||||
# to be added during wget.
|
||||
check_for_rewriting() {
|
||||
WGET_ARGS="$GZIP_WGET_ARGS $1" check_rewriting_status true
|
||||
}
|
||||
|
||||
# Helper method that obtains a gzipped response and verifies that no rewriting
|
||||
# has happened. Also takes an extra parameter that identifies extra headers
|
||||
# to be added during wget.
|
||||
check_for_no_rewriting() {
|
||||
WGET_ARGS="$GZIP_WGET_ARGS $1" check_rewriting_status false
|
||||
}
|
||||
|
||||
if $RUN_TESTS; then
|
||||
echo "Starting tests"
|
||||
else
|
||||
if $USE_VALGRIND; then
|
||||
# Clear valgrind trap
|
||||
trap - EXIT
|
||||
echo "To end valgrind, run 'kill -s TERM $VALGRIND_PID'"
|
||||
fi
|
||||
echo "Not running tests; commence manual testing"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# check_stat in system_test_helpers.sh needs to know whether statstistics are
|
||||
# enabled, which is always the case for ngx_pagespeed.
|
||||
statistics_enabled=1
|
||||
CACHE_FLUSH_TEST="on"
|
||||
CACHE_PURGE_METHODS="PURGE GET"
|
||||
|
||||
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
|
||||
PAGESPEED_DIR="$MOD_PAGESPEED_DIR/pagespeed"
|
||||
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
|
||||
echo "Not finding $SYSTEM_TEST_FILE -- is mod_pagespeed not in a parallel"
|
||||
echo "directory to ngx_pagespeed?"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
PSA_JS_LIBRARY_URL_PREFIX="pagespeed_custom_static"
|
||||
BEACON_HANDLER="ngx_pagespeed_beacon"
|
||||
STATISTICS_HANDLER="ngx_pagespeed_statistics"
|
||||
GLOBAL_STATISTICS_HANDLER="ngx_pagespeed_global_statistics"
|
||||
MESSAGES_HANDLER="ngx_pagespeed_message"
|
||||
STATISTICS_URL=http://$PRIMARY_HOSTNAME/$STATISTICS_HANDLER
|
||||
GLOBAL_STATISTICS_URL=http://$PRIMARY_HOSTNAME/$GLOBAL_STATISTICS_HANDLER
|
||||
|
||||
# An expected failure can be indicated like: "~In-place resource optimization~"
|
||||
PAGESPEED_EXPECTED_FAILURES="
|
||||
~Cache purging with PageSpeed off in vhost, but on in directory.~
|
||||
~2-pass ipro with long ModPagespeedInPlaceRewriteDeadline~
|
||||
~3-pass ipro with short ModPagespeedInPlaceRewriteDeadline~
|
||||
"
|
||||
|
||||
if [ "$POSITION_AUX" = "true" ] ; then
|
||||
PAGESPEED_EXPECTED_FAILURES+="
|
||||
~server-side includes~
|
||||
"
|
||||
fi
|
||||
|
||||
|
||||
# Some tests are flakey under valgrind. For now, add them to the expected
|
||||
# failures when running under valgrind.
|
||||
#
|
||||
# TODO(sligicki): When the prioritize critical css race condition is fixed, the
|
||||
# two prioritize_critical_css tests no longer need to be listed here.
|
||||
# TODO(oschaaf): Now that we wait after we send a SIGHUP for the new worker
|
||||
# process to handle requests, check if we can remove more from the expected
|
||||
# failures here under valgrind.
|
||||
if $USE_VALGRIND; then
|
||||
PAGESPEED_EXPECTED_FAILURES+="
|
||||
~combine_css Maximum size of combined CSS.~
|
||||
~prioritize_critical_css~
|
||||
~prioritize_critical_css Able to read POST data from temp file.~
|
||||
~IPRO flow doesn't copy uncacheable resources multiple times.~
|
||||
~inline_unauthorized_resources allows unauthorized css selectors~
|
||||
"
|
||||
fi
|
||||
|
||||
# The existing system test takes its arguments as positional parameters, and
|
||||
# wants different ones than we want, so we need to reset our positional args.
|
||||
set -- "$PRIMARY_HOSTNAME"
|
||||
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
|
||||
|
||||
start_test Test pagespeed directive inside if block inside location block.
|
||||
|
||||
URL="http://if-in-location.example.com/"
|
||||
URL+="mod_pagespeed_example/inline_javascript.html"
|
||||
|
||||
# When we specify the X-Custom-Header-Inline-Js that triggers an if block in the
|
||||
# config which turns on inline_javascript.
|
||||
WGET_ARGS="--header=X-Custom-Header-Inline-Js:Yes"
|
||||
http_proxy=$SECONDARY_HOSTNAME \
|
||||
fetch_until $URL 'grep -c document.write' 1
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $WGET_ARGS $URL)
|
||||
check_from "$OUT" fgrep "X-Inline-Javascript: Yes"
|
||||
check_not_from "$OUT" fgrep "inline_javascript.js"
|
||||
|
||||
# Without that custom header we don't trigger the if block, and shouldn't get
|
||||
# any inline javascript.
|
||||
WGET_ARGS=""
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $WGET_ARGS $URL)
|
||||
check_from "$OUT" fgrep "X-Inline-Javascript: No"
|
||||
check_from "$OUT" fgrep "inline_javascript.js"
|
||||
check_not_from "$OUT" fgrep "document.write"
|
||||
|
||||
# Tests related to rewritten response (downstream) caching.
|
||||
|
||||
if [ "$NATIVE_FETCHER" = "on" ]; then
|
||||
echo "Native fetcher doesn't support PURGE requests and so we can't use or"
|
||||
echo "test downstream caching."
|
||||
else
|
||||
CACHABLE_HTML_LOC="http://${SECONDARY_HOSTNAME}/mod_pagespeed_test/cachable_rewritten_html"
|
||||
CACHABLE_HTML_LOC+="/downstream_caching.html"
|
||||
TMP_LOG_LINE="proxy_cache.example.com GET /purge/mod_pagespeed_test/cachable_rewritten_"
|
||||
PURGE_REQUEST_IN_ACCESS_LOG=$TMP_LOG_LINE"html/downstream_caching.html.*(200)"
|
||||
|
||||
OUT_CONTENTS_FILE="$OUTDIR/gzipped.html"
|
||||
OUT_HEADERS_FILE="$OUTDIR/headers.html"
|
||||
GZIP_WGET_ARGS="-q -S --header=Accept-Encoding:gzip -o $OUT_HEADERS_FILE -O - "
|
||||
|
||||
# Number of downstream cache purges should be 0 here.
|
||||
CURRENT_STATS=$($WGET_DUMP $STATISTICS_URL)
|
||||
check_from "$CURRENT_STATS" egrep -q \
|
||||
"downstream_cache_purge_attempts:[[:space:]]*0"
|
||||
|
||||
# The 1st request results in a cache miss, non-rewritten response
|
||||
# produced by pagespeed code and a subsequent purge request.
|
||||
start_test Check for case where rewritten cache should get purged.
|
||||
check_for_no_rewriting "--header=Host:proxy_cache.example.com"
|
||||
check egrep -q "X-Cache: MISS" $OUT_HEADERS_FILE
|
||||
fetch_until $STATISTICS_URL \
|
||||
'grep -c successful_downstream_cache_purges:[[:space:]]*1' 1
|
||||
|
||||
check [ $(grep -ce "$PURGE_REQUEST_IN_ACCESS_LOG" $ACCESS_LOG) = 1 ];
|
||||
|
||||
# The 2nd request results in a cache miss (because of the previous purge),
|
||||
# rewritten response produced by pagespeed code and no new purge requests.
|
||||
start_test Check for case where rewritten cache should not get purged.
|
||||
check_for_rewriting "--header=Host:proxy_cache.example.com \
|
||||
--header=X-PSA-Blocking-Rewrite:psatest"
|
||||
check egrep -q "X-Cache: MISS" $OUT_HEADERS_FILE
|
||||
CURRENT_STATS=$($WGET_DUMP $STATISTICS_URL)
|
||||
check_from "$CURRENT_STATS" egrep -q \
|
||||
"downstream_cache_purge_attempts:[[:space:]]*1"
|
||||
check [ $(grep -ce "$PURGE_REQUEST_IN_ACCESS_LOG" $ACCESS_LOG) = 1 ];
|
||||
|
||||
# The 3rd request results in a cache hit (because the previous response is
|
||||
# now present in cache), rewritten response served out from cache and not
|
||||
# by pagespeed code and no new purge requests.
|
||||
start_test Check for case where there is a rewritten cache hit.
|
||||
check_for_rewriting "--header=Host:proxy_cache.example.com"
|
||||
check egrep -q "X-Cache: HIT" $OUT_HEADERS_FILE
|
||||
fetch_until $STATISTICS_URL \
|
||||
'grep -c downstream_cache_purge_attempts:[[:space:]]*1' 1
|
||||
check [ $(grep -ce "$PURGE_REQUEST_IN_ACCESS_LOG" $ACCESS_LOG) = 1 ];
|
||||
|
||||
# Enable one of the beaconing dependent filters and verify interaction
|
||||
# between beaconing and downstream caching logic, by verifying that
|
||||
# whenever beaconing code is present in the rewritten page, the
|
||||
# output is also marked as a cache-miss, indicating that the instrumentation
|
||||
# was done by the backend.
|
||||
start_test Check whether beaconing is accompanied by a BYPASS always.
|
||||
WGET_ARGS="-S --header=Host:proxy_cache.example.com \
|
||||
--header=X-Allow-Beacon:yes"
|
||||
CACHABLE_HTML_LOC+="?PageSpeedFilters=lazyload_images"
|
||||
fetch_until -gzip $CACHABLE_HTML_LOC \
|
||||
"zgrep -c \"pagespeed\.CriticalImages\.Run\"" 1
|
||||
check egrep -q 'X-Cache: BYPASS' $WGET_OUTPUT
|
||||
check fgrep -q 'Cache-Control: no-cache, max-age=0' $WGET_OUTPUT
|
||||
|
||||
fi
|
||||
|
||||
start_test "Custom statistics paths in server block"
|
||||
|
||||
# Served on normal paths by default.
|
||||
URL="inherit-paths.example.com/ngx_pagespeed_statistics"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q cache_time_us
|
||||
|
||||
URL="inherit-paths.example.com/ngx_pagespeed_message"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q Info
|
||||
|
||||
URL="inherit-paths.example.com/pagespeed_console"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q console_div
|
||||
|
||||
URL="inherit-paths.example.com/pagespeed_admin/"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q Admin
|
||||
|
||||
# Not served on normal paths when overriden.
|
||||
URL="custom-paths.example.com/ngx_pagespeed_statistics"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check_not $WGET_DUMP $URL)
|
||||
check_not_from "$OUT" fgrep -q cache_time_us
|
||||
|
||||
URL="custom-paths.example.com/ngx_pagespeed_message"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check_not $WGET_DUMP $URL)
|
||||
check_not_from "$OUT" fgrep -q Info
|
||||
|
||||
URL="custom-paths.example.com/pagespeed_console"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check_not $WGET_DUMP $URL)
|
||||
check_not_from "$OUT" fgrep -q console_div
|
||||
|
||||
URL="custom-paths.example.com/pagespeed_admin/"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check_not $WGET_DUMP $URL)
|
||||
check_not_from "$OUT" fgrep -q Admin
|
||||
|
||||
# Served on custom paths when overriden
|
||||
URL="custom-paths.example.com/custom_pagespeed_statistics"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q cache_time_us
|
||||
|
||||
URL="custom-paths.example.com/custom_pagespeed_message"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q Info
|
||||
|
||||
URL="custom-paths.example.com/custom_pagespeed_console"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q console_div
|
||||
|
||||
URL="custom-paths.example.com/custom_pagespeed_admin/"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP $URL)
|
||||
check_from "$OUT" fgrep -q Admin
|
||||
|
||||
function gunzip_grep_0ff() {
|
||||
gunzip - | fgrep -q "color:#00f"
|
||||
echo $?
|
||||
}
|
||||
|
||||
start_test ipro with mod_deflate
|
||||
CSS_FILE="http://compressed-css.example.com/"
|
||||
CSS_FILE+="mod_pagespeed_test/ipro/mod_deflate/big.css"
|
||||
http_proxy=$SECONDARY_HOSTNAME fetch_until -gzip $CSS_FILE gunzip_grep_0ff 0
|
||||
|
||||
start_test ipro with reverse proxy of compressed content
|
||||
http_proxy=$SECONDARY_HOSTNAME \
|
||||
fetch_until -gzip http://ipro-proxy.example.com/big.css \
|
||||
gunzip_grep_0ff 0
|
||||
|
||||
# Also test the .pagespeed. version, to make sure we didn't accidentally gunzip
|
||||
# stuff above when we shouldn't have.
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET -q -O - \
|
||||
http://ipro-proxy.example.com/A.big.css.pagespeed.cf.0.css)
|
||||
check_from "$OUT" fgrep -q "big{color:#00f}"
|
||||
|
||||
start_test Respect X-Forwarded-Proto when told to
|
||||
FETCHED=$OUTDIR/x_forwarded_proto
|
||||
URL=$SECONDARY_HOSTNAME/mod_pagespeed_example/?PageSpeedFilters=add_base_tag
|
||||
HEADERS="--header=X-Forwarded-Proto:https --header=Host:xfp.example.com"
|
||||
check $WGET_DUMP -O $FETCHED $HEADERS $URL
|
||||
# When enabled, we respect X-Forwarded-Proto and thus list base as https.
|
||||
check fgrep -q '<base href="https://' $FETCHED
|
||||
|
||||
start_test Relative redirects starting with a forward slash survive.
|
||||
URL=http://xfp.example.com/redirect
|
||||
# wget seems a bit hairy here, when it comes to handling (relative) redirects.
|
||||
# I could not get this test going with wget, and that is why curl is used here.
|
||||
# TODO(oschaaf): debug wget some more and swap out curl here.
|
||||
OUT=$(curl -v --proxy $SECONDARY_HOSTNAME $URL 2>&1)
|
||||
check_from "$OUT" egrep -q '301 Moved Permanently'
|
||||
# The important part is that we don't end up with an absolute location here.
|
||||
check_from "$OUT" grep -q 'Location: /mod_pagespeed_example'
|
||||
check_not_from "$OUT" grep -q 'Location: http'
|
||||
|
||||
# Test that loopback route fetcher works with vhosts not listening on
|
||||
# 127.0.0.1
|
||||
start_test IP choice for loopback fetches.
|
||||
HOST_NAME="loopbackfetch.example.com"
|
||||
URL="$HOST_NAME/mod_pagespeed_example/rewrite_images.html"
|
||||
http_proxy=127.0.0.2:$SECONDARY_PORT \
|
||||
fetch_until $URL 'grep -c .pagespeed.ic' 2
|
||||
|
||||
# When we allow ourself to fetch a resource because the Host header tells us
|
||||
# that it is one of our resources, we should be fetching it from ourself.
|
||||
start_test "Loopback fetches go to local IPs without DNS lookup"
|
||||
|
||||
# If we're properly fetching from ourself we will issue loopback fetches for
|
||||
# /mod_pagespeed_example/combine_javascriptN.js, which will succeed, so
|
||||
# combining will work. If we're taking 'Host:www.google.com' to mean that we
|
||||
# should fetch from www.google.com then those fetches will fail because
|
||||
# google.com won't have /mod_pagespeed_example/combine_javascriptN.js and so
|
||||
# we'll not rewrite any resources.
|
||||
|
||||
URL="$HOSTNAME/mod_pagespeed_example/combine_javascript.html"
|
||||
URL+="?PageSpeed=on&PageSpeedFilters=combine_javascript"
|
||||
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
|
||||
# a 404. Instead it should use a loopback fetch and succeed.
|
||||
URL="$HOSTNAME/mod_pagespeed_example/styles/big.css.pagespeed.ce.8CfGBvwDhH.css"
|
||||
check wget -O /dev/null --header=Host:www.google.com "$URL"
|
||||
|
||||
start_test statistics load
|
||||
|
||||
OUT=$($WGET_DUMP $STATISTICS_URL)
|
||||
check_from "$OUT" grep 'PageSpeed Statistics'
|
||||
|
||||
start_test statistics handler full-featured
|
||||
OUT=$($WGET_DUMP $STATISTICS_URL?config)
|
||||
check_from "$OUT" grep "InPlaceResourceOptimization (ipro)"
|
||||
|
||||
start_test statistics handler properly sets JSON content-type
|
||||
OUT=$($WGET_DUMP $STATISTICS_URL?json)
|
||||
check_from "$OUT" grep "Content-Type: application/javascript"
|
||||
|
||||
start_test scrape stats works
|
||||
|
||||
# This needs to be before reload, when we clear the stats.
|
||||
check test $(scrape_stat image_rewrite_total_original_bytes) -ge 10000
|
||||
|
||||
# Test that ngx_pagespeed keeps working after nginx gets a signal to reload the
|
||||
# configuration. This is in the middle of tests so that significant work
|
||||
# happens both before and after.
|
||||
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.
|
||||
# TODO(oschaaf): make sure we wait for the new worker to get ready to accept
|
||||
# requests.
|
||||
fire_ab_load
|
||||
|
||||
URL="$EXAMPLE_ROOT/styles/W.rewrite_css_images.css.pagespeed.cf.Hash.css"
|
||||
check wget "$URL" -O /dev/null
|
||||
check_simple "$NGINX_EXECUTABLE" -s reload -c "$PAGESPEED_CONF"
|
||||
|
||||
# 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
|
||||
# tests unaware.
|
||||
function wait_for_new_worker() {
|
||||
while [ $(scrape_stat image_rewrite_total_original_bytes) -gt 0 ]; do
|
||||
echo "Waiting for new worker to get ready..."
|
||||
sleep .1
|
||||
done
|
||||
}
|
||||
wait_for_new_worker
|
||||
check wget "$URL" -O /dev/null
|
||||
if [ "$AB_PID" != "0" ]; then
|
||||
echo "Kill ab (pid: $AB_PID)"
|
||||
kill -s KILL $AB_PID &>/dev/null || true
|
||||
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.
|
||||
test_filter add_instrumentation beacons load.
|
||||
|
||||
# Nginx won't sent a Content-Length header on a 204, and while this is correct
|
||||
# per rfc 2616 wget hangs. Adding --no-http-keep-alive fixes that, as wget will.
|
||||
# send 'Connection: close' in its request headers, which will make nginx
|
||||
# respond with that as well. Check that we got a 204.
|
||||
BEACON_URL="http%3A%2F%2Fimagebeacon.example.com%2Fmod_pagespeed_test%2F"
|
||||
OUT=$(wget -q --save-headers -O - --no-http-keep-alive \
|
||||
"$PRIMARY_SERVER/$BEACON_HANDLER?ets=load:13&url=$BEACON_URL")
|
||||
check_from "$OUT" grep '^HTTP/1.1 204'
|
||||
# The $'...' tells bash to interpret c-style escapes, \r in this case.
|
||||
check_from "$OUT" grep $'^Cache-Control: max-age=0, no-cache\r$'
|
||||
|
||||
# Several cache flushing tests.
|
||||
|
||||
start_test Cache flushing works by touching cache.flush in cache directory.
|
||||
|
||||
# If we write fixed values into the css file here, there is a risk that
|
||||
# we will end up seeing the 'right' value because an old process hasn't
|
||||
# invalidated things yet, rather than because it updated to what we expect
|
||||
# in the first run followed by what we expect in the second run.
|
||||
# So, we incorporate the timestamp into RGB colors, using hours
|
||||
# prefixed with 1 (as 0-123 fits the 0-255 range) to get a second value.
|
||||
# A one-second precision is good enough since there is a sleep 2 below.
|
||||
COLOR_SUFFIX=`date +%H,%M,%S\)`
|
||||
COLOR0=rgb\($COLOR_SUFFIX
|
||||
COLOR1=rgb\(1$COLOR_SUFFIX
|
||||
|
||||
# We test on three different cache setups:
|
||||
#
|
||||
# 1. A virtual host using the normal FileCachePath.
|
||||
# 2. Another virtual host with a different FileCachePath.
|
||||
# 3. Another virtual host with a different CacheFlushFilename.
|
||||
#
|
||||
# This means we need to repeat many of the steps three times.
|
||||
|
||||
echo "Clear out our existing state before we begin the test."
|
||||
check touch "$FILE_CACHE/cache.flush"
|
||||
check touch "$FILE_CACHE/othercache.flush"
|
||||
check touch "$SECONDARY_CACHE/cache.flush"
|
||||
check touch "$IPRO_CACHE/cache.flush"
|
||||
sleep 1
|
||||
|
||||
CACHE_TESTING_DIR="$SERVER_ROOT/cache_flush/"
|
||||
CACHE_TESTING_TMPDIR="$CACHE_TESTING_DIR/$$"
|
||||
mkdir "$CACHE_TESTING_TMPDIR"
|
||||
cp "$CACHE_TESTING_DIR/cache_flush_test.html" "$CACHE_TESTING_TMPDIR/"
|
||||
CSS_FILE="$CACHE_TESTING_TMPDIR/update.css"
|
||||
echo ".class myclass { color: $COLOR0; }" > "$CSS_FILE"
|
||||
|
||||
URL_PATH="cache_flush/$$/cache_flush_test.html"
|
||||
|
||||
URL="$SECONDARY_HOSTNAME/$URL_PATH"
|
||||
CACHE_A="--header=Host:cache_a.example.com"
|
||||
fetch_until $URL "grep -c $COLOR0" 1 $CACHE_A
|
||||
|
||||
CACHE_B="--header=Host:cache_b.example.com"
|
||||
fetch_until $URL "grep -c $COLOR0" 1 $CACHE_B
|
||||
|
||||
CACHE_C="--header=Host:cache_c.example.com"
|
||||
fetch_until $URL "grep -c $COLOR0" 1 $CACHE_C
|
||||
|
||||
# All three caches are now populated.
|
||||
|
||||
# Track how many flushes were noticed by pagespeed processes up till this point
|
||||
# in time. Note that each process/vhost separately detects the 'flush'.
|
||||
|
||||
# A helper function just used here to look up the cache flush count for each
|
||||
# cache.
|
||||
function cache_flush_count_scraper {
|
||||
CACHE_LETTER=$1 # a, b, or c
|
||||
URL="$SECONDARY_HOSTNAME/ngx_pagespeed_statistics"
|
||||
HOST="--header=Host:cache_${CACHE_LETTER}.example.com"
|
||||
$WGET_DUMP $HOST $URL | egrep "^cache_flush_count:? " | awk '{print $2}'
|
||||
}
|
||||
|
||||
NUM_INITIAL_FLUSHES_A=$(cache_flush_count_scraper a)
|
||||
NUM_INITIAL_FLUSHES_B=$(cache_flush_count_scraper b)
|
||||
NUM_INITIAL_FLUSHES_C=$(cache_flush_count_scraper c)
|
||||
|
||||
# Now change the file to $COLOR1.
|
||||
echo ".class myclass { color: $COLOR1; }" > "$CSS_FILE"
|
||||
|
||||
# We expect to have a stale cache for 5 seconds, so the result should stay
|
||||
# $COLOR0. This only works because we have only one worker process. If we had
|
||||
# more than one then the worker process handling this request might be different
|
||||
# than the one that got the previous one, and it wouldn't be in cache.
|
||||
OUT="$($WGET_DUMP $CACHE_A "$URL")"
|
||||
check_from "$OUT" fgrep $COLOR0
|
||||
|
||||
OUT="$($WGET_DUMP $CACHE_B "$URL")"
|
||||
check_from "$OUT" fgrep $COLOR0
|
||||
|
||||
OUT="$($WGET_DUMP $CACHE_C "$URL")"
|
||||
check_from "$OUT" fgrep $COLOR0
|
||||
|
||||
# Flush the cache by touching a special file in the cache directory. Now
|
||||
# css gets re-read and we get $COLOR1 in the output. Sleep here to avoid
|
||||
# a race due to 1-second granularity of file-system timestamp checks. For
|
||||
# the test to pass we need to see time pass from the previous 'touch'.
|
||||
#
|
||||
# The three vhosts here all have CacheFlushPollIntervalSec set to 1.
|
||||
|
||||
sleep 2
|
||||
check touch "$FILE_CACHE/cache.flush"
|
||||
sleep 1
|
||||
|
||||
# Check that CACHE_A flushed properly.
|
||||
fetch_until $URL "grep -c $COLOR1" 1 $CACHE_A
|
||||
|
||||
# Cache was just flushed, so it should see see exactly one flush and the other
|
||||
# two should see none.
|
||||
NUM_MEDIAL_FLUSHES_A=$(cache_flush_count_scraper a)
|
||||
NUM_MEDIAL_FLUSHES_B=$(cache_flush_count_scraper b)
|
||||
NUM_MEDIAL_FLUSHES_C=$(cache_flush_count_scraper c)
|
||||
check [ $(($NUM_MEDIAL_FLUSHES_A - $NUM_INITIAL_FLUSHES_A)) -eq 1 ]
|
||||
check [ $NUM_MEDIAL_FLUSHES_B -eq $NUM_INITIAL_FLUSHES_B ]
|
||||
check [ $NUM_MEDIAL_FLUSHES_C -eq $NUM_INITIAL_FLUSHES_C ]
|
||||
|
||||
start_test Flushing one cache does not flush all caches.
|
||||
|
||||
# Check that CACHE_B and CACHE_C are still serving a stale version.
|
||||
OUT="$($WGET_DUMP $CACHE_B "$URL")"
|
||||
check_from "$OUT" fgrep $COLOR0
|
||||
|
||||
OUT="$($WGET_DUMP $CACHE_C "$URL")"
|
||||
check_from "$OUT" fgrep $COLOR0
|
||||
|
||||
start_test Secondary caches also flush.
|
||||
|
||||
# Now flush the other two files so they can see the color change.
|
||||
check touch "$FILE_CACHE/othercache.flush"
|
||||
check touch "$SECONDARY_CACHE/cache.flush"
|
||||
sleep 1
|
||||
|
||||
# Check that CACHE_B and C flushed properly.
|
||||
fetch_until $URL "grep -c $COLOR1" 1 $CACHE_B
|
||||
fetch_until $URL "grep -c $COLOR1" 1 $CACHE_C
|
||||
|
||||
# Now cache A should see no flush while caches B and C should each see a flush.
|
||||
NUM_FINAL_FLUSHES_A=$(cache_flush_count_scraper a)
|
||||
NUM_FINAL_FLUSHES_B=$(cache_flush_count_scraper b)
|
||||
NUM_FINAL_FLUSHES_C=$(cache_flush_count_scraper c)
|
||||
check [ $NUM_FINAL_FLUSHES_A -eq $NUM_MEDIAL_FLUSHES_A ]
|
||||
check [ $(($NUM_FINAL_FLUSHES_B - $NUM_MEDIAL_FLUSHES_B)) -eq 1 ]
|
||||
check [ $(($NUM_FINAL_FLUSHES_C - $NUM_MEDIAL_FLUSHES_C)) -eq 1 ]
|
||||
|
||||
# Clean up so we don't leave behind a stray file not under source control.
|
||||
rm -rf "$CACHE_TESTING_TMPDIR"
|
||||
|
||||
# connection_refused.html references modpagespeed.com:1023/someimage.png.
|
||||
# Pagespeed will attempt to connect to that host and port to fetch the input
|
||||
# resource using serf. We expect the connection to be refused. Relies on
|
||||
# "pagespeed Domain modpagespeed.com:1023" in the config. Also relies on
|
||||
# running after a cache-flush to avoid bypassing the serf fetch, since pagespeed
|
||||
# remembers fetch-failures in its cache for 5 minutes.
|
||||
start_test Connection refused handling
|
||||
|
||||
# Monitor the log starting now. tail -F will catch log rotations.
|
||||
FETCHER_REFUSED_PATH=$TESTTMP/instaweb_fetcher_refused
|
||||
rm -f $FETCHER_REFUSED_PATH
|
||||
LOG="$TEST_TMP/error.log"
|
||||
echo LOG = $LOG
|
||||
tail --sleep-interval=0.1 -F $LOG > $FETCHER_REFUSED_PATH &
|
||||
TAIL_PID=$!
|
||||
# Wait for tail to start.
|
||||
echo -n "Waiting for tail to start..."
|
||||
while [ ! -s $FETCHER_REFUSED_PATH ]; do
|
||||
sleep 0.1
|
||||
echo -n "."
|
||||
done
|
||||
echo "done!"
|
||||
|
||||
# Actually kick off the request.
|
||||
echo $WGET_DUMP $TEST_ROOT/connection_refused.html
|
||||
echo checking...
|
||||
check $WGET_DUMP $TEST_ROOT/connection_refused.html > /dev/null
|
||||
echo check done
|
||||
# If we are spewing errors, this gives time to spew lots of them.
|
||||
sleep 1
|
||||
# Wait up to 10 seconds for the background fetch of someimage.png to fail.
|
||||
if [ "$NATIVE_FETCHER" = "on" ]; then
|
||||
EXPECTED="111: Connection refused"
|
||||
else
|
||||
EXPECTED="Serf status 111"
|
||||
fi
|
||||
for i in {1..100}; do
|
||||
ERRS=$(grep -c "$EXPECTED" $FETCHER_REFUSED_PATH || true)
|
||||
if [ $ERRS -ge 1 ]; then
|
||||
break;
|
||||
fi;
|
||||
echo -n "."
|
||||
sleep 0.1
|
||||
done;
|
||||
echo "."
|
||||
# Kill the log monitor silently.
|
||||
kill $TAIL_PID
|
||||
wait $TAIL_PID 2> /dev/null || true
|
||||
check [ $ERRS -ge 1 ]
|
||||
|
||||
# TODO(jefftk): when we support ListOutstandingUrlsOnError uncomment the below
|
||||
#
|
||||
## Make sure we have the URL detail we expect because ListOutstandingUrlsOnError
|
||||
## is on in the config file.
|
||||
#echo Check that ListOutstandingUrlsOnError works
|
||||
#check grep "URL http://modpagespeed.com:1023/someimage.png active for " \
|
||||
# $FETCHER_REFUSED_PATH
|
||||
|
||||
start_test Blocking rewrite enabled.
|
||||
# We assume that blocking_rewrite_test_dont_reuse_1.jpg will not be
|
||||
# rewritten on the first request since it takes significantly more time to
|
||||
# rewrite than the rewrite deadline and it is not already accessed by
|
||||
# another request earlier.
|
||||
BLOCKING_REWRITE_URL="$TEST_ROOT/blocking_rewrite.html"
|
||||
BLOCKING_REWRITE_URL+="?PageSpeedFilters=rewrite_images"
|
||||
OUTFILE=$WGET_DIR/blocking_rewrite.out.html
|
||||
OLDSTATS=$WGET_DIR/blocking_rewrite_stats.old
|
||||
NEWSTATS=$WGET_DIR/blocking_rewrite_stats.new
|
||||
$WGET_DUMP $STATISTICS_URL > $OLDSTATS
|
||||
check $WGET_DUMP --header 'X-PSA-Blocking-Rewrite: psatest'\
|
||||
$BLOCKING_REWRITE_URL -O $OUTFILE
|
||||
$WGET_DUMP $STATISTICS_URL > $NEWSTATS
|
||||
check_stat $OLDSTATS $NEWSTATS image_rewrites 1
|
||||
check_stat $OLDSTATS $NEWSTATS cache_hits 0
|
||||
check_stat $OLDSTATS $NEWSTATS cache_misses 2
|
||||
check_stat $OLDSTATS $NEWSTATS cache_inserts 3
|
||||
# TODO(sligocki): There is no stat num_rewrites_executed. Fix.
|
||||
#check_stat $OLDSTATS $NEWSTATS num_rewrites_executed 1
|
||||
|
||||
start_test Blocking rewrite enabled using wrong key.
|
||||
URL="blocking.example.com/mod_pagespeed_test/blocking_rewrite_another.html"
|
||||
OUTFILE=$WGET_DIR/blocking_rewrite.out.html
|
||||
http_proxy=$SECONDARY_HOSTNAME check $WGET_DUMP \
|
||||
--header 'X-PSA-Blocking-Rewrite: junk' \
|
||||
$URL > $OUTFILE
|
||||
check [ $(grep -c "[.]pagespeed[.]" $OUTFILE) -lt 1 ]
|
||||
|
||||
http_proxy=$SECONDARY_HOSTNAME fetch_until $URL \
|
||||
'grep -c [.]pagespeed[.]' 1
|
||||
|
||||
run_post_cache_flush
|
||||
|
||||
# Test ForbidAllDisabledFilters, which is set in the config for
|
||||
# /mod_pagespeed_test/forbid_all_disabled/disabled/ where we've disabled
|
||||
# remove_quotes, remove_comments, and collapse_whitespace. We fetch 3 times
|
||||
# trying to circumvent the forbidden flag: a normal fetch, a fetch using a query
|
||||
# parameter to try to enable the forbidden filters, and a fetch using a request
|
||||
# header to try to enable the forbidden filters.
|
||||
function test_forbid_all_disabled() {
|
||||
QUERYP="$1"
|
||||
HEADER="$2"
|
||||
if [ -n "$QUERYP" ]; then
|
||||
INLINE_CSS=",-inline_css"
|
||||
else
|
||||
INLINE_CSS="?PageSpeedFilters=-inline_css"
|
||||
fi
|
||||
WGET_ARGS="--header=X-PSA-Blocking-Rewrite:psatest"
|
||||
URL=$TEST_ROOT/forbid_all_disabled/disabled/forbidden.html
|
||||
OUTFILE="$TESTTMP/test_forbid_all_disabled"
|
||||
# Fetch testing that forbidden filters stay disabled.
|
||||
echo $WGET $HEADER $URL$QUERYP$INLINE_CSS
|
||||
$WGET $WGET_ARGS -q -O $OUTFILE $HEADER $URL$QUERYP$INLINE_CSS
|
||||
check egrep -q '<link rel="stylesheet' $OUTFILE
|
||||
check egrep -q '<!--' $OUTFILE
|
||||
check egrep -q ' <li>' $OUTFILE
|
||||
# Fetch testing that enabling inline_css works.
|
||||
echo $WGET $HEADER $URL
|
||||
$WGET $WGET_ARGS -q -O $OUTFILE $HEADER $URL
|
||||
check egrep -q '<style>.yellow' $OUTFILE
|
||||
rm -f $OUTFILE
|
||||
}
|
||||
start_test ForbidAllDisabledFilters baseline check.
|
||||
test_forbid_all_disabled "" ""
|
||||
start_test ForbidAllDisabledFilters query parameters check.
|
||||
QUERYP="?PageSpeedFilters="
|
||||
QUERYP="${QUERYP}+remove_quotes,+remove_comments,+collapse_whitespace"
|
||||
test_forbid_all_disabled $QUERYP ""
|
||||
start_test ForbidAllDisabledFilters request headers check.
|
||||
HEADER="--header=PageSpeedFilters:"
|
||||
HEADER="${HEADER}+remove_quotes,+remove_comments,+collapse_whitespace"
|
||||
test_forbid_all_disabled "" $HEADER
|
||||
|
||||
# Test the experiment framework (Furious).
|
||||
|
||||
start_test PageSpeedExperiment cookie is set.
|
||||
EXP_EXAMPLE="http://experiment.example.com/mod_pagespeed_example"
|
||||
EXP_EXTEND_CACHE="$EXP_EXAMPLE/extend_cache.html"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $EXP_EXTEND_CACHE)
|
||||
check_from "$OUT" fgrep "PageSpeedExperiment="
|
||||
MATCHES=$(echo "$OUT" | grep -c "PageSpeedExperiment=")
|
||||
check [ $MATCHES -eq 1 ]
|
||||
|
||||
start_test PageSpeedFilters query param should disable experiments.
|
||||
URL="$EXP_EXTEND_CACHE?PageSpeed=on&PageSpeedFilters=rewrite_css"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $URL)
|
||||
check_not_from "$OUT" fgrep 'PageSpeedExperiment='
|
||||
|
||||
start_test experiment assignment can be forced
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
|
||||
"$EXP_EXTEND_CACHE?PageSpeedEnrollExperiment=2")
|
||||
check_from "$OUT" fgrep 'PageSpeedExperiment=2'
|
||||
|
||||
start_test experiment assignment can be forced to a 0% experiment
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
|
||||
"$EXP_EXTEND_CACHE?PageSpeedEnrollExperiment=3")
|
||||
check_from "$OUT" fgrep 'PageSpeedExperiment=3'
|
||||
|
||||
start_test experiment assignment can be forced even if already assigned
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
|
||||
--header Cookie:PageSpeedExperiment=7 \
|
||||
"$EXP_EXTEND_CACHE?PageSpeedEnrollExperiment=2")
|
||||
check_from "$OUT" fgrep 'PageSpeedExperiment=2'
|
||||
|
||||
start_test If the user is already assigned, no need to assign them again.
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
|
||||
--header='Cookie: PageSpeedExperiment=2' $EXP_EXTEND_CACHE)
|
||||
check_not_from "$OUT" fgrep 'PageSpeedExperiment='
|
||||
|
||||
start_test The beacon should include the experiment id.
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
|
||||
--header='Cookie: PageSpeedExperiment=2' $EXP_EXTEND_CACHE)
|
||||
BEACON_CODE="pagespeed.addInstrumentationInit('/$BEACON_HANDLER', 'load',"
|
||||
BEACON_CODE+=" '&exptid=2', 'http://experiment.example.com/"
|
||||
BEACON_CODE+="mod_pagespeed_example/extend_cache.html');"
|
||||
check_from "$OUT" grep "$BEACON_CODE"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=7' \
|
||||
$EXP_EXTEND_CACHE)
|
||||
BEACON_CODE="pagespeed.addInstrumentationInit('/$BEACON_HANDLER', 'load',"
|
||||
BEACON_CODE+=" '&exptid=7', 'http://experiment.example.com/"
|
||||
BEACON_CODE+="mod_pagespeed_example/extend_cache.html');"
|
||||
check_from "$OUT" grep "$BEACON_CODE"
|
||||
|
||||
start_test The no-experiment group beacon should not include an experiment id.
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
|
||||
--header='Cookie: PageSpeedExperiment=0' $EXP_EXTEND_CACHE)
|
||||
check_not_from "$OUT" grep 'pagespeed_beacon.*exptid'
|
||||
|
||||
# We expect id=7 to be index=a and id=2 to be index=b because that's the
|
||||
# order they're defined in the config file.
|
||||
start_test Resource urls are rewritten to include experiment indexes.
|
||||
http_proxy=$SECONDARY_HOSTNAME \
|
||||
fetch_until $EXP_EXTEND_CACHE \
|
||||
"fgrep -c .pagespeed.a.ic." 1 --header=Cookie:PageSpeedExperiment=7
|
||||
http_proxy=$SECONDARY_HOSTNAME \
|
||||
fetch_until $EXP_EXTEND_CACHE \
|
||||
"fgrep -c .pagespeed.b.ic." 1 --header=Cookie:PageSpeedExperiment=2
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=7' \
|
||||
$EXP_EXTEND_CACHE)
|
||||
check_from "$OUT" fgrep ".pagespeed.a.ic."
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=2' \
|
||||
$EXP_EXTEND_CACHE)
|
||||
check_from "$OUT" fgrep ".pagespeed.b.ic."
|
||||
|
||||
start_test Images are different when the url specifies different experiments.
|
||||
# While the images are the same, image B should be smaller because in the config
|
||||
# file we enable convert_jpeg_to_progressive only for id=2 (side B). Ideally we
|
||||
# would check that it was actually progressive, by checking whether "identify
|
||||
# -verbose filename" produced "Interlace: JPEG" or "Interlace: None", but that
|
||||
# would introduce a dependency on imagemagick. This is just as accurate, but
|
||||
# more brittle (because changes to our compression code would change the
|
||||
# computed file sizes).
|
||||
|
||||
IMG_A="$EXP_EXAMPLE/images/xPuzzle.jpg.pagespeed.a.ic.fakehash.jpg"
|
||||
IMG_B="$EXP_EXAMPLE/images/xPuzzle.jpg.pagespeed.b.ic.fakehash.jpg"
|
||||
http_proxy=$SECONDARY_HOSTNAME fetch_until $IMG_A 'wc -c' 102902 "" -le
|
||||
http_proxy=$SECONDARY_HOSTNAME fetch_until $IMG_B 'wc -c' 98276 "" -le
|
||||
|
||||
start_test Analytics javascript is added for the experimental group.
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=2' \
|
||||
$EXP_EXTEND_CACHE)
|
||||
check_from "$OUT" fgrep -q 'Experiment: 2'
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=7' \
|
||||
$EXP_EXTEND_CACHE)
|
||||
check_from "$OUT" fgrep -q 'Experiment: 7'
|
||||
|
||||
start_test Analytics javascript is not added for the no-experiment group.
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=0' \
|
||||
$EXP_EXTEND_CACHE)
|
||||
check_not_from "$OUT" fgrep -q 'Experiment:'
|
||||
|
||||
start_test Analytics javascript is not added for any group with Analytics off.
|
||||
EXP_NO_GA_EXTEND_CACHE="http://experiment.noga.example.com"
|
||||
EXP_NO_GA_EXTEND_CACHE+="/mod_pagespeed_example/extend_cache.html"
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=2' \
|
||||
$EXP_NO_GA_EXTEND_CACHE)
|
||||
check_not_from "$OUT" fgrep -q 'Experiment:'
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=7' \
|
||||
$EXP_NO_GA_EXTEND_CACHE)
|
||||
check_not_from "$OUT" fgrep -q 'Experiment:'
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --header='Cookie: PageSpeedExperiment=0' \
|
||||
$EXP_NO_GA_EXTEND_CACHE)
|
||||
check_not_from "$OUT" fgrep -q 'Experiment:'
|
||||
|
||||
# Repeat the critical_css_filter test on a host that processes post data via
|
||||
# temp files to test that ngx_pagespeed specific code path.
|
||||
filter_spec_method="headers"
|
||||
test_filter prioritize_critical_css Able to read POST data from temp file.
|
||||
URL="http://beacon-post-temp-file.example.com/mod_pagespeed_example/prioritize_critical_css.html"
|
||||
http_proxy=$SECONDARY_HOSTNAME\
|
||||
fetch_until -save $URL 'fgrep -c pagespeed.criticalCssBeaconInit' 1
|
||||
check [ $(fgrep -o ".very_large_class_name_" $FETCH_FILE | wc -l) -eq 36 ]
|
||||
CALL_PAT=".*criticalCssBeaconInit("
|
||||
SKIP_ARG="[^,]*,"
|
||||
CAPTURE_ARG="'\([^']*\)'.*"
|
||||
BEACON_PATH=$(sed -n "s/${CALL_PAT}${CAPTURE_ARG}/\1/p" $FETCH_FILE)
|
||||
ESCAPED_URL=$( \
|
||||
sed -n "s/${CALL_PAT}${SKIP_ARG}${CAPTURE_ARG}/\1/p" $FETCH_FILE)
|
||||
OPTIONS_HASH=$( \
|
||||
sed -n "s/${CALL_PAT}${SKIP_ARG}${SKIP_ARG}${CAPTURE_ARG}/\1/p" $FETCH_FILE)
|
||||
NONCE=$( \
|
||||
sed -n "s/${CALL_PAT}${SKIP_ARG}${SKIP_ARG}${SKIP_ARG}${CAPTURE_ARG}/\1/p" \
|
||||
$FETCH_FILE)
|
||||
BEACON_URL="http://${SECONDARY_HOSTNAME}${BEACON_PATH}?url=${ESCAPED_URL}"
|
||||
BEACON_DATA="oh=${OPTIONS_HASH}&n=${NONCE}&cs=.big,.blue,.bold,.foo"
|
||||
|
||||
OUT=$(wget -q --save-headers -O - --no-http-keep-alive \
|
||||
--post-data "$BEACON_DATA" "$BEACON_URL" \
|
||||
--header "Host:beacon-post-temp-file.example.com")
|
||||
check_from "$OUT" grep '^HTTP/1.1 204'
|
||||
|
||||
# Now make sure we see the correct critical css rules.
|
||||
http_proxy=$SECONDARY_HOSTNAME\
|
||||
fetch_until $URL \
|
||||
'grep -c <style>[.]blue{[^}]*}</style>' 1
|
||||
http_proxy=$SECONDARY_HOSTNAME\
|
||||
fetch_until $URL \
|
||||
'grep -c <style>[.]big{[^}]*}</style>' 1
|
||||
http_proxy=$SECONDARY_HOSTNAME\
|
||||
fetch_until $URL \
|
||||
'grep -c <style>[.]blue{[^}]*}[.]bold{[^}]*}</style>' 1
|
||||
http_proxy=$SECONDARY_HOSTNAME\
|
||||
fetch_until -save $URL \
|
||||
'grep -c <style>[.]foo{[^}]*}</style>' 1
|
||||
# The last one should also have the other 3, too.
|
||||
check [ `grep -c '<style>[.]blue{[^}]*}</style>' $FETCH_UNTIL_OUTFILE` = 1 ]
|
||||
check [ `grep -c '<style>[.]big{[^}]*}</style>' $FETCH_UNTIL_OUTFILE` = 1 ]
|
||||
check [ `grep -c '<style>[.]blue{[^}]*}[.]bold{[^}]*}</style>' \
|
||||
$FETCH_UNTIL_OUTFILE` = 1 ]
|
||||
|
||||
start_test keepalive with html rewriting
|
||||
keepalive_test "keepalive-html.example.com"\
|
||||
"/mod_pagespeed_example/rewrite_images.html" ""
|
||||
|
||||
start_test keepalive with serving resources
|
||||
keepalive_test "keepalive-resource.example.com"\
|
||||
"/mod_pagespeed_example/combine_javascript2.js+combine_javascript1.js+combine_javascript2.js.pagespeed.jc.0.js"\
|
||||
""
|
||||
|
||||
BEACON_URL="http%3A%2F%2Fimagebeacon.example.com%2Fmod_pagespeed_test%2F"
|
||||
start_test keepalive with beacon get requests
|
||||
keepalive_test "keepalive-beacon-get.example.com"\
|
||||
"/$BEACON_HANDLER?ets=load:13&url=$BEACON_URL" ""
|
||||
|
||||
BEACON_DATA="url=http%3A%2F%2Fimagebeacon.example.com%2Fmod_pagespeed_test%2F"
|
||||
BEACON_DATA+="image_rewriting%2Frewrite_images.html"
|
||||
BEACON_DATA+="&oh=$OPTIONS_HASH&ci=2932493096"
|
||||
|
||||
start_test keepalive with beacon post requests
|
||||
keepalive_test "keepalive-beacon-post.example.com" "/$BEACON_HANDLER"\
|
||||
"$BEACON_DATA"
|
||||
|
||||
start_test keepalive with static resources
|
||||
keepalive_test "keepalive-static.example.com"\
|
||||
"/pagespeed_custom_static/js_defer.0.js" ""
|
||||
|
||||
start_test pagespeed_custom_static defer js served with correct headers.
|
||||
# First, determine which hash js_defer is served with. We need a correct hash
|
||||
# to get it served up with an Etag, which is one of the things we want to test.
|
||||
URL="$HOSTNAME/mod_pagespeed_example/defer_javascript.html?PageSpeed=on&PageSpeedFilters=defer_javascript"
|
||||
OUT=$($WGET_DUMP $URL)
|
||||
HASH=$(echo $OUT \
|
||||
| grep --only-matching "/js_defer\\.*\([^.]\)*.js" | cut -d '.' -f 2)
|
||||
|
||||
start_test JS gzip headers
|
||||
|
||||
JS_URL="$HOSTNAME/pagespeed_custom_static/js_defer.$HASH.js"
|
||||
JS_HEADERS=$($WGET -O /dev/null -q -S --header='Accept-Encoding: gzip' \
|
||||
$JS_URL 2>&1)
|
||||
check_200_http_response "$JS_HEADERS"
|
||||
check_from "$JS_HEADERS" fgrep -qi 'Content-Encoding: gzip'
|
||||
check_from "$JS_HEADERS" fgrep -qi 'Vary: Accept-Encoding'
|
||||
# Nginx's gzip module clears etags, which we don't want. Make sure we have it.
|
||||
check_from "$JS_HEADERS" egrep -qi 'Etag: W/"0"'
|
||||
check_from "$JS_HEADERS" fgrep -qi 'Last-Modified:'
|
||||
|
||||
|
||||
start_test PageSpeedFilters response headers is interpreted
|
||||
URL=$SECONDARY_HOSTNAME/mod_pagespeed_example/
|
||||
OUT=$($WGET_DUMP --header=Host:response-header-filters.example.com $URL)
|
||||
check_from "$OUT" egrep -qi 'addInstrumentationInit'
|
||||
OUT=$($WGET_DUMP --header=Host:response-header-disable.example.com $URL)
|
||||
check_not_from "$OUT" egrep -qi 'addInstrumentationInit'
|
||||
|
||||
# TODO(jmaessen, jefftk): Port proxying tests, which rely on pointing a
|
||||
# MapProxyDomain construct at a static server. Perhaps $HOSTNAME will
|
||||
# serve, but the tests need to use different urls then. For mod_pagespeed these
|
||||
# tests immediately precede the "scrape_secondary_stat" definition in
|
||||
# system_test.sh.
|
||||
|
||||
start_test messages load
|
||||
OUT=$($WGET_DUMP "$HOSTNAME/ngx_pagespeed_message")
|
||||
check_not_from "$OUT" grep "Writing to ngx_pagespeed_message failed."
|
||||
check_from "$OUT" grep -q "/mod_pagespeed_example"
|
||||
|
||||
start_test Check keepalive after a 304 responses.
|
||||
# '-m 2' specifies that the whole operation is allowed to take 2 seconds max.
|
||||
check curl -vv -m 2 http://$PRIMARY_HOSTNAME/foo.css.pagespeed.ce.0.css \
|
||||
-H 'If-Modified-Since: Z' http://$PRIMARY_HOSTNAME/foo
|
||||
|
||||
start_test Date response header set
|
||||
OUT=$($WGET_DUMP $EXAMPLE_ROOT/combine_css.html)
|
||||
check_not_from "$OUT" egrep -q '^Date: Thu, 01 Jan 1970 00:00:00 GMT'
|
||||
|
||||
OUT=$($WGET_DUMP --header=Host:date.example.com \
|
||||
http://$SECONDARY_HOSTNAME/mod_pagespeed_example/combine_css.html)
|
||||
check_from "$OUT" egrep -q '^Date: Fri, 16 Oct 2009 23:05:07 GMT'
|
||||
WGET_ARGS=
|
||||
|
||||
#very basic tests to test gzip nesting configuration
|
||||
start_test Nested gzip gzip off
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/"
|
||||
HEADERS="--header=Accept-Encoding:gzip --header=Host:gzip-test1.example.com"
|
||||
OUT=$($WGET_DUMP -O /dev/null -S $HEADERS $URL 2>&1)
|
||||
check_not_from "$OUT" fgrep -qi 'Content-Encoding: gzip'
|
||||
check_not_from "$OUT" fgrep -qi 'Vary: Accept-Encoding'
|
||||
|
||||
start_test Nested gzip gzip on
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/styles/big.css"
|
||||
HEADERS="--header=Accept-Encoding:gzip --header=Host:gzip-test1.example.com"
|
||||
OUT=$($WGET_DUMP -O /dev/null -S $HEADERS $URL 2>&1)
|
||||
check_from "$OUT" fgrep -qi 'Content-Encoding: gzip'
|
||||
check_from "$OUT" fgrep -qi 'Vary: Accept-Encoding'
|
||||
|
||||
start_test Nested gzip pagespeed off
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/"
|
||||
HEADERS="--header=Accept-Encoding:gzip --header=Host:gzip-test2.example.com"
|
||||
OUT=$($WGET_DUMP -O /dev/null -S $HEADERS $URL 2>&1)
|
||||
check_not_from "$OUT" fgrep -qi 'Content-Encoding: gzip'
|
||||
check_not_from "$OUT" fgrep -qi 'Vary: Accept-Encoding'
|
||||
|
||||
start_test Nested gzip pagespeed on
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/styles/big.css"
|
||||
HEADERS="--header=Accept-Encoding:gzip --header=Host:gzip-test2.example.com"
|
||||
OUT=$($WGET_DUMP -O /dev/null -S $HEADERS $URL 2>&1)
|
||||
check_from "$OUT" fgrep -qi 'Content-Encoding: gzip'
|
||||
check_from "$OUT" fgrep -qi 'Vary: Accept-Encoding'
|
||||
|
||||
start_test Test that POST requests are rewritten.
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/rewrite_images.html"
|
||||
HEADERS="--header=Host:proxy-post.example.com --post-data=abcdefgh"
|
||||
OUT=$($WGET_DUMP -S $HEADERS $URL 2>&1)
|
||||
check_from "$OUT" fgrep -qi 'addInstrumentationInit'
|
||||
|
||||
start_test Test that we can modify filters via script variables.
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/rewrite_images.html"
|
||||
HEADERS="--header=Host:script-filters.example.com --header=X-Script:1"
|
||||
OUT=$($WGET_DUMP -S $HEADERS $URL 2>&1)
|
||||
check_from "$OUT" fgrep -qi 'addInstrumentationInit'
|
||||
|
||||
HEADERS="--header=Host:script-filters.example.com"
|
||||
OUT=$($WGET_DUMP -S $HEADERS $URL 2>&1)
|
||||
check_not_from "$OUT" fgrep -qi 'addInstrumentationInit'
|
||||
|
||||
start_test Test that we can modify domain sharding via script variables.
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/rewrite_images.html"
|
||||
HEADERS="--header=Host:script-filters.example.com"
|
||||
OUT=$($WGET_DUMP -S $HEADERS $URL 2>&1)
|
||||
check_from "$OUT" fgrep "http://cdn1.example.com"
|
||||
check_from "$OUT" fgrep "http://cdn2.example.com"
|
||||
|
||||
URL="http://$SECONDARY_HOSTNAME/mod_pagespeed_example/rewrite_images.html"
|
||||
HEADERS="--header=Host:script-filters.example.com --header=X-Script:1"
|
||||
OUT=$($WGET_DUMP -S $HEADERS $URL 2>&1)
|
||||
check_not_from "$OUT" fgrep "http://cdn1.example.com"
|
||||
check_not_from "$OUT" fgrep "http://cdn2.example.com"
|
||||
|
||||
if [ "$NATIVE_FETCHER" != "on" ]; then
|
||||
start_test Test that we can rewrite an HTTPS resource.
|
||||
fetch_until $TEST_ROOT/https_fetch/https_fetch.html \
|
||||
'grep -c /https_gstatic_dot_com/1.gif.pagespeed.ce' 1
|
||||
fi
|
||||
|
||||
start_test Base config has purging disabled. Check error message syntax.
|
||||
OUT=$($WGET_DUMP "$HOSTNAME/pagespeed_admin/cache?purge=*")
|
||||
check_from "$OUT" fgrep -q "pagespeed EnableCachePurge on;"
|
||||
|
||||
start_test Default server header in html flow.
|
||||
URL=http://headers.example.com/mod_pagespeed_example/
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
|
||||
# '|| true' in the line below supresses the exit code from grep when there is no
|
||||
# match in its input (1).
|
||||
MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true
|
||||
check [ $MATCHES -eq 1 ]
|
||||
|
||||
start_test Default server header in resource flow.
|
||||
URL=http://headers.example.com/mod_pagespeed_example/
|
||||
URL+=combine_javascript2.js+combine_javascript1.js.pagespeed.jc.0.js
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
|
||||
MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true
|
||||
check [ $MATCHES -eq 1 ]
|
||||
|
||||
start_test Default server header in IPRO flow.
|
||||
URL=http://headers.example.com//mod_pagespeed_example/combine_javascript2.js
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
|
||||
MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true
|
||||
check [ $MATCHES -eq 1 ]
|
||||
|
||||
start_test Override server header in html flow.
|
||||
URL=http://headers.example.com/mod_pagespeed_test/whitespace.html
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
|
||||
MATCHES=$(echo "$OUT" | grep -c "Server: override") || true
|
||||
check [ $MATCHES -eq 1 ]
|
||||
|
||||
if [ "$POSITION_AUX" = "true" ] ; then
|
||||
start_test Override server header in resource flow.
|
||||
URL=http://headers.example.com/mod_pagespeed_test/
|
||||
URL+=A.proxy_pass.css.pagespeed.cf.0.css
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
|
||||
MATCHES=$(echo "$OUT" | grep -c "Server: override") || true
|
||||
check [ $MATCHES -eq 1 ]
|
||||
|
||||
start_test Override server header in IPRO flow.
|
||||
URL=http://headers.example.com/mod_pagespeed_test/proxy_pass.css
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
|
||||
MATCHES=$(echo "$OUT" | grep -c "Server: override") || true
|
||||
check [ $MATCHES -eq 1 ]
|
||||
fi
|
||||
|
||||
start_test Conditional cache-control header override in resource flow.
|
||||
URL=http://headers.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'
|
||||
MATCHES=$(echo "$OUT" | grep -c "Cache-Control: override") || true
|
||||
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'
|
||||
|
||||
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 ]
|
||||
|
||||
start_test Follow flushes can be turned off.
|
||||
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.
|
||||
|
||||
# Fire up some heavy load if ab is available to test a stressed shutdown
|
||||
fire_ab_load
|
||||
|
||||
if $USE_VALGRIND; then
|
||||
# SIGQUIT requests a graceful shutdown.
|
||||
kill -s QUIT $VALGRIND_PID
|
||||
while pgrep memcheck > /dev/null; do sleep 1; done
|
||||
# Clear the previously set trap, we don't need it anymore.
|
||||
trap - EXIT
|
||||
|
||||
start_test No Valgrind complaints.
|
||||
check_not [ -s "$TEST_TMP/valgrind.log" ]
|
||||
else
|
||||
check_simple "$NGINX_EXECUTABLE" -s quit -c "$PAGESPEED_CONF"
|
||||
while pgrep -x nginx > /dev/null; do sleep 1; done
|
||||
fi
|
||||
|
||||
if [ "$AB_PID" != "0" ]; then
|
||||
echo "Kill ab (pid: $AB_PID)"
|
||||
kill -s KILL $AB_PID &>/dev/null || true
|
||||
fi
|
||||
|
||||
start_test Logged output looks healthy.
|
||||
|
||||
# TODO(oschaaf): Sanity check for all the warnings/errors here.
|
||||
OUT=$(cat "$ERROR_LOG" \
|
||||
| grep "\\[" \
|
||||
| grep -v "\\[debug\\]" \
|
||||
| grep -v "\\[info\\]" \
|
||||
| grep -v "\\[notice\\]" \
|
||||
| grep -v "\\[warn\\].*Cache Flush.*" \
|
||||
| grep -v "\\[warn\\].*doesnotexist.css.*" \
|
||||
| grep -v "\\[warn\\].*Invalid filter name: bogus.*" \
|
||||
| grep -v "\\[warn\\].*You seem to have downstream caching.*" \
|
||||
| grep -v "\\[warn\\].*Warning_trigger*" \
|
||||
| grep -v "\\[warn\\].*Rewrite http://www.google.com/mod_pagespeed_example/ failed*" \
|
||||
| grep -v "\\[warn\\].*A.bad:0:Resource*" \
|
||||
| grep -v "\\[warn\\].*W.bad.pagespeed.cf.hash.css*" \
|
||||
| grep -v "\\[warn\\].*BadName*" \
|
||||
| grep -v "\\[warn\\].*CSS parsing error*" \
|
||||
| grep -v "\\[warn\\].*Fetch failed for resource*" \
|
||||
| grep -v "\\[warn\\].*Rewrite.*example.pdf failed*" \
|
||||
| grep -v "\\[warn\\].*Rewrite.*hello.js failed*" \
|
||||
| grep -v "\\[warn\\].*Resource based on.*ngx_pagespeed_statistics.*" \
|
||||
| grep -v "\\[warn\\].*Canceling 1 functions on sequence Shutdown.*" \
|
||||
| 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\\].*/mod_pagespeed/bad*" \
|
||||
| grep -v "\\[error\\].*doesnotexist.css.*" \
|
||||
| grep -v "\\[error\\].*is forbidden.*" \
|
||||
| grep -v "\\[error\\].*access forbidden by rule.*" \
|
||||
| grep -v "\\[error\\].*forbidden.example.com*" \
|
||||
| grep -v "\\[error\\].*custom-paths.example.com*" \
|
||||
| grep -v "\\[error\\].*bogus_format*" \
|
||||
| grep -v "\\[error\\].*/install/foo*" \
|
||||
| grep -v "\\[error\\].*recv() failed*" \
|
||||
| grep -v "\\[error\\].*send() failed*" \
|
||||
| grep -v "\\[error\\].*Invalid url requested: js_defer.js.*" \
|
||||
| grep -v "\\[error\\].*/mod_pagespeed_example/styles/yellow.css+blue.css.pagespeed.cc..css.*" \
|
||||
| grep -v "\\[error\\].*/mod_pagespeed_example/images/Puzzle.jpg.pagespeed.ce..jpg.*" \
|
||||
| grep -v "\\[error\\].*/pagespeed_custom_static/js_defer.js.*" \
|
||||
| grep -v "\\[error\\].*UH8L-zY4b4AAAAAAAAAA.*" \
|
||||
| grep -v "\\[error\\].*UH8L-zY4b4.*" \
|
||||
| grep -v "\\[error\\].*Serf status 111(Connection refused) polling.*" \
|
||||
| grep -v "\\[error\\].*Failed to make directory*" \
|
||||
| grep -v "\\[error\\].*Could not create directories*" \
|
||||
| grep -v "\\[error\\].*opening temp file: No such file or directory.*" \
|
||||
| grep -v "\\[error\\].*remote\.cfg.*" \
|
||||
| grep -v "\\[error\\].*Slow read operation on file.*" \
|
||||
| grep -v "\\[error\\].*Slow ReadFile operation on file.*" \
|
||||
| grep -v "\\[error\\].*Slow write operation on file.*" \
|
||||
| grep -v "\\[warn\\].*remote\.cfg.*" \
|
||||
| grep -v "\\[warn\\].*end token not received.*" \
|
||||
| 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\\].*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)
|
||||
|
||||
check [ -z "$OUT" ]
|
||||
|
||||
check_failures_and_exit
|
||||
@@ -0,0 +1,2308 @@
|
||||
# nginx_system_test.sh makes a few substitutions to pagespeed_test.conf.template
|
||||
# file to generate @@TEST_TMP@@/pagespeed_test.conf
|
||||
|
||||
# The cache flush test depends on worker_processes=1.
|
||||
worker_processes 1;
|
||||
|
||||
daemon @@DAEMON@@;
|
||||
master_process on;
|
||||
|
||||
error_log "@@ERROR_LOG@@" debug;
|
||||
pid "@@TEST_TMP@@/nginx.pid";
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
server_names_hash_bucket_size 128;
|
||||
|
||||
log_format cache '$time_local '
|
||||
'$upstream_cache_status '
|
||||
'$http_host $request ($status) '
|
||||
'"$http_user_agent"';
|
||||
access_log "@@ACCESS_LOG@@" cache;
|
||||
|
||||
# Don't put entries in the error log for 403s and 404s.
|
||||
log_not_found off;
|
||||
|
||||
proxy_cache_path "@@PROXY_CACHE@@" levels=1:2 keys_zone=htmlcache:60m inactive=90m max_size=50m;
|
||||
proxy_temp_path "@@TMP_PROXY_CACHE@@";
|
||||
|
||||
pagespeed ProcessScriptVariables all;
|
||||
pagespeed StatisticsPath /ngx_pagespeed_statistics;
|
||||
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
|
||||
pagespeed ConsolePath /pagespeed_console;
|
||||
pagespeed MessagesPath /ngx_pagespeed_message;
|
||||
pagespeed AdminPath /pagespeed_admin;
|
||||
pagespeed GlobalAdminPath /pagespeed_global_admin;
|
||||
|
||||
pagespeed StaticAssetPrefix /pagespeed_custom_static/;
|
||||
|
||||
pagespeed MessageBufferSize 200000;
|
||||
# Increase the default fetcher timeout to resolve sporadic flakeyness when
|
||||
# the native fetcher uses 8.8.8.8 to resolve.
|
||||
pagespeed FetcherTimeoutMs 10000;
|
||||
pagespeed NativeFetcherMaxKeepaliveRequests 50;
|
||||
|
||||
root "@@SERVER_ROOT@@";
|
||||
|
||||
# Block 5a: Decide on Cache-Control header value to use for outgoing
|
||||
# response.
|
||||
# Map new_cache_control_header_val to "no-cache, max-age=0" if the
|
||||
# content is html and use the original Cache-Control header value
|
||||
# in all other cases.
|
||||
map $upstream_http_content_type $new_cache_control_header_val {
|
||||
default $upstream_http_cache_control;
|
||||
"~*text/html" "no-cache, max-age=0";
|
||||
}
|
||||
|
||||
pagespeed UsePerVHostStatistics on;
|
||||
pagespeed InPlaceResourceOptimization on;
|
||||
pagespeed CreateSharedMemoryMetadataCache "@@SHM_CACHE@@" 8192;
|
||||
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.
|
||||
# With this option enabled, the inline image system test will currently fail.
|
||||
# When critical image beaconing is enabled, only critical images are inlined.
|
||||
# In our current system test, we aren't yet sending a beacon to identify the
|
||||
# critical images to be inlined, so we just disable the option here.
|
||||
pagespeed CriticalImagesBeaconEnabled false;
|
||||
|
||||
# By default, resources will not be used for inlining without explicit
|
||||
# authorization. Supported values are off or a comma-separated list of strings
|
||||
# from {Script,Stylesheet}.
|
||||
pagespeed InlineResourcesWithoutExplicitAuthorization off;
|
||||
|
||||
pagespeed Statistics on;
|
||||
pagespeed StatisticsLogging on;
|
||||
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 {
|
||||
# Sets up a logical home-page server on
|
||||
# max-cacheable-content-length.example.com. This server is only used to
|
||||
# test ModPagespeedMaxCacheableContentLength, i.e.,
|
||||
# max_cacheable_response_content_length.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name max-cacheable-content-length.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_javascript;
|
||||
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@@";
|
||||
@@RESOLVER@@
|
||||
|
||||
server {
|
||||
# Block 1: Basic port, server_name definitions.
|
||||
# This server represents the external caching layer server which
|
||||
# receives user requests and proxies them to the upstream server
|
||||
# running on the PRIMARY_PORT when the response is not available in
|
||||
# the cache. It also services purge requests from the upstream server.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name proxy_cache.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
# Disable PageSpeed on this server.
|
||||
pagespeed off;
|
||||
|
||||
# Block 2: Define prefix for proxy_cache_key based on the UserAgent.
|
||||
|
||||
# Define placeholder PS-CapabilityList header values for large and small
|
||||
# screens with no UA dependent optimizations. Note that these placeholder
|
||||
# values should not contain any of ll, ii, dj, jw or ws, since these
|
||||
# codes will end up representing optimizations to be supported for the
|
||||
# request.
|
||||
set $default_ps_capability_list_for_large_screens "LargeScreen.SkipUADependentOptimizations";
|
||||
set $default_ps_capability_list_for_small_screens "TinyScreen.SkipUADependentOptimizations";
|
||||
|
||||
# As a fallback, the PS-CapabilityList header that is sent to the upstream
|
||||
# PageSpeed server should be for a large screen device with no browser
|
||||
# specific optimizations.
|
||||
set $ps_capability_list $default_ps_capability_list_for_large_screens;
|
||||
|
||||
# Cache-fragment 1: Desktop User-Agents that support lazyload_images (ll),
|
||||
# inline_images (ii) and defer_javascript (dj).
|
||||
# Note: Wget is added for testing purposes only.
|
||||
if ($http_user_agent ~* "Chrome/|Firefox/|MSIE |Safari|Wget") {
|
||||
set $ps_capability_list "ll,ii,dj:";
|
||||
}
|
||||
# Cache-fragment 2: Desktop User-Agents that support lazyload_images (ll),
|
||||
# inline_images (ii), defer_javascript (dj), webp (jw) and lossless_webp
|
||||
# (ws).
|
||||
if ($http_user_agent ~*
|
||||
"Chrome/[2][3-9]+\.|Chrome/[3-9][0-9]+\.|Chrome/[0-9]{3,}\.") {
|
||||
set $ps_capability_list "ll,ii,dj,jw,ws:";
|
||||
}
|
||||
# Cache-fragment 3: This fragment contains (a) Desktop User-Agents that
|
||||
# match fragments 1 or 2 but should not because they represent older
|
||||
# versions of certain browsers or bots and (b) Tablet User-Agents that
|
||||
# correspond to large screens. These will only get optimizations that work
|
||||
# on all browsers and use image compression qualities applicable to large
|
||||
# screens. Note that even Tablets that are capable of supporting inline or
|
||||
# webp images, e.g. Android 4.1.2, will not get these advanced
|
||||
# optimizations.
|
||||
if ($http_user_agent ~* "Firefox/[1-2]\.|MSIE [5-8]\.|bot|Yahoo!|Ruby|RPT-HTTPClient|(Google \(\+https\:\/\/developers\.google\.com\/\+\/web\/snippet\/\))|Android|iPad|TouchPad|Silk-Accelerated|Kindle Fire") {
|
||||
set $ps_capability_list $default_ps_capability_list_for_large_screens;
|
||||
}
|
||||
# Cache-fragment 4: Mobiles and small screen Tablets will use image compression
|
||||
# qualities applicable to small screens, but all other optimizations will be
|
||||
# those that work on all browsers.
|
||||
if ($http_user_agent ~* "Mozilla.*Android.*Mobile*|iPhone|BlackBerry|Opera Mobi|Opera Mini|SymbianOS|UP.Browser|J-PHONE|Profile/MIDP|portalmmm|DoCoMo|Obigo|Galaxy Nexus|GT-I9300|GT-N7100|HTC One|Nexus [4|7|S]|Xoom|XT907") {
|
||||
set $ps_capability_list $default_ps_capability_list_for_small_screens;
|
||||
}
|
||||
|
||||
# Block 3a: Bypass the cache for .pagespeed. resource. PageSpeed has its own
|
||||
# cache for these, and these could bloat up the caching layer.
|
||||
if ($uri ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+") {
|
||||
set $bypass_cache "1";
|
||||
}
|
||||
|
||||
# For testing purposes, we never generate values that will result in a beacon
|
||||
# unless a test request it via "X-Allow-Beacon: yes" in its request header.
|
||||
# This is for testing purposes, note that in a production environment,
|
||||
# you want 'set_random $rand 0 100;' unconditionally!
|
||||
set $rand 5;
|
||||
|
||||
if ($http_x_allow_beacon ~ "yes") {
|
||||
set_random $rand 0 100;
|
||||
}
|
||||
set $should_beacon_header_val "";
|
||||
if ($rand ~* "^[0-4]$") {
|
||||
set $should_beacon_header_val "random_rebeaconing_key";
|
||||
set $bypass_cache 1;
|
||||
}
|
||||
|
||||
# Block 3b: Only cache responses to clients that support gzip. Most clients
|
||||
# do, and the cache holds much more if it stores gzipped responses.
|
||||
if ($http_accept_encoding !~* gzip) {
|
||||
set $bypass_cache "1";
|
||||
}
|
||||
|
||||
# Block 4: Location block for purge requests.
|
||||
location ~ /purge(/.*) {
|
||||
allow 127.0.0.1;
|
||||
allow ::1;
|
||||
deny all;
|
||||
proxy_cache_purge htmlcache $ps_capability_list$1$is_args$args;
|
||||
}
|
||||
|
||||
# Block 6: Location block with proxy_cache directives.
|
||||
location /mod_pagespeed_test/cachable_rewritten_html/ {
|
||||
# 1: Upstream PageSpeed server is running at localhost:@@PRIMARY_PORT@@.
|
||||
proxy_pass http://localhost:@@PRIMARY_PORT@@;
|
||||
# 2: Use htmlcache as the zone for caching.
|
||||
proxy_cache htmlcache;
|
||||
# 3: Bypass requests that correspond to .pagespeed. resources
|
||||
# or clients that do not support gzip etc.
|
||||
proxy_cache_bypass $bypass_cache;
|
||||
# 4: Use the redefined proxy_cache_key and make sure the /purge/
|
||||
# block uses the same key.
|
||||
proxy_cache_key $ps_capability_list$uri$is_args$args;
|
||||
# 5: Forward Host header to upstream server.
|
||||
proxy_set_header Host $host;
|
||||
# 6: Set the PS-CapabilityList header for PageSpeed server to respect.
|
||||
proxy_set_header PS-CapabilityList $ps_capability_list;
|
||||
add_header PS-CapabilityList $ps_capability_list;
|
||||
# 7: Add a header for identifying cache hits/misses/expires. This is
|
||||
# for debugging purposes only and can be commented out in production.
|
||||
add_header X-Cache $upstream_cache_status;
|
||||
|
||||
# Block 5b: Override Cache-Control headers as needed.
|
||||
# Hide the upstream cache control header.
|
||||
proxy_hide_header Cache-Control;
|
||||
# Add the inferred Cache-Control header.
|
||||
add_header Cache-Control $new_cache_control_header_val;
|
||||
|
||||
proxy_set_header PS-ShouldBeacon $should_beacon_header_val;
|
||||
proxy_hide_header PS-ShouldBeacon;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name if-in-server.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
set $inline_javascript "No";
|
||||
|
||||
if ($http_x_custom_header_inline_js) {
|
||||
# TODO(jefftk): Turn on NGX_HTTP_SIF_CONF and figure out how to get
|
||||
# pagespeed directives inside of a server location block to be respected,
|
||||
# then uncomment the following line and duplicate the if-in-location test
|
||||
# for if-in-server.
|
||||
#pagespeed EnableFilters inline_javascript;
|
||||
set $inline_javascript "Yes";
|
||||
}
|
||||
|
||||
add_header "X-Inline-Javascript" $inline_javascript;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name if-in-location.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
|
||||
|
||||
location / {
|
||||
set $inline_javascript "No";
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
|
||||
if ($http_x_custom_header_inline_js) {
|
||||
pagespeed EnableFilters inline_javascript;
|
||||
set $inline_javascript "Yes";
|
||||
}
|
||||
|
||||
add_header "X-Inline-Javascript" $inline_javascript;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name secondary.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
|
||||
pagespeed MapProxyDomain secondary.example.com/gstatic_images
|
||||
http://www.gstatic.com/psa/static;
|
||||
}
|
||||
|
||||
# These three vhosts are for testing the experiment framework (Furious).
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name experiment.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed InPlaceResourceOptimization off;
|
||||
|
||||
pagespeed RunExperiment on;
|
||||
pagespeed AnalyticsID "123-45-6734";
|
||||
pagespeed UseAnalyticsJs false;
|
||||
pagespeed ExperimentVariable 2;
|
||||
pagespeed ExperimentSpec
|
||||
"id=7;enable=recompress_images;disable=convert_jpeg_to_progressive;percent=50";
|
||||
pagespeed ExperimentSpec "id=2;enable=recompress_images;percent=50";
|
||||
pagespeed ExperimentSpec "id=3;default;percent=0";
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name contentexperiment.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed InPlaceResourceOptimization off;
|
||||
|
||||
pagespeed RunExperiment on;
|
||||
pagespeed AnalyticsID "123-45-6734";
|
||||
pagespeed UseAnalyticsJs false;
|
||||
pagespeed ExperimentVariable 2;
|
||||
pagespeed ExperimentSpec
|
||||
"id=7;enable=recompress_images;disable=convert_jpeg_to_progressive;percent=50;options=ContentExperimentID=ID:H1BpS2TCRFmJzZgjwyeBHQ,ContentExperimentVariantID=111";
|
||||
pagespeed ExperimentSpec
|
||||
"id=2;enable=recompress_images;percent=50;options=ContentExperimentID=ID:H1BpS2TCRFmJzZgjwyeBHQ,ContentExperimentVariantID=222";
|
||||
pagespeed ExperimentSpec
|
||||
"id=3;default;percent=0;options=ContentExperimentID=123,ContentExperimentVariantID=333";
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name experiment.noga.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RunExperiment on;
|
||||
pagespeed ExperimentVariable 2;
|
||||
pagespeed ExperimentSpec
|
||||
"id=7;enable=recompress_images;disable=convert_jpeg_to_progressive;percent=50";
|
||||
pagespeed ExperimentSpec "id=2;enable=recompress_images;percent=50";
|
||||
pagespeed ExperimentSpec "id=3;default;percent=0";
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name experiment.devicematch.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RunExperiment on;
|
||||
pagespeed ExperimentSpec
|
||||
"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 {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name preserveurls.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed EnableFilters inline_preview_images,lazyload_images;
|
||||
pagespeed EnableFilters resize_mobile_images,rewrite_images,sprite_images;
|
||||
pagespeed EnableFilters fallback_rewrite_css_urls,flatten_css_imports;
|
||||
pagespeed EnableFilters inline_css,move_css_above_scripts,move_css_to_head;
|
||||
pagespeed EnableFilters outline_css,rewrite_css,combine_css;
|
||||
pagespeed EnableFilters combine_javascript,defer_javascript;
|
||||
pagespeed EnableFilters inline_javascript;
|
||||
pagespeed EnableFilters outline_javascript,rewrite_javascript;
|
||||
|
||||
location /mod_pagespeed_test/preserveurls/on/ {
|
||||
pagespeed JsPreserveURLs On;
|
||||
pagespeed ImagePreserveURLs On;
|
||||
pagespeed CssPreserveURLs On;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/preserveurls/off/ {
|
||||
pagespeed JsPreserveURLs Off;
|
||||
pagespeed ImagePreserveURLs Off;
|
||||
pagespeed CssPreserveURLs Off;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
# Setup a vhost with the critical image beacon and lazyload filter enabled
|
||||
# to make sure that critical images are not lazyloaded.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name imagebeacon.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters lazyload_images;
|
||||
pagespeed CriticalImagesBeaconEnabled true;
|
||||
}
|
||||
|
||||
server {
|
||||
# Setup a vhost with the critical image beacon enabled to make sure that
|
||||
# downstream caches and rebeaconing interact correctly.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name downstreamcacherebeacon.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed CriticalImagesBeaconEnabled true;
|
||||
# Enable the downstream caching feature and specify a rebeaconing key.
|
||||
pagespeed DownstreamCachePurgeLocationPrefix "http://localhost:@@SECONDARY_PORT@@/purge";
|
||||
pagespeed DownstreamCacheRebeaconingKey random_rebeaconing_key;
|
||||
location ~ .*[.]html {
|
||||
add_header Cache-Control "private, max-age=3000";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name downstreamcacheresource.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
pagespeed DownstreamCachePurgeLocationPrefix "http://localhost:@@SECONDARY_PORT@@/purge";
|
||||
}
|
||||
|
||||
# Set up a reverse proxy (rproxy.) and origin (origin.) as vhosts for
|
||||
# showing that we can configure PageSpeed via response headers.
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name rproxy.rmcomments.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed DisableFilters add_instrumentation,remove_comments;
|
||||
|
||||
# Note that we don't enable remove_comments here; that setting comes from
|
||||
# the response headers from origin.rmcomments.example.com
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:@@SECONDARY_PORT@@/;
|
||||
proxy_set_header "Host" "origin.rmcomments.example.com";
|
||||
}
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name origin.rmcomments.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed off;
|
||||
location / {
|
||||
add_header PageSpeedFilters remove_comments;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name renderedimagebeacon.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters resize_rendered_image_dimensions;
|
||||
pagespeed CriticalImagesBeaconEnabled true;
|
||||
}
|
||||
|
||||
|
||||
# Build a configuration hierarchy where at the root we have turned on
|
||||
# OptimizeForBandwidth, and in various subdirectories we override settings
|
||||
# to make them more aggressive.
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name optimizeforbandwidth.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel OptimizeForBandwidth;
|
||||
pagespeed DisableFilters add_instrumentation;
|
||||
|
||||
location /mod_pagespeed_test/optimize_for_bandwidth/inline_css {
|
||||
pagespeed EnableFilters inline_css;
|
||||
}
|
||||
location /mod_pagespeed_test/optimize_for_bandwidth/css_urls {
|
||||
pagespeed CssPreserveURLs off;
|
||||
}
|
||||
location /mod_pagespeed_test/optimize_for_bandwidth/image_urls {
|
||||
pagespeed ImagePreserveURLs off;
|
||||
}
|
||||
location /mod_pagespeed_test/optimize_for_bandwidth/core_filters {
|
||||
pagespeed RewriteLevel CoreFilters;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
# For testing with a custom origin header. In this VirtualHost,
|
||||
# /mod_pagespeed_test is included in our DocumentRoot and thus does
|
||||
# not need to be in any resource URL paths. This helps us verify that
|
||||
# we are looping back to the corect VirtualHost -- if we hit the wrong
|
||||
# one it will not work. Also we don't have a VirtualHost for
|
||||
# sharedcdn.example.com, so the default Host header used for
|
||||
# origin-mapping won't work either. Instead, we want origin-fetches
|
||||
# to go back to this VirtualHost so we rely on the new third optional
|
||||
# argument to MapOriginDomain.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name customhostheader.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@_test";
|
||||
root "@@SERVER_ROOT@@/mod_pagespeed_test";
|
||||
|
||||
pagespeed on;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
# Don't use localhost, as ngx_pagespeed's native fetcher cannot resolve it
|
||||
pagespeed MapOriginDomain 127.0.0.1:@@SECONDARY_PORT@@/customhostheader
|
||||
sharedcdn.example.com/test customhostheader.example.com;
|
||||
pagespeed JpegRecompressionQuality 50;
|
||||
pagespeed CriticalImagesBeaconEnabled false;
|
||||
}
|
||||
|
||||
server {
|
||||
# Sets up a virtual host where we can specify forbidden filters without
|
||||
# affecting any other hosts.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name forbidden.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
|
||||
# Start with all core filters enabled ...
|
||||
pagespeed RewriteLevel CoreFilters;
|
||||
# ... then forbid these filters ...
|
||||
pagespeed ForbidFilters remove_quotes,remove_comments,collapse_whitespace;
|
||||
pagespeed ForbidFilters rewrite_css,resize_images;
|
||||
# ... and disable but not forbid this one (to ensure we retain its URL).
|
||||
pagespeed DisableFilters inline_css;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name unauthorizedresources.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed InlineResourcesWithoutExplicitAuthorization Script,Stylesheet;
|
||||
pagespeed CssInlineMaxBytes 1000000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name client-domain-rewrite.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
# Don't actually try to rewrite any resources; the ones in
|
||||
# rewrite_domains.html don't actually exist.
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
|
||||
pagespeed MapRewriteDomain http://client-domain-rewrite.example.com
|
||||
http://src.example.com;
|
||||
pagespeed ClientDomainRewrite true;
|
||||
pagespeed EnableFilters rewrite_domains;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name url-attribute.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
# Don't actually try to rewrite any resources; the ones in
|
||||
# rewrite_domains.html don't actually exist.
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
|
||||
# This is used for testing dynamically defined url-valued
|
||||
# attributes
|
||||
pagespeed UrlValuedAttribute span src Hyperlink;
|
||||
pagespeed UrlValuedAttribute hr imgsrc Image;
|
||||
pagespeed DomainRewriteHyperlinks on;
|
||||
pagespeed MapRewriteDomain http://dst.example.com http://src.example.com;
|
||||
pagespeed EnableFilters rewrite_domains;
|
||||
pagespeed UrlValuedAttribute custom a Image;
|
||||
pagespeed UrlValuedAttribute custom b otherResource;
|
||||
pagespeed UrlValuedAttribute custom c hyperlink;
|
||||
pagespeed UrlValuedAttribute img alt-src Image;
|
||||
pagespeed UrlValuedAttribute video alt-a 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.
|
||||
pagespeed UrlValuedAttribute blockquote cite Image;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.2:@@SECONDARY_PORT@@;
|
||||
server_name loopbackfetch.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name domain-hyperlinks-on.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
# Don't actually try to rewrite any resources; the ones in
|
||||
# rewrite_domains.html don't actually exist.
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
|
||||
pagespeed DomainRewriteHyperlinks on;
|
||||
pagespeed MapRewriteDomain http://dst.example.com http://src.example.com;
|
||||
pagespeed EnableFilters rewrite_domains;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name domain-hyperlinks-off.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
# Don't actually try to rewrite any resources; the ones in
|
||||
# rewrite_domains.html don't actually exist.
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
|
||||
pagespeed DomainRewriteHyperlinks off;
|
||||
pagespeed MapRewriteDomain http://dst.example.com http://src.example.com;
|
||||
pagespeed EnableFilters rewrite_domains;
|
||||
}
|
||||
|
||||
server {
|
||||
# Test host for shared memory cache.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name shmcache.example.com;
|
||||
pagespeed FileCachePath "@@SHM_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name xfp.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed RespectXForwardedProto on;
|
||||
|
||||
location /redirecting_origin {
|
||||
pagespeed off;
|
||||
# Hack: we clear the response headers using headers_more.
|
||||
# If we don't, nginx will add an extra empty Location: headers here.
|
||||
# It is kind of hard to get nginx to generate a relative location header
|
||||
# that starts with "/".
|
||||
more_clear_headers 'Location';
|
||||
add_header Location /mod_pagespeed_example;
|
||||
return 301;
|
||||
}
|
||||
location /redirect {
|
||||
proxy_method GET;
|
||||
proxy_pass http://127.0.0.1:@@SECONDARY_PORT@@/redirecting_origin;
|
||||
proxy_set_header "Host" "xfp.example.com";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name xheader.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed XHeaderValue "UNSPECIFIED VERSION";
|
||||
}
|
||||
|
||||
# Support for embedded configurations, where image flags in the
|
||||
# VirtualHost serving HTML is not the same as the one serving resources,
|
||||
# and thus we must embed the image flags in the rewritten image URLs.
|
||||
#
|
||||
# Note that we test with two distinct caches.
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name embed-config-html.example.org;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
root "@@SERVER_ROOT@@/mod_pagespeed_test";
|
||||
|
||||
pagespeed AddOptionsToUrls on;
|
||||
pagespeed JpegRecompressionQuality 73;
|
||||
pagespeed DisableFilters inline_css,extend_cache,inline_javascript;
|
||||
pagespeed Domain embed-config-resources.example.com;
|
||||
|
||||
# Share a cache keyspace with embed-config-resources.example.com.
|
||||
pagespeed CacheFragment "embed-config";
|
||||
|
||||
pagespeed LoadFromFile "http://embed-config-resources.example.com/"
|
||||
"@@SERVER_ROOT@@/mod_pagespeed_example/";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name embed-config-resources.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
root "@@SERVER_ROOT@@/mod_pagespeed_example";
|
||||
|
||||
pagespeed AddOptionsToUrls on;
|
||||
|
||||
# Note that we do not set the jpeg quality here, but take
|
||||
# it from image URL query parameters that we synthesize in
|
||||
# from embed-config-html.example.org.
|
||||
|
||||
# Share a cache keyspace with embed-config-html.example.org.
|
||||
pagespeed CacheFragment "embed-config";
|
||||
|
||||
pagespeed LoadFromFile "http://embed-config-resources.example.com/"
|
||||
"@@SERVER_ROOT@@/mod_pagespeed_example/";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name ipro-for-browser.example.com;
|
||||
root "@@SERVER_ROOT@@/mod_pagespeed_example";
|
||||
pagespeed EnableFilters rewrite_images,rewrite_css;
|
||||
pagespeed EnableFilters convert_to_webp_lossless;
|
||||
pagespeed EnableFilters in_place_optimize_for_browser;
|
||||
pagespeed JpegRecompressionQuality 75;
|
||||
pagespeed WebpRecompressionQuality 70;
|
||||
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@@";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name respectvary.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed RespectVary on;
|
||||
add_header Vary User-Agent;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name cache_a.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed CacheFlushPollIntervalSec 1;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters inline_css;
|
||||
|
||||
# Make a non-empty subdirectory config to make sure that
|
||||
# cache.flush updates get transmitted to nested configurations.
|
||||
#
|
||||
# TODO(jmarantz): This test currently fails on ngx_pagespeed, meaning we
|
||||
# don't handle cache flushing correctly here. Uncomment the config below to
|
||||
# expose the error.
|
||||
#location /mod_pagespeed_test/cache_flush/ {
|
||||
# pagespeed RewriteLevel PassThrough;
|
||||
# pagespeed EnableFilters inline_css;
|
||||
# pagespeed DisableFilters add_instrumentation;
|
||||
#}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name cache_b.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
|
||||
pagespeed CacheFlushPollIntervalSec 1;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters inline_css;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name cache_c.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed CacheFlushFilename "othercache.flush";
|
||||
pagespeed CacheFlushPollIntervalSec 1;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters inline_css;
|
||||
}
|
||||
|
||||
# The next three server blocks are for a cdn test.
|
||||
server {
|
||||
# Sets up a logical home-page server on www.example.com
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name www.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
|
||||
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_css,rewrite_images;
|
||||
pagespeed CacheFragment "example";
|
||||
}
|
||||
server {
|
||||
# Sets up a logical origin for CDNs to fetch content from, on
|
||||
# origin.example.com.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name origin.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
|
||||
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_css,rewrite_images;
|
||||
pagespeed CacheFragment "example";
|
||||
}
|
||||
server {
|
||||
# Sets up a logical cdn, which is where we tell browsers to fetch resources
|
||||
# from.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name cdn.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
|
||||
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_css,rewrite_images;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name lff-ipro.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed LoadFromFile
|
||||
"http://lff-ipro.example.com/mod_pagespeed_example/lff_ipro"
|
||||
"@@SERVER_ROOT@@/mod_pagespeed_example/lff_ipro";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name tryfiles.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { }
|
||||
location ~ "^/ngx_pagespeed_static/" { }
|
||||
location ~ "^/ngx_pagespeed_beacon$" { }
|
||||
|
||||
try_files $uri $uri/ /mod_pagespeed_example/index.html;
|
||||
}
|
||||
|
||||
server {
|
||||
# Proxy modpagespeed.com for testing Issue 582.
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name modpagespeed.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed off;
|
||||
|
||||
location / {
|
||||
proxy_pass http://modpagespeed.com;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name custom-paths.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed StatisticsPath /custom_pagespeed_statistics;
|
||||
pagespeed ConsolePath /custom_pagespeed_console;
|
||||
pagespeed MessagesPath /custom_pagespeed_message;
|
||||
pagespeed AdminPath /custom_pagespeed_admin;
|
||||
|
||||
pagespeed StatisticsDomains Allow *;
|
||||
pagespeed GlobalStatisticsDomains Allow *;
|
||||
pagespeed MessagesDomains Allow *;
|
||||
pagespeed ConsoleDomains Allow *;
|
||||
pagespeed AdminDomains Allow *;
|
||||
pagespeed GlobalAdminDomains Allow *;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name inherit-paths.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed StatisticsDomains Allow *;
|
||||
pagespeed GlobalStatisticsDomains Allow *;
|
||||
pagespeed MessagesDomains Allow *;
|
||||
pagespeed ConsoleDomains Allow *;
|
||||
pagespeed AdminDomains Allow *;
|
||||
pagespeed GlobalAdminDomains Allow *;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name blocking.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name keepalive-html.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed RewriteLevel CoreFilters;
|
||||
error_log "@@TEST_TMP@@/keepalive-html.example.com.error.log" warn;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name keepalive-resource.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
error_log "@@TEST_TMP@@/keepalive-resource.example.com.error.log" warn;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name keepalive-beacon-get.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
error_log "@@TEST_TMP@@/keepalive-beacon-get.example.com.error.log" warn;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name keepalive-beacon-post.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
error_log "@@TEST_TMP@@/keepalive-beacon-post.example.com.error.log" warn;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name keepalive-static.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
error_log "@@TEST_TMP@@/keepalive-static.example.com.error.log" warn;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name response-header-filters.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed on;
|
||||
location / {
|
||||
proxy_pass http://localhost:@@SECONDARY_PORT@@;
|
||||
proxy_set_header Host "enable-filter-header-origin.example.com";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name response-header-disable.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed EnableFilters add_instrumentation;
|
||||
pagespeed on;
|
||||
location / {
|
||||
proxy_pass http://localhost:@@SECONDARY_PORT@@;
|
||||
proxy_set_header Host "pagespeed-off-header-origin.example.com";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name headers.example.com;
|
||||
pagespeed InPlaceRewriteDeadlineMs -1;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed LoadFromFile "http://headers.example.com/"
|
||||
"@@SERVER_ROOT@@/";
|
||||
location /mod_pagespeed_test/ {
|
||||
more_set_headers "Server: override";
|
||||
more_set_headers -s '404' 'Cache-Control: override';
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name custom404.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
error_page 404 /404.html;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name ipro.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
|
||||
pagespeed on;
|
||||
pagespeed InPlaceResourceOptimization on;
|
||||
|
||||
location /mod_pagespeed_test/ipro/nocache/test_image_dont_reuse.png {
|
||||
add_header Cache-Control no-cache;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/no-cache-control-header {
|
||||
add_header Cache-Control "";
|
||||
pagespeed ImplicitCacheTtlMs 333000;
|
||||
}
|
||||
}
|
||||
|
||||
# Test hosts to cover all possible cache configurations. L1 will be filecache
|
||||
# or memcache depending on the setting of MEMCACHED_TEST. These four hosts
|
||||
# are for the four settings for the L2 cache.
|
||||
|
||||
# 1. L2_d=LRU, L2_m=LRU
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name lrud-lrum.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@_lrud_lrum";
|
||||
|
||||
pagespeed LRUCacheKbPerProcess 1024;
|
||||
pagespeed LRUCacheByteLimit 2000;
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
pagespeed CriticalImagesBeaconEnabled false;
|
||||
}
|
||||
|
||||
# 2. L2_d=LRU, L2_m=SHM
|
||||
pagespeed CreateSharedMemoryMetadataCache
|
||||
"@@SECONDARY_CACHE@@_lrud_shmm" 8192;
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name lrud-shmm.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@_lrud_shmm";
|
||||
|
||||
pagespeed LRUCacheKbPerProcess 1024;
|
||||
pagespeed LRUCacheByteLimit 2000;
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
pagespeed CriticalImagesBeaconEnabled false;
|
||||
}
|
||||
|
||||
# 3. L2_d=none, L2_m=SHM
|
||||
pagespeed CreateSharedMemoryMetadataCache
|
||||
"@@SECONDARY_CACHE@@_noned_shmm" 8192;
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name noned-shmm.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@_noned_shmm";
|
||||
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
pagespeed CriticalImagesBeaconEnabled false;
|
||||
}
|
||||
|
||||
# 4. L2_d=none, L2_m=none
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name noned-nonem.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@_noned_nonem";
|
||||
|
||||
pagespeed EnableFilters rewrite_images;
|
||||
pagespeed CriticalImagesBeaconEnabled false;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name date.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
add_header "Date" "Fri, 16 Oct 2009 23:05:07 GMT";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name options-by-cookies-enabled.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@_optionsbycookieson";
|
||||
pagespeed AllowOptionsToBeSetByCookies true;
|
||||
pagespeed StickyQueryParameters sticky_secret;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters collapse_whitespace;
|
||||
pagespeed DisableFilters remove_comments,add_instrumentation;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name options-by-cookies-disabled.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@_optionsbycookiesoff";
|
||||
pagespeed AllowOptionsToBeSetByCookies false;
|
||||
pagespeed DisableFilters add_instrumentation;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name redirect.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@_redirected";
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters add_instrumentation,collapse_whitespace;
|
||||
location /redirect {
|
||||
rewrite ^/redirect/(.*) http://$server_name/$1 permanent;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name request-option-override.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RequestOptionOverride abc;
|
||||
pagespeed RewriteLevel Passthrough;
|
||||
pagespeed EnableFilters collapse_whitespace;
|
||||
pagespeed DisableFilters remove_comments,add_instrumentation;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name signed-urls.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed UrlSigningKey helloworld;
|
||||
pagespeed RewriteLevel Passthrough;
|
||||
pagespeed EnableFilters collapse_whitespace,rewrite_images;
|
||||
pagespeed DisableFilters remove_comments,add_instrumentation;
|
||||
}
|
||||
|
||||
# For testing signed URLs, ignoring signature validity.
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name signed-urls-transition.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed UrlSigningKey helloworld;
|
||||
pagespeed AcceptInvalidSignatures true;
|
||||
pagespeed RewriteLevel Passthrough;
|
||||
pagespeed EnableFilters collapse_whitespace,rewrite_images;
|
||||
pagespeed DisableFilters remove_comments,add_instrumentation;
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name unsigned-urls-transition.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
# This server will not sign URLs, but AcceptInvalidSignature is on.
|
||||
pagespeed AcceptInvalidSignatures true;
|
||||
pagespeed RewriteLevel Passthrough;
|
||||
pagespeed EnableFilters collapse_whitespace,rewrite_images;
|
||||
pagespeed DisableFilters remove_comments,add_instrumentation;
|
||||
}
|
||||
|
||||
# Start remote config servers.
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name remote-config.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/standard";
|
||||
pagespeed RemoteConfigurationTimeoutMs 1500;
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name remote-config-partially-invalid.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RemoteConfigurationUrl
|
||||
"http://127.0.0.1:@@RCPORT@@/partly-invalid";
|
||||
pagespeed RemoteConfigurationTimeoutMs 1500;
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name remote-config-invalid.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/invalid";
|
||||
pagespeed RemoteConfigurationTimeoutMs 1500;
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name remote-config-failed-fetch.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/fail-future";
|
||||
pagespeed RemoteConfigurationTimeoutMs 1500;
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name remote-config-slow-fetch.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/timeout";
|
||||
pagespeed RemoteConfigurationTimeoutMs 1500;
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name remote-config-experiment.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed RemoteConfigurationUrl "http://127.0.0.1:@@RCPORT@@/experiment";
|
||||
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;
|
||||
}
|
||||
|
||||
# Test that pagespeed is disabled when sendfile headers are present.
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name uses-sendfile.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed EnableFilters inline_javascript,rewrite_javascript;
|
||||
add_header 'X-Sendfile' 'blablabla';
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name doesnt-sendfile.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed EnableFilters inline_javascript,rewrite_javascript;
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name uses-xaccelredirect.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
pagespeed EnableFilters inline_javascript,rewrite_javascript;
|
||||
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.
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name ipro-proxy.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@_ipro_proxy";
|
||||
|
||||
pagespeed on;
|
||||
pagespeed InPlaceResourceOptimization on;
|
||||
pagespeed EnableFilters rewrite_domains;
|
||||
|
||||
location / {
|
||||
proxy_pass
|
||||
"http://localhost:@@PRIMARY_PORT@@/mod_pagespeed_test/ipro/mod_deflate/";
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name compressed-css.example.com;
|
||||
pagespeed on;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
pagespeed InPlaceResourceOptimization on;
|
||||
}
|
||||
|
||||
# nested gzip config: pagespeed gzip on/off
|
||||
server {
|
||||
pagespeed on;
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name gzip-test1.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
location /mod_pagespeed_example/ {
|
||||
pagespeed gzip off;
|
||||
}
|
||||
location /mod_pagespeed_example/styles/ {
|
||||
pagespeed gzip on;
|
||||
}
|
||||
}
|
||||
|
||||
# nested gzip config: pagespeed on/off
|
||||
server {
|
||||
pagespeed on;
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name gzip-test2.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
location /mod_pagespeed_example/ {
|
||||
pagespeed off;
|
||||
}
|
||||
location /mod_pagespeed_example/styles/ {
|
||||
pagespeed on;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
pagespeed on;
|
||||
pagespeed EnableFilters add_instrumentation;
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name proxy-post.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
location / {
|
||||
# Transform the POST to a GET request for the origin,
|
||||
# as nginx's static handler doesn't allow POST requests.
|
||||
proxy_method GET;
|
||||
proxy_pass http://127.0.0.1:@@SECONDARY_PORT@@/;
|
||||
proxy_set_header "Host" "proxy-post-origin.example.com";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
pagespeed off;
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name proxy-post-origin.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
root "@@SERVER_ROOT@@/";
|
||||
}
|
||||
|
||||
server {
|
||||
# Write all post data to temp files
|
||||
client_body_in_file_only clean;
|
||||
pagespeed CriticalImagesBeaconEnabled true;
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name beacon-post-temp-file.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name script-filters.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
root "@@SERVER_ROOT@@/";
|
||||
set $filters "";
|
||||
set $domain_shards "cdn1.example.com,cdn2.example.com";
|
||||
if ($http_X_Script) {
|
||||
set $filters "add_instrumentation";
|
||||
set $domain_shards "";
|
||||
}
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_domains;
|
||||
pagespeed EnableFilters $filters;
|
||||
pagespeed ShardDomain script-filters.example.com "$domain_shards";
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name purge.example.com;
|
||||
|
||||
# Test purging individual URLs without flushing the entire metadata cache.
|
||||
pagespeed EnableCachePurge on;
|
||||
|
||||
pagespeed PurgeMethod PURGE;
|
||||
root "@@SERVER_ROOT@@/purge";
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@_purge";
|
||||
pagespeed DisableFilters add_instrumentation;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_css;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name psoff-dir-on.example.com;
|
||||
|
||||
# Test purging individual URLs without flushing the entire metadata cache.
|
||||
pagespeed EnableCachePurge on;
|
||||
|
||||
pagespeed PurgeMethod PURGE;
|
||||
root "@@SERVER_ROOT@@/purge";
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@_dir_on";
|
||||
pagespeed DisableFilters add_instrumentation;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters rewrite_css;
|
||||
pagespeed off;
|
||||
location / {
|
||||
pagespeed on;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name cc-header-origin.example.com;
|
||||
pagespeed InPlaceResourceOptimization off;
|
||||
pagespeed off;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
root "@@SERVER_ROOT@@/";
|
||||
location /mod_pagespeed_test/nostore {
|
||||
add_header "Cache-Control" "max-age=12345";
|
||||
add_header "Cache-Control" "public, no-store";
|
||||
add_header "Cache-Control" "max-age=14";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name enable-filter-header-origin.example.com;
|
||||
pagespeed InPlaceResourceOptimization off;
|
||||
pagespeed off;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
root "@@SERVER_ROOT@@/";
|
||||
location / {
|
||||
add_header "PageSpeedFilters" "add_instrumentation";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name pagespeed-off-header-origin.example.com;
|
||||
pagespeed InPlaceResourceOptimization off;
|
||||
pagespeed off;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
root "@@SERVER_ROOT@@/";
|
||||
location / {
|
||||
add_header "PageSpeed" "off";
|
||||
}
|
||||
}
|
||||
|
||||
pagespeed MessagesDomains Allow messages-allowed.example.com;
|
||||
pagespeed MessagesDomains Allow cleared-inherited.example.com;
|
||||
pagespeed MessagesDomains Allow cleared-inherited-reallowed.example.com;
|
||||
pagespeed MessagesDomains Allow more-messages-allowed.example.com;
|
||||
pagespeed MessagesDomains Allow anything-*-wildcard.example.com;
|
||||
pagespeed MessagesDomains Allow localhost;
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name messages-allowed.example.com
|
||||
messages-not-allowed.example.com
|
||||
more-messages-allowed.example.com
|
||||
anything-a-wildcard.example.com
|
||||
anything-b-wildcard.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name messages-still-not-allowed.example.com
|
||||
but-this-message-allowed.example.com
|
||||
and-this-one.example.com;
|
||||
pagespeed MessagesDomains Allow but-this-message-allowed.example.com;
|
||||
pagespeed MessagesDomains Allow and-this-one.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name cleared-inherited.example.com
|
||||
cleared-inherited-reallowed.example.com
|
||||
messages-allowed-at-vhost.example.com
|
||||
messages-not-allowed-at-vhost.example.com
|
||||
anything-c-wildcard.example.com;
|
||||
pagespeed MessagesDomains Disallow *;
|
||||
pagespeed MessagesDomains Allow cleared-inherited-reallowed.example.com;
|
||||
pagespeed MessagesDomains Allow messages-allowed-at-vhost.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name cleared-inherited-unlisted.example.com;
|
||||
pagespeed MessagesDomains Allow *;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
server {
|
||||
server_name nothing-allowed.example.com;
|
||||
pagespeed MessagesDomains Disallow *;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
server {
|
||||
server_name nothing-explicitly-allowed.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
}
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
listen [::]:@@SECONDARY_PORT@@;
|
||||
server_name everything-explicitly-allowed.example.com
|
||||
everything-explicitly-allowed-but-aliased.example.com;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
pagespeed StatisticsDomains Allow everything-explicitly-allowed.example.com;
|
||||
pagespeed GlobalStatisticsDomains
|
||||
Allow everything-explicitly-allowed.example.com;
|
||||
pagespeed MessagesDomains Allow everything-explicitly-allowed.example.com;
|
||||
pagespeed ConsoleDomains Allow everything-explicitly-allowed.example.com;
|
||||
pagespeed AdminDomains Allow everything-explicitly-allowed.example.com;
|
||||
pagespeed GlobalAdminDomains
|
||||
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 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 {
|
||||
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 {
|
||||
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 {
|
||||
listen @@PRIMARY_PORT@@;
|
||||
listen [::]:@@PRIMARY_PORT@@;
|
||||
server_name localhost;
|
||||
pagespeed FileCachePath "@@FILE_CACHE@@";
|
||||
|
||||
location ~ ^/pagespeed_admin {
|
||||
allow 127.0.0.1;
|
||||
allow ::1;
|
||||
deny all;
|
||||
}
|
||||
|
||||
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 "" "";
|
||||
}
|
||||
|
||||
# Backend for ipro-proxy.example.com
|
||||
location /mod_pagespeed_test/ipro/mod_deflate/ {
|
||||
pagespeed off;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/cachable_rewritten_html/ {
|
||||
# This location has the html files that will be configured to be stored
|
||||
# in the proxy_cache layer.
|
||||
pagespeed DownstreamCachePurgeMethod "GET";
|
||||
pagespeed DownstreamCachePurgeLocationPrefix "http://localhost:@@SECONDARY_PORT@@/purge";
|
||||
pagespeed DownstreamCacheRebeaconingKey "random_rebeaconing_key";
|
||||
# We use a very small deadline here to force the rewriting to not complete
|
||||
# in the very first attempt.
|
||||
pagespeed RewriteDeadlinePerFlushMs 1;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters collapse_whitespace,extend_cache,recompress_images;
|
||||
pagespeed CriticalImagesBeaconEnabled true;
|
||||
add_header Cache-Control "public, max-age=100";
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/disable_no_transform/index.html {
|
||||
pagespeed DisableRewriteOnNoTransform off;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/disable_no_transform/disable_no_transform.css {
|
||||
add_header 'Cache-Control' 'no-transform';
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/no_transform {
|
||||
add_header 'Cache-Control' 'no-transform';
|
||||
}
|
||||
|
||||
# uncomment the following two lines if you're testing memcached
|
||||
#pagespeed MemcachedServers "localhost:11211";
|
||||
#pagespeed MemcachedThreads 1;
|
||||
|
||||
pagespeed on;
|
||||
|
||||
#pagespeed CacheFlushPollIntervalSec 1;
|
||||
|
||||
#pagespeed RunExperiment on;
|
||||
#pagespeed AnalyticsID "UA-XXXXXXXX-Y";
|
||||
#pagespeed ExperimentSpec "id=1;percent=50;default";
|
||||
#pagespeed ExperimentSpec "id=2;percent=50";
|
||||
|
||||
pagespeed Library 43 1o978_K0_LNE5_ystNklf
|
||||
http://www.modpagespeed.com/rewrite_javascript.js;
|
||||
pagespeed RetainComment " google_ad_section*";
|
||||
pagespeed PermitIdsForCssCombining "allowed-to-combine-1-*";
|
||||
pagespeed PermitIdsForCssCombining "allowed-to-combine-2-*";
|
||||
|
||||
# Test proxying of non-.pagespeed. resources.
|
||||
pagespeed MapProxyDomain http://localhost:@@PRIMARY_PORT@@/modpagespeed_http
|
||||
http://@@PAGESPEED_TEST_HOST@@/do_not_modify;
|
||||
pagespeed MapProxyDomain http://localhost:@@PRIMARY_PORT@@/content_type_present
|
||||
http://@@PAGESPEED_TEST_HOST@@:8091;
|
||||
pagespeed MapProxyDomain http://localhost:@@PRIMARY_PORT@@/content_type_absent
|
||||
http://@@PAGESPEED_TEST_HOST@@:8092;
|
||||
|
||||
add_header X-Extra-Header 1;
|
||||
|
||||
# Establish a proxy mapping where the current server proxies an image
|
||||
# stored on ref.pssdemos.com.
|
||||
pagespeed MapProxyDomain localhost:@@PRIMARY_PORT@@/gstatic_images
|
||||
http://www.gstatic.com/psa/static;
|
||||
|
||||
location /ngx_pagespeed_statistics {
|
||||
allow 127.0.0.1;
|
||||
allow ::1;
|
||||
deny all;
|
||||
}
|
||||
|
||||
location /ngx_pagespeed_message {
|
||||
allow 127.0.0.1;
|
||||
allow ::1;
|
||||
deny all;
|
||||
}
|
||||
|
||||
pagespeed Domain modpagespeed.com:1023;
|
||||
# As opposed to mod_pagespeed, our default for aris is 'on'
|
||||
pagespeed AvoidRenamingIntrospectiveJavascript off;
|
||||
|
||||
location /mod_pagespeed_test/nostore {
|
||||
proxy_pass http://localhost:@@SECONDARY_PORT@@;
|
||||
proxy_set_header Host "cc-header-origin.example.com";
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/forbid_all_disabled/disabled {
|
||||
# Prevent the enabling of these filters for files in this directory
|
||||
# -and- all subdirectories.
|
||||
#
|
||||
# Apache checks here that they can't be renabled with .htaccess, but
|
||||
# that's not how Nginx location blocks work.
|
||||
pagespeed ForbidAllDisabledFilters true;
|
||||
pagespeed DisableFilters remove_quotes,remove_comments;
|
||||
pagespeed DisableFilters collapse_whitespace;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/max_html_parse_size {
|
||||
pagespeed MaxHtmlParseBytes 5000;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_example/core_filters/ {
|
||||
pagespeed RewriteLevel CoreFilters;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_example/pass_through/ {
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
}
|
||||
|
||||
#location / {
|
||||
# proxy_pass http://www.google.com;
|
||||
#}
|
||||
|
||||
location /mod_pagespeed_test/ssi/ {
|
||||
ssi on;
|
||||
|
||||
pagespeed EnableFilters collapse_whitespace,remove_comments,combine_css;
|
||||
pagespeed DisableFilters add_instrumentation;
|
||||
pagespeed DisableFilters inline_css;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/no_cache/ {
|
||||
add_header Cache-Control no-cache;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/compressed/ {
|
||||
add_header Content-Encoding gzip;
|
||||
|
||||
# Even though this is also in the server block it must be repeated here
|
||||
# because add_header directives are only inherited if you don't define
|
||||
# more of them. See: http://serverfault.com/questions/400197
|
||||
add_header X-Extra-Header 1;
|
||||
|
||||
types {
|
||||
text/javascript custom_ext;
|
||||
}
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/shard/ {
|
||||
pagespeed ShardDomain "localhost:@@PRIMARY_PORT@@" shard1,shard2;
|
||||
pagespeed RewriteLevel PassThrough;
|
||||
pagespeed EnableFilters extend_cache;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/retain_cache_control/ {
|
||||
pagespeed ModifyCachingHeaders off;
|
||||
add_header Cache-Control "private, max-age=3000";
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/retain_cache_control_with_downstream_caching/ {
|
||||
pagespeed ModifyCachingHeaders on;
|
||||
pagespeed DownstreamCachePurgeLocationPrefix "http://localhost:8020/";
|
||||
add_header Cache-Control "private, max-age=3000";
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/avoid_renaming_introspective_javascript__on/ {
|
||||
pagespeed AvoidRenamingIntrospectiveJavascript on;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/custom_options/ {
|
||||
pagespeed DisableFilters convert_jpeg_to_progressive;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/test_image_dont_reuse.png {
|
||||
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/ {
|
||||
# TODO(jmarantz): ModPagespeedInPlaceWaitForOptimized should be superfluous,
|
||||
# or made equivalent to ModPagespeedInPlaceRewriteDeadlineMs -1, which waits
|
||||
# forever. Otherwise ModPagespeedInPlaceRewriteDeadlineMs should just have
|
||||
# the specified deadline.
|
||||
# # See https://github.com/pagespeed/mod_pagespeed/issues/1171 for more
|
||||
# detailed discussion.
|
||||
pagespeed InPlaceWaitForOptimized on;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/wait/long/ {
|
||||
# Make the deadline long here for valgrind tests. We could
|
||||
# conditionalize this.
|
||||
pagespeed InPlaceRewriteDeadlineMs 10000;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/wait/short/ {
|
||||
pagespeed EnableFilters in_place_optimize_for_browser;
|
||||
|
||||
# Make the deadline short here as we expect to always miss it
|
||||
# in tests.
|
||||
pagespeed InPlaceRewriteDeadlineMs 1;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/instant/wait/ {
|
||||
pagespeed InPlaceWaitForOptimized on;
|
||||
|
||||
# TODO(jefftk): When running with valgrind we need to raise the rewrite
|
||||
# deadline or else we get "Deadline exceeded for rewrite of resource".
|
||||
# I had thought InPlaceWaitForOptimized was supposed to disable the
|
||||
# rewrite deadline, but it seems not to.
|
||||
#
|
||||
# InPlaceWaitForOptimized is definitely doing something, though: when I
|
||||
# remove the InPlaceRewriteDeadlineMs line below and run without valgrind,
|
||||
# purple.css is optimized via ipro on the first request but if I set
|
||||
# InPlaceWaitForOptimized to off then it is not.
|
||||
pagespeed InPlaceRewriteDeadlineMs 1000;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/instant/deadline/ {
|
||||
set $ps_deadline -1;
|
||||
pagespeed ImageRecompressionQuality $ps_deadline;
|
||||
pagespeed InPlaceRewriteDeadlineMs $ps_deadline;
|
||||
}
|
||||
|
||||
# Test to make sure that user-authenticated resources do not get cached and
|
||||
# optimized.
|
||||
location /mod_pagespeed_test/auth/ {
|
||||
auth_basic "Restricted";
|
||||
auth_basic_user_file "@@SERVER_ROOT@@/mod_pagespeed_test/auth/passwd.conf";
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/cookie/ {
|
||||
# Add Vary:Cookie. This should prevent us from optimizing the
|
||||
# vary_cookie.css even though PagespeedRespectVary is off.
|
||||
# test/nginx_system_test.sh does the fetches test with and w/o cookies.
|
||||
add_header Vary Cookie;
|
||||
pagespeed RespectVary off;
|
||||
pagespeed InPlaceWaitForOptimized on;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/ipro/cookie2/ {
|
||||
# Add Vary:Cookie2. This should prevent us from optimizing the
|
||||
# vary_cookie2.css even though PagespeedRespectVary is off.
|
||||
# test/nginx_system_test.sh does the fetches test with and w/o cookie2.
|
||||
add_header Vary Cookie2;
|
||||
pagespeed RespectVary off;
|
||||
pagespeed InPlaceWaitForOptimized on;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/vary/ {
|
||||
pagespeed RespectVary on;
|
||||
}
|
||||
|
||||
location ~ /mod_pagespeed_test/vary/\.(js|css)$ {
|
||||
add_header Vary User-Agent;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/vary/no_respect/ {
|
||||
pagespeed DisableFilters add_instrumentation,inline_css;
|
||||
pagespeed RespectVary off;
|
||||
}
|
||||
|
||||
location /mod_pagespeed_test/experimental_js_minifier/ {
|
||||
pagespeed UseExperimentalJsMinifier on;
|
||||
}
|
||||
|
||||
pagespeed FetchHttps enable;
|
||||
location /mod_pagespeed_test/https_fetch/ {
|
||||
pagespeed DisableFilters inline_images;
|
||||
set $ps_gstatic "https://www.gstatic.com/psa/static";
|
||||
pagespeed MapProxyDomain
|
||||
http://localhost:@@PRIMARY_PORT@@/https_gstatic_dot_com
|
||||
$ps_gstatic;
|
||||
}
|
||||
|
||||
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
|
||||
# directly, but so far this is the best I've come up with and duplicating
|
||||
# the test doesn't seem to make sense.
|
||||
pagespeed LoadFromFile
|
||||
"http://$host:@@PRIMARY_PORT@@/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;
|
||||
|
||||
# Test LoadFromFile mapping by mapping one dir to another.
|
||||
pagespeed LoadFromFile
|
||||
"http://localhost:@@PRIMARY_PORT@@/mod_pagespeed_test/load_from_file/web_dir/"
|
||||
"@@SERVER_ROOT@@/mod_pagespeed_test/load_from_file/file_dir/";
|
||||
pagespeed LoadFromFileMatch
|
||||
"^http://localhost:@@PRIMARY_PORT@@/mod_pagespeed_test/load_from_file_match/web_([^/]*)/"
|
||||
"@@SERVER_ROOT@@/mod_pagespeed_test/load_from_file/file_\1/";
|
||||
pagespeed LoadFromFileRule Disallow
|
||||
"@@SERVER_ROOT@@/mod_pagespeed_test/load_from_file/file_dir/httponly/";
|
||||
pagespeed LoadFromFileRuleMatch Disallow \.ssp.css$ps_dollar;
|
||||
pagespeed LoadFromFileRuleMatch Allow exception\.ssp\.css$ps_dollar;
|
||||
#charset koi8-r;
|
||||
|
||||
#access_log logs/host.access.log main;
|
||||
|
||||
index index.html;
|
||||
|
||||
|
||||
#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 html;
|
||||
}
|
||||
}
|
||||
|
||||
sendfile on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
types {
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
text/xml xml;
|
||||
image/gif gif;
|
||||
image/jpeg jpeg jpg;
|
||||
application/x-javascript js;
|
||||
application/atom+xml atom;
|
||||
application/rss+xml rss;
|
||||
|
||||
text/mathml mml;
|
||||
text/plain txt;
|
||||
text/vnd.sun.j2me.app-descriptor jad;
|
||||
text/vnd.wap.wml wml;
|
||||
text/x-component htc;
|
||||
|
||||
image/png png;
|
||||
image/tiff tif tiff;
|
||||
image/vnd.wap.wbmp wbmp;
|
||||
image/x-icon ico;
|
||||
image/x-jng jng;
|
||||
image/x-ms-bmp bmp;
|
||||
image/svg+xml svg svgz;
|
||||
image/webp webp;
|
||||
|
||||
application/json json;
|
||||
application/java-archive jar war ear;
|
||||
application/mac-binhex40 hqx;
|
||||
application/msword doc;
|
||||
application/pdf pdf;
|
||||
application/postscript ps eps ai;
|
||||
application/rtf rtf;
|
||||
application/vnd.ms-excel xls;
|
||||
application/vnd.ms-powerpoint ppt;
|
||||
application/vnd.wap.wmlc wmlc;
|
||||
application/vnd.google-earth.kml+xml kml;
|
||||
application/vnd.google-earth.kmz kmz;
|
||||
application/x-7z-compressed 7z;
|
||||
application/x-cocoa cco;
|
||||
application/x-java-archive-diff jardiff;
|
||||
application/x-java-jnlp-file jnlp;
|
||||
application/x-makeself run;
|
||||
application/x-perl pl pm;
|
||||
application/x-pilot prc pdb;
|
||||
application/x-rar-compressed rar;
|
||||
application/x-redhat-package-manager rpm;
|
||||
application/x-sea sea;
|
||||
application/x-shockwave-flash swf;
|
||||
application/x-stuffit sit;
|
||||
application/x-tcl tcl tk;
|
||||
application/x-x509-ca-cert der pem crt;
|
||||
application/x-xpinstall xpi;
|
||||
application/xhtml+xml xhtml;
|
||||
application/zip zip;
|
||||
|
||||
application/octet-stream bin exe dll;
|
||||
application/octet-stream deb;
|
||||
application/octet-stream dmg;
|
||||
application/octet-stream eot;
|
||||
application/octet-stream iso img;
|
||||
application/octet-stream msi msp msm;
|
||||
|
||||
audio/midi mid midi kar;
|
||||
audio/mpeg mp3;
|
||||
audio/ogg ogg;
|
||||
audio/x-m4a m4a;
|
||||
audio/x-realaudio ra;
|
||||
|
||||
video/3gpp 3gpp 3gp;
|
||||
video/mp4 mp4;
|
||||
video/mpeg mpeg mpg;
|
||||
video/quicktime mov;
|
||||
video/webm webm;
|
||||
video/x-flv flv;
|
||||
video/x-m4v m4v;
|
||||
video/x-mng mng;
|
||||
video/x-ms-asf asx asf;
|
||||
video/x-ms-wmv wmv;
|
||||
video/x-msvideo avi;
|
||||
}
|
||||
default_type application/octet-stream;
|
||||
|
||||
}
|
||||
Executable
+110
@@ -0,0 +1,110 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2013 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)
|
||||
#
|
||||
# Runs ngx_pagespeed system tests.
|
||||
#
|
||||
# Exits with status 0 if all tests pass.
|
||||
# Exits with status 1 immediately if any test fails.
|
||||
# Exits with status 2 if command line args are wrong.
|
||||
#
|
||||
# Usage:
|
||||
# ./run_tests.sh
|
||||
# Or:
|
||||
# ./run_tests.sh /path/to/mod_pagespeed /path/to/nginx/binary
|
||||
#
|
||||
# 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
|
||||
# TEST_NATIVE_FETCHER=true to also test the native fetcher, set
|
||||
# TEST_SERF_FETCHER=false to skip the serf fetcher.
|
||||
TEST_NATIVE_FETCHER=${TEST_NATIVE_FETCHER:-false}
|
||||
TEST_SERF_FETCHER=${TEST_SERF_FETCHER:-true}
|
||||
|
||||
# Normally we actually run the tests, but you might only want us to set up nginx
|
||||
# for you so you can do manual testing. If so, set RUN_TESTS=false and this
|
||||
# will exit after configuring and starting nginx.
|
||||
RUN_TESTS=${RUN_TESTS:-true}
|
||||
|
||||
# To run tests with valgrind, set the environment variable USE_VALGRIND to
|
||||
# true.
|
||||
USE_VALGRIND=${USE_VALGRIND:-false}
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
MOD_PAGESPEED_DIR="testing-dependencies/mod_pagespeed/"
|
||||
NGINX_EXECUTABLE="nginx/sbin/nginx"
|
||||
elif [ "$#" -eq 2 ]; then
|
||||
MOD_PAGESPEED_DIR="$1"
|
||||
NGINX_EXECUTABLE="$2"
|
||||
else
|
||||
echo "Usage: $0 [mod_pagespeed_dir nginx_executable]"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
: ${PRIMARY_PORT:=8050}
|
||||
: ${SECONDARY_PORT:=8051}
|
||||
: ${CONTROLLER_PORT:=8053}
|
||||
: ${RCPORT:=9991}
|
||||
: ${PAGESPEED_TEST_HOST:=selfsigned.modpagespeed.com}
|
||||
: ${PHP_PORT:=9000}
|
||||
|
||||
this_dir="$( cd $(dirname "$0") && pwd)"
|
||||
|
||||
function run_test_checking_failure() {
|
||||
"$MOD_PAGESPEED_DIR/install/start_php.sh" "$PHP_PORT"
|
||||
USE_VALGRIND="$USE_VALGRIND" \
|
||||
PRIMARY_PORT="$PRIMARY_PORT" \
|
||||
SECONDARY_PORT="$SECONDARY_PORT" \
|
||||
MOD_PAGESPEED_DIR="$MOD_PAGESPEED_DIR" \
|
||||
NGINX_EXECUTABLE="$NGINX_EXECUTABLE" \
|
||||
PAGESPEED_TEST_HOST="$PAGESPEED_TEST_HOST" \
|
||||
RUN_TESTS="$RUN_TESTS" \
|
||||
CONTROLLER_PORT="$CONTROLLER_PORT" \
|
||||
RCPORT="$RCPORT" \
|
||||
bash "$this_dir/nginx_system_test.sh"
|
||||
STATUS=$?
|
||||
echo "With $@ setup."
|
||||
case $STATUS in
|
||||
0)
|
||||
return # No failure.
|
||||
;;
|
||||
3)
|
||||
return # Only expected failures.
|
||||
;;
|
||||
4)
|
||||
return # Return passing error code when running manually.
|
||||
;;
|
||||
*)
|
||||
exit 1 # Real failure.
|
||||
esac
|
||||
}
|
||||
|
||||
if $TEST_SERF_FETCHER; then
|
||||
NATIVE_FETCHER=off run_test_checking_failure "serf fetcher"
|
||||
fi
|
||||
|
||||
if $TEST_NATIVE_FETCHER; then
|
||||
NATIVE_FETCHER=on run_test_checking_failure "native fetcher"
|
||||
fi
|
||||
@@ -0,0 +1,193 @@
|
||||
# Copyright 2013 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: oschaaf@we-amp.com (Otto van der Schaaf)
|
||||
|
||||
|
||||
# The first few suppressions can be found in other modules
|
||||
# and easily found when searched for, and seem false positives.
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Param
|
||||
socketcall.sendmsg(msg.msg_iov[i])
|
||||
fun:__sendmsg_nocancel
|
||||
fun:ngx_write_channel
|
||||
fun:ngx_signal_worker_processes
|
||||
fun:ngx_master_process_cycle
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Param
|
||||
socketcall.sendmsg(msg.msg_iov[i])
|
||||
fun:__sendmsg_nocancel
|
||||
fun:ngx_write_channel
|
||||
fun:ngx_master_process_cycle
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Param
|
||||
socketcall.sendmsg(msg.msg_iov[i])
|
||||
fun:__sendmsg_nocancel
|
||||
fun:ngx_write_channel
|
||||
fun:ngx_pass_open_channel
|
||||
fun:ngx_start_cache_manager_processes
|
||||
fun:ngx_master_process_cycle
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Param
|
||||
socketcall.sendmsg(msg.msg_iov[i])
|
||||
fun:__sendmsg_nocancel
|
||||
fun:ngx_write_channel
|
||||
fun:ngx_pass_open_channel
|
||||
fun:ngx_start_cache_manager_processes
|
||||
fun:ngx_master_process_cycle
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:ngx_alloc
|
||||
fun:ngx_event_process_init
|
||||
fun:ngx_worker_process_init
|
||||
fun:ngx_worker_process_cycle
|
||||
fun:ngx_spawn_process
|
||||
fun:ngx_start_worker_processes
|
||||
fun:ngx_master_process_cycle
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Param
|
||||
socketcall.sendmsg(msg.msg_iov[i])
|
||||
fun:__sendmsg_nocancel
|
||||
fun:ngx_write_channel
|
||||
fun:ngx_pass_open_channel
|
||||
fun:ngx_start_worker_processes
|
||||
fun:ngx_master_process_cycle
|
||||
fun:main
|
||||
}
|
||||
|
||||
# similar to http://trac.nginx.org/nginx/ticket/369
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Param
|
||||
pwrite64(buf)
|
||||
obj:/lib/x86_64-linux-gnu/libpthread-2.15.so
|
||||
fun:ngx_write_file
|
||||
fun:ngx_write_chain_to_file
|
||||
fun:ngx_write_chain_to_temp_file
|
||||
fun:ngx_event_pipe_write_chain_to_temp_file
|
||||
fun:ngx_event_pipe
|
||||
fun:ngx_http_upstream_process_upstream
|
||||
fun:ngx_http_upstream_process_header
|
||||
fun:ngx_http_upstream_handler
|
||||
fun:ngx_epoll_process_events
|
||||
fun:ngx_process_events_and_timers
|
||||
fun:ngx_worker_process_cycle
|
||||
}
|
||||
# Mentioned in https://github.com/pagespeed/ngx_pagespeed/issues/103
|
||||
# Assuming a false postives as the issue is closed.
|
||||
{
|
||||
<nginx false positive>
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
obj:/lib/x86_64-linux-gnu/libpthread-2.15.so
|
||||
fun:ngx_log_error_core
|
||||
fun:ngx_http_parse_complex_uri
|
||||
fun:ngx_http_process_request_uri
|
||||
fun:ngx_http_process_request_line
|
||||
fun:ngx_http_wait_request_handler
|
||||
fun:ngx_epoll_process_events
|
||||
fun:ngx_process_events_and_timers
|
||||
fun:ngx_worker_process_cycle
|
||||
fun:ngx_spawn_process
|
||||
fun:ngx_start_worker_processes
|
||||
fun:ngx_master_process_cycle
|
||||
}
|
||||
|
||||
# Extra suppresions for testing in release mode:
|
||||
|
||||
{
|
||||
<re2 uninitialised value in optimized code>
|
||||
Memcheck:Cond
|
||||
fun:_ZN3re24Prog8OptimizeEv
|
||||
...
|
||||
}
|
||||
{
|
||||
<re2 uninitialised value in optimized code>
|
||||
Memcheck:Value8
|
||||
fun:_ZN3re24Prog8OptimizeEv
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<re2 uninitialised value in optimized code>
|
||||
Memcheck:Cond
|
||||
fun:_ZN3re2L4AddQEPNS_9SparseSetEi
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<re2 uninitialised value in optimized code>
|
||||
Memcheck:Value8
|
||||
fun:_ZN3re2L4AddQEPNS_9SparseSetEi
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<re2 uninitialized value in optimized code>
|
||||
Memcheck:Value8
|
||||
fun:_ZN3re23DFA10AddToQueueEPNS0_5WorkqEij
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<re2 uninitialized value in optimized code>
|
||||
Memcheck:Cond
|
||||
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
|
||||
...
|
||||
}
|
||||
Reference in New Issue
Block a user