I try to write a nginx http module which decides to enable or forbid a
HTTP request sent in the request parameters (r->args). At the end of
decision I would like to clear the whole args or just a part of it, so
won’t appear in access.log of the origin server.
Is this solution correct without freeing args before?
I run some tests but it seems that after setting r->args.len=0 and
r->args.data=NULL and returning NGX_OK the request arrives at the origin
server untouched.
Logs on the original server:
172.27.134.40 - - [22/Sep/2009:14:17:42 +0200] “GET
/index.html?test=4ab8c062 HTTP/1.0” 404 169 “-” “-”
On Tue, Sep 22, 2009 at 08:25:49AM -0400, leki75 wrote:
Hello Igor,
I run some tests but it seems that after setting r->args.len=0 and r->args.data=NULL and returning NGX_OK the request arrives at the origin server untouched.
Logs on the original server:
172.27.134.40 - - [22/Sep/2009:14:17:42 +0200] “GET /index.html?test=4ab8c062 HTTP/1.0” 404 169 “-” “-”
I suppose you mean “proxy_pass http://test;” here.
As it’s proxy_pass without uri component - it uses original uri
with arguments (r->unparsed_uri, available as $request_uri
variable) if it’s valid instead of reconstructing it from r->uri
and r->args. That’s why still see original arguments on backend
with your code.
I think you misunderstand me. Not the log output is the problem if I
want to use eg. proxy_cache than I need to remove the query parameters
before caching the content.
The request flow should be (so the origin server wont get any query
parameters):
GET /uri?params HTTP/1.x → nginx → GET /uri HTTP/1.x → origin server
More on this, is it possible to modify the request flow programmatically
without internal_redirect? Like:
GET /uri?param1=value1¶m2=value2 HTTP/1.x → nginx → GET
/uri?my_param=value3 HTTP/1.x → origin server
But a better solution would be like this, which does not work at the
moment:
location / {
leki_test on;
proxy_pass http://test;
proxy_cache test;
proxy_cache_min_uses 1;
proxy_cache_valid 1d;
proxy_cache_methods GET HEAD;
proxy_cache_use_stale error timeout;
}