prevent Nginx from handling If-Match header

1,564 views
Skip to first unread message

JB

unread,
May 19, 2016, 9:22:21 AM5/19/16
to openresty-en
Hi,
  In my Nginx OpenResty environment, if I post to a URL that it handles and I set the request header If-Match, then it returns with: 412 Precondition Failed.  I'm assuming this is normally the expected behavior.  However, I want Nginx to ignore all headers and just pass them through.  Any ideas how to do that?

Thanks

Lord Nynex

unread,
May 19, 2016, 9:24:04 PM5/19/16
to openre...@googlegroups.com
Hello,

I'm going to assume by 'pass them through' you mean to say that you're using proxy_pass with an upstream? If so, I would be surprised to find that nginx cares about your if-match header at all. I strongly suspect this response code is coming from your upstream application. 

Can you provide a minimal configuration that allows me to reproduce this issue?

-Brandon

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JB

unread,
May 20, 2016, 7:03:13 AM5/20/16
to openresty-en
Hi Brandon,
  Thanks for such a quick response!  Maybe my terminology wasn't accurate.  I'm actually using Lua code.  Here is a very simple conf example:

-----
events {
    worker_connections 19000;
    multi_accept on;
}

http {
server {
        listen 80;
        location / {
            content_by_lua '
ngx.say(ngx.req.get_headers()["If-Match"])              
            ';
        }
    }
}
-----

I'm using the Chrome app, Postman, as the client.  When I don't supply a header, it outputs "Nil" as expected.  If I supply an "If-Match" header with any value, I get the following response:
-----
<html>
    <head>
        <title>412 Precondition Failed</title>
    </head>
    <body bgcolor="white">
        <center>
            <h1>412 Precondition Failed</h1>
        </center>
        <hr>
        <center>openresty/1.9.7.4</center>
    </body>
</html>
-----

Thanks!

Yichun Zhang (agentzh)

unread,
May 27, 2016, 6:12:40 PM5/27/16
to openresty-en
Hello!
Well, if you don't need that, just remove the offending request header
yourself forcibly, as in

rewrite_by_lua_block {
ngx.req.clear_header("if-match")
}

This feature is implemented in a builtin nginx output filter module
called ngx_http_not_modified_filter_module IIRC.

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages