From 175ea6d039461061e663e371041d1cdbbb03d7b5 Mon Sep 17 00:00:00 2001 From: Jeff Kaufman Date: Wed, 22 Jul 2015 10:32:41 -0400 Subject: [PATCH] config: whitelist a few more directives for script variables When configuring downstream caching if you have an origin with multiple caches in front of it you might want to choose how you handle requests in response to which cache you're getting them from. Whitelist DownstreamCachePurgeLocationPrefix, DownstreamCachePurgeMethod, and DownstreamCacheRewrittenPercentageThreshold for scripting so this is possible. --- src/ngx_rewrite_options.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ngx_rewrite_options.cc b/src/ngx_rewrite_options.cc index 40d1bd1f6..c28f09916 100644 --- a/src/ngx_rewrite_options.cc +++ b/src/ngx_rewrite_options.cc @@ -276,10 +276,15 @@ const char* NgxRewriteOptions::ParseAndSetOptions( ScriptLine* script_line; script_line = NULL; - // Only allow script variable support for LoadFromFile for now. // Note that LoadFromFile should not be scriptable on wildcard hosts, // as browsers might be able to manipulate its natural use-case: $http_host. - if (!StringCaseStartsWith(directive, "LoadFromFile")) { + if (!StringCaseStartsWith(directive, "LoadFromFile") && + !StringCaseEqual(directive, "EnableFilters") && + !StringCaseEqual(directive, "DisableFilters") && + !StringCaseEqual(directive, "DownstreamCachePurgeLocationPrefix") && + !StringCaseEqual(directive, "DownstreamCachePurgeMethod") && + !StringCaseEqual(directive, + "DownstreamCacheRewrittenPercentageThreshold")) { compile_scripts = false; }