Forum: NGINX strange map $request issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2974d09ac2541e892966b762aad84943?d=identicon&s=25 itpp2012 (Guest)
on 2014-06-20 15:06
(Received via mailing list)
For example:

map $request $testvar {
        default                                 0;
        ~*montytest                           1;
}

if ($testvar) { return 412; }

[20/Jun/2014:xx:xx:20 +0200] 69.64.xxxx:52393 - - "GET /montytest/
HTTP/1.1"
412 712 "-" "Mozilla/5.0........

[20/Jun/2014:xx:xx:29 +0200] 115.254.xxxx:59855 - - "HEAD /montytest/
HTTP/1.1" 400 0 "-" "-" "-" -

Why does a GET work but not a HEAD ??

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,251074,251074#msg-251074
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-06-20 15:22
(Received via mailing list)
Hello!

On Fri, Jun 20, 2014 at 09:05:44AM -0400, itpp2012 wrote:

> 412 712 "-" "Mozilla/5.0........
>
> [20/Jun/2014:xx:xx:29 +0200] 115.254.xxxx:59855 - - "HEAD /montytest/
> HTTP/1.1" 400 0 "-" "-" "-" -
>
> Why does a GET work but not a HEAD ??

It looks like the HEAD request was invalid, and hence 400 was
returned before any further processing.  The reason why 400 was
returned should be in error log at info level.

--
Maxim Dounin
http://nginx.org/
2974d09ac2541e892966b762aad84943?d=identicon&s=25 itpp2012 (Guest)
on 2014-06-20 15:35
(Received via mailing list)
The log entries are both in access.log, nothing in error.log, maybe a
try_files thing ? though the IF is after try_files and works for a GET.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,251074,251076#msg-251076
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-06-20 16:24
(Received via mailing list)
Hello!

On Fri, Jun 20, 2014 at 09:35:20AM -0400, itpp2012 wrote:

> The log entries are both in access.log, nothing in error.log, maybe a
> try_files thing ? though the IF is after try_files and works for a GET.

Note that you have to configure error_log to log "info" level
messages.  By default, logging level is "error".

http://nginx.org/r/error_log

--
Maxim Dounin
http://nginx.org/
2974d09ac2541e892966b762aad84943?d=identicon&s=25 itpp2012 (Guest)
on 2014-06-20 19:36
(Received via mailing list)
It was a malformed request so a 400 is correct, a valid HEAD in this
case
does return a 412.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,251074,251080#msg-251080
This topic is locked and can not be replied to.