Add a testcase for controlling rewriter settings using response headers from an origin, with rewriting in a reverse proxy.
diff --git a/test/nginx_system_test.sh b/test/nginx_system_test.sh
index 21e8f86..888d1f5 100755
--- a/test/nginx_system_test.sh
+++ b/test/nginx_system_test.sh
@@ -2622,6 +2622,16 @@
 check_from "$OUT" egrep -iq $'^Expires: .*\r$'
 check_from "$OUT" egrep -iq $'^Last-Modified: .*\r$'
 
+# Verify that we can control pagespeed settings via a response
+# header passed from an origin to a reverse proxy.
+start_test Honor response header direcives from origin
+URL="http://rproxy.rmcomments.example.com/"
+URL+="mod_pagespeed_example/remove_comments.html"
+echo http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $URL ...
+OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $URL)
+check_from "$OUT" fgrep -q "remove_comments example"
+check_not_from "$OUT" fgrep -q "This comment will be removed"
+
 # Test handling of large HTML files. We first test with a cold cache, and verify
 # that we bail out of parsing and insert a script redirecting to
 # ?PageSpeed=off. This should also insert an entry into the property cache so
diff --git a/test/pagespeed_test.conf.template b/test/pagespeed_test.conf.template
index 2be6f29..580b555 100644
--- a/test/pagespeed_test.conf.template
+++ b/test/pagespeed_test.conf.template
@@ -353,6 +353,30 @@
 
   server {
     listen @@SECONDARY_PORT@@;
+    server_name origin.rmcomments.example.com;
+#    pagespeed FileCachePath "@@FILE_CACHE@@";
+    pagespeed off;
+    add_header PageSpeedFilters remove_comments;
+  }
+  server {
+    # Set up a reverse proxy (rproxy.) and origin (origin.) as vhosts for
+    # showing that we can configure PageSpeed via response headers.
+    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://localhost:@@SECONDARY_PORT@@;
+      proxy_set_header X-Forwarded-For $remote_addr;
+      proxy_set_header Host origin.rmcomments.example.com;
+    }
+  }
+
+  server {
+    listen @@SECONDARY_PORT@@;
     server_name renderedimagebeacon.example.com;
     pagespeed FileCachePath "@@FILE_CACHE@@";