[PATCH] http_geo_module: warn when using a variable as the value

Daniel K. dk at syse.no
Wed Dec 16 23:13:16 UTC 2015

Something like this would have saved me a lot of time, hopefully it will
be of help to others as well.

But hey, I got an excuse to dive into the nginx code.

Sorry about the non-'hg export'-ness of the patch.
I guess Thunderbird will mangle the whitespace, and if you insist I may
eventually install hg and do it properly, but here goes...

Daniel K.

Warn when using a variable as the data value in geo blocks

Since the geo module does not expand variables, warn when a variable is
used as the data value; as in the default entry of:

geo $geo {
	default		$foobar;	'';

--- nginx-1.9.9.orig/src/http/modules/ngx_http_geo_module.c
+++ nginx-1.9.9/src/http/modules/ngx_http_geo_module.c
@@ -621,6 +621,13 @@ ngx_http_geo(ngx_conf_t *cf, ngx_command
         goto done;

+    if (value[1].data[0] == '$') {
+        ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
+                           "suspect value \"%V\", "
+                           "the geo module does not expand variables",
+                           &value[1]);
+    }
     if (ctx->ranges) {
         rv = ngx_http_geo_range(cf, ctx, value);

More information about the nginx-devel mailing list