﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
916	Incorrect map value passed.	plutocrat@…		"Hi,
I'm running a Wordpress Multisite instance, and have used the suggested mapping scheme in it. Mine looks like this.

{{{
map $http_host $blogid {
        default 2;
        domain1.com 1;
        temp2.domain1.com 2;
        domain2.com 2;
        temp3.domain1.com 3;
        domain3.com 3;
	.... etc ....
        temp11.domain1.com 11;
        domain11.com 11;
        .... etc ....
        temp17.domain1.com 17;
        domain17.com 17;
}
}}}

Later on in the config, I use it like this:

{{{
location ~ ^/wp-content/uploads/(.*)$ {
        try_files /wp-content/uploads/sites/$blogid/$1 /wp-content/uploads/$1  /wp-includes/ms-files.php?file=$1 ;
        access_log off; log_not_found off; expires max;
}
}}}
This was previously working OK: If the file
domain3.com/wp-content/uploads/2014/12/test.pdf
was requested, then the file from 
domain3.com/wp-content/uploads/sites/3/2014/12/test.pdf
would be served

I was experiencing problems with this on one site, domain11.com. I turned on debugging in the logs and found that it actually seemed to be mapping domain11.com to $blogid=1 instead of blogid=11. 

2016/03/02 03:34:07 [debug] 16139#16139: *566496 http map started
2016/03/02 03:34:07 [debug] 16139#16139: *566496 http script var: ""domain11.com""
2016/03/02 03:34:07 [debug] 16139#16139: *566496 http map: ""domain11.com"" ""1""
2016/03/02 03:34:07 [debug] 16139#16139: *566496 http script copy: ""/wp-content/uploads/sites/""
2016/03/02 03:34:07 [debug] 16139#16139: *566496 http script var: ""1""
2016/03/02 03:34:07 [debug] 16139#16139: *566496 http script copy: ""/""
2016/03/02 03:34:07 [debug] 16139#16139: *566496 http script capture: ""2014/12/test.pdf""
2016/03/02 03:34:07 [debug] 16139#16139: *566496 trying to use file: ""/wp-content/uploads/sites/1/2014/12/test.pdf"" ""/home/user/domains/domain1.com/public_html/wp-content/uploads/sites/1/2014/12/test.pdf""

So is this a bug, or have I just misunderstood the map format? Is there a workaround?
I tried uncommenting the other $blogid=11 (ie. temp11.domain1.com). That didn't fix it. 
I tried putting """" around the value 11 in the map. That didn't fix it. 

"	defect	closed	minor		nginx-core	1.9.x	worksforme			Linux sxxxxxxxxw 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u2 x86_64 GNU/Linux	"nginx version: nginx/1.8.1
built with OpenSSL 1.0.1e 11 Feb 2013
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_gunzip_module --with-file-aio --with-threads --with-http_spdy_module --with-http_geoip_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_smtp_module --without-mail_imap_module --without-http_uwsgi_module --without-http_scgi_module --add-module=/usr/src/builddir/debian/modules/naxsi/naxsi_src --add-module=/usr/src/builddir/debian/modules/nginx-cache-purge --add-module=/usr/src/builddir/debian/modules/nginx-upstream-fair --add-module=/usr/src/builddir/debian/modules/nginx-echo --add-module=/usr/src/builddir/debian/modules/nginx-x-rid-header --with-ld-opt=-lossp-uuid
"
