blob: e64036dbcc977a9bca8a33aadac4992198d47aff [file] [log] [blame]
# 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;
proxy_cache_path "@@PROXY_CACHE@@" levels=1:2 keys_zone=htmlcache:60m inactive=90m max_size=50m;
proxy_temp_path "@@TMP_PROXY_CACHE@@";
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;
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;
# 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";
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@@;
server_name max-cacheable-content-length.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_javascript;
pagespeed MaxCacheableContentLength 85;
}
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@@;
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";
}
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;
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:8050.
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@@;
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@@;
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@@;
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@@;
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@@;
server_name mpd.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed MapProxyDomain mpd.example.com/gstatic_images
http://www.gstatic.com/psa/static;
}
# These two vhosts are for testing the experiment framework (Furious).
server {
listen @@SECONDARY_PORT@@;
server_name experiment.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed InPlaceResourceOptimization off;
pagespeed RunExperiment on;
pagespeed AnalyticsID "123-45-6734";
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@@;
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@@;
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@@;
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@@;
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@@;
server_name downstreamcacheresource.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_images;
pagespeed DownstreamCachePurgeLocationPrefix "http://localhost:@@SECONDARY_PORT@@/purge";
}
server {
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.
#
# In Apache we can do this all with Directory blocks, but to get the same
# inheretence in Nginx we need to have location blocks inside a server block.
server {
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@@;
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@@;
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@@;
server_name unauthorizedresources.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed InlineResourcesWithoutExplicitAuthorization Script,Stylesheet;
pagespeed CssInlineMaxBytes 1000000;
}
server {
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@@;
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;
}
server {
listen 127.0.0.2:@@SECONDARY_PORT@@;
server_name loopbackfetch.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
}
server {
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@@;
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 {
listen @@SECONDARY_PORT@@;
server_name retaincomment.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RetainComment " google_ad_section*";
}
server {
# Test host for shared memory cache.
listen @@SECONDARY_PORT@@;
server_name shmcache.example.com;
pagespeed FileCachePath "@@SHM_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_images;
}
server {
listen @@SECONDARY_PORT@@;
server_name xfp.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RespectXForwardedProto on;
}
server {
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@@;
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@@;
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@@;
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 InPlaceResourceOptimization on;
pagespeed FileCachePath "@@IPRO_CACHE@@";
}
server {
listen @@SECONDARY_PORT@@;
server_name respectvary.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RespectVary on;
add_header Vary User-Agent;
}
server {
listen @@SECONDARY_PORT@@;
server_name cache_a.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed CacheFlushPollIntervalSec 1;
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters inline_css;
}
server {
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@@;
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@@;
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@@;
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@@;
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@@;
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@@;
server_name modpagespeed.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed off;
location / {
proxy_pass http://modpagespeed.com;
}
}
server {
listen @@SECONDARY_PORT@@;
server_name notransform.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_images;
add_header Cache-Control no-transform;
}
server {
listen @@SECONDARY_PORT@@;
server_name blocking.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_images;
}
server {
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@@;
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@@;
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@@;
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@@;
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@@;
server_name response-header-filters.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed on;
add_header PageSpeedFilters add_instrumentation;
}
server {
listen @@SECONDARY_PORT@@;
server_name response-header-disable.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed EnableFilters add_instrumentation;
pagespeed on;
add_header PageSpeed off;
}
server {
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@@;
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@@;
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@@;
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@@;
server_name noned-nonem.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@_noned_nonem";
pagespeed EnableFilters rewrite_images;
pagespeed CriticalImagesBeaconEnabled false;
}
server {
listen @@SECONDARY_PORT@@;
server_name date.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
add_header "Date" "Date: Fri, 16 Oct 2009 23:05:07 GMT";
}
# Proxy + IPRO a gzip'd file for testing Issue 896.
server {
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@@;
server_name compressed-css.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed InPlaceResourceOptimization on;
}
server {
listen @@PRIMARY_PORT@@;
server_name localhost;
pagespeed FileCachePath "@@FILE_CACHE@@";
location ~ ^/pagespeed_admin {
allow 127.0.0.1;
deny all;
}
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
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';
}
# uncomment the following two lines if you're testing memcached
#pagespeed MemcachedServers "localhost:11211";
#pagespeed MemcachedThreads 1;
pagespeed on;
pagespeed MessageBufferSize 200000;
#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;
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;
deny all;
}
location /ngx_pagespeed_message {
allow 127.0.0.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 {
add_header "Cache-Control" "max-age=12345";
add_header "Cache-Control" "public, no-store";
add_header "Cache-Control" "max-age=14";
}
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/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/ {
pagespeed InPlaceRewriteDeadlineMs -1;
}
# 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 LoadFromFile
"http://localhost:@@PRIMARY_PORT@@/mod_pagespeed_test/ipro/instant/"
"@@SERVER_ROOT@@/mod_pagespeed_test/ipro/instant/";
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$;
pagespeed LoadFromFileRuleMatch Allow exception\.ssp\.css$;
#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;
# set up gzip
gzip on;
gzip_vary on;
gzip_proxied any;
# Turn on gzip for all content types that should benefit from it.
gzip_types application/ecmascript;
gzip_types application/javascript;
gzip_types application/json;
gzip_types application/pdf;
gzip_types application/postscript;
gzip_types application/x-javascript;
gzip_types image/svg+xml;
gzip_types text/css;
gzip_types text/csv;
# "gzip_types text/html" is assumed.
gzip_types text/javascript;
gzip_types text/plain;
gzip_types text/xml;
gzip_http_version 1.0;
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/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;
}