Welcome! Log In Create A New Profile

Advanced

if-clause garbles variable content

December 19, 2009 03:33PM
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?
Subject Author Posted

if-clause garbles variable content

marius December 19, 2009 03:33PM

Re: if-clause garbles variable content

Maxim Dounin December 19, 2009 05:02PM

Re: if-clause garbles variable content

marius December 20, 2009 01:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 57
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready