I'd like to use a map in order to prevent various spiders from indexing documents, but I'm running into strange issues, which I can't explain (nginx 0.7.62 or 0.7.64):
[code]
root /tmp/test;
map $lookup $test_blacklist {
default "";
/aabbccddeeff/aabbccddeeff/2009/A/Pdf/20090101.pdf 1;
}
location ~* ^/aabbccddeeff(/.*) {
set $lookup "";
if ($http_user_agent ~ "Googlebot|Slurp|msnbot") {
# force lowercase "aabbccddeeff"
set $lookup /aabbccddeeff$1;
}
if ($test_blacklist != "") {
return 410;
}
charset iso-8859-1;
alias /tmp/test/aabbccddeeff$1;
}
[/code]
When requesting a file from that map, the open() log points to a garbled path "/aabbccddeeffcddeeff" rather than the requested "/aabbccddeeff/aabbccddeeff":
[quote]
[notice] 31998#0: *1 "Googlebot|Slurp|msnbot" matches "Googlebot", client: 127.0.0.1, server: test, request: "HEAD /aabbccddeeff/aabbccddeeff/2009/A/Pdf/20090101.pdf HTTP/1.1", host: "test"
[error] 31998#0: *1 open() "/tmp/test/aabbccddeeffcddeeff/2009/A/Pdf/20090101.pdf" failed (2: No such file or directory), client: 127.0.0.1, server: test, request: "HEAD /aabbccddeeff/aabbccddeeff/2009/A/Pdf/20090101.pdf HTTP/1.1", host: "test"
[/quote]
What's more, if the user-agent isn't matched, the server sends a 301 redirect with an appended "/" rather than delivering the file:
[quote]
HTTP/1.1 301 Moved Permanently
Location: http://test/aabbccddeeff/aabbccddeeff/2009/A/Pdf/20090101.pdf/
[/quote]
On the other hand, if I omit the $http_user_agent test, the server behaves as expected, by either delivering the file or returning a 410 status, dependning of the content of $lookup.
Am I doing something wrong?