Merge pull request #235 from pagespeed/jefftk-map-proxy-domain
system-test: MapProxyDomain
This commit is contained in:
@@ -643,4 +643,38 @@ echo http_proxy=$SECONDARY_HOSTNAME $WGET --save-headers -O - $FILTERED
|
||||
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET --save-headers -O - $FILTERED 2>&1)
|
||||
check_from "$OUT" fgrep " 200 OK"
|
||||
|
||||
start_test MapProxyDomain
|
||||
# depends on MapProxyDomain in pagespeed_test.conf.template
|
||||
URL=$EXAMPLE_ROOT/proxy_external_resource.html
|
||||
echo Rewrite HTML with reference to a proxyable image.
|
||||
fetch_until -save -recursive $URL \
|
||||
'grep -c pss_images/xPuzzle\.jpg\.pagespeed\.ic' 1
|
||||
check_file_size "$OUTDIR/xPuzzle*" -lt 60000
|
||||
|
||||
# To make sure that we can reconstruct the proxied content by going back
|
||||
# to the origin, we must avoid hitting the output cache.
|
||||
# Note that cache-flushing does not affect the cache of rewritten resources;
|
||||
# only input-resources and metadata. To avoid hitting that cache and force
|
||||
# us to rewrite the resource from origin, we grab this resource from a
|
||||
# virtual host attached to a different cache.
|
||||
#
|
||||
# With the proper hash, we'll get a long cache lifetime.
|
||||
SECONDARY_HOST="http://mpd.example.com/pss_images"
|
||||
PROXIED_IMAGE="$SECONDARY_HOST/$(basename $OUTDIR/xPuzzle*)"
|
||||
WGET_ARGS="--save-headers"
|
||||
|
||||
echo $PROXIED_IMAGE expecting one year cache.
|
||||
http_proxy=$SECONDARY_HOSTNAME fetch_until $PROXIED_IMAGE \
|
||||
"grep -c max-age=31536000" 1
|
||||
|
||||
# With the wrong hash, we'll get a short cache lifetime (and also no output
|
||||
# cache hit.
|
||||
WRONG_HASH="0"
|
||||
PROXIED_IMAGE="$SECONDARY_HOST/xPuzzle.jpg.pagespeed.ic.$WRONG_HASH.jpg"
|
||||
echo Fetching $PROXIED_IMAGE expecting short private cache.
|
||||
http_proxy=$SECONDARY_HOSTNAME fetch_until $PROXIED_IMAGE \
|
||||
"grep -c max-age=300,private" 1
|
||||
|
||||
WGET_ARGS=""
|
||||
|
||||
check_failures_and_exit
|
||||
|
||||
@@ -22,6 +22,15 @@ http {
|
||||
root "@@SERVER_ROOT@@";
|
||||
pagespeed UsePerVHostStatistics on;
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
server_name mpd.example.com;
|
||||
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
|
||||
|
||||
pagespeed MapProxyDomain mpd.example.com:@@SECONDARY_PORT@@/pss_images
|
||||
http://ref.pssdemos.com/filter/images;
|
||||
}
|
||||
|
||||
server {
|
||||
listen @@SECONDARY_PORT@@;
|
||||
server_name preserveurls.example.com;
|
||||
@@ -178,6 +187,11 @@ http {
|
||||
|
||||
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@@/pss_images
|
||||
http://ref.pssdemos.com/filter/images;
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_param QUERY_STRING $query_string;
|
||||
|
||||
Reference in New Issue
Block a user