Forum: NGINX nginx ignores access_log directive when post_action specifie

Posted by Chris Krybus (univ)
on 2010-05-31 02:26
Hi,

in the location below nginx writes a custom download log. Everything
works fine except when there is a post_action directive.

I seems that nginx skips the access_log directive but I don't understand
why. Any help is greatly appreciated.

Here is the config:

location /download_intern/ {
    internal;

    if ($uri ~* ^/download_intern/([0-9]+)/) {
        set $transferID $1;
        set $server $arg_ip;
        set $url $arg_url;
        proxy_pass http://$server:80/$url;
        break;
    }


    log_format download '$remote_addr [$time_local]
$upstream_cache_status   "$scheme://$host$request_uri" $status
[$transferID] $body_bytes_sent';

    access_log /opt/nginx/logs/server.download_log download;


    # without this line the download log file is being written
    post_action /done;
}


location /done {
    internal;
    # log the transfer on the main server
    proxy_pass http://xxx.xxx.xxx.xxx:80/download_end/?tid=$transferID;
}
Posted by rishabh (Guest)
on 2012-02-10 07:30
(Received via mailing list)
I am facing the same problem, is there any update on this issue ?

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,92464,222201#msg-222201
Posted by Maxim Dounin (Guest)
on 2012-02-10 08:32
(Received via mailing list)
Hello!

On Fri, Feb 10, 2012 at 01:29:26AM -0500, rishabh wrote:

> I am facing the same problem, is there any update on this issue ?

Logging happens in a location where request completes, and with
post_action it's the location where post_action processed.
So the problem looks like configuration one.

Maxim Dounin
Posted by rishabh (Guest)
on 2012-02-20 13:29
(Received via mailing list)
Hi,

I am trying to log into two files. one default and one custom via
post_action.

http {
access_log /var/log/nginx/access.log;

server {
  location @postactionlocation {
     set_by_lua_file $logdata /var/www/log.lua;
     access_log /var/log/nginx/access2.log '$logdata';
     return 444;
  }

  location / {
     #someproxypass here
  }

  post_action @postactionlocation;
}


In this case only access2.log(via post_action) is written and not the
default access.log(in http)

What would be an optimal solution.

Thanks

--
Rishabh


Maxim Dounin Wrote:
-------------------------------------------------------
> post_action it's the location where post_action
> processed.
> So the problem looks like configuration one.
>
> Maxim Dounin
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,92464,222714#msg-222714
Posted by Maxim Dounin (Guest)
on 2012-02-20 16:19
(Received via mailing list)
Hello!

On Mon, Feb 20, 2012 at 07:28:52AM -0500, rishabh wrote:

>      set_by_lua_file $logdata /var/www/log.lua;
>
>
> In this case only access2.log(via post_action) is written and not the
> default access.log(in http)
>
> What would be an optimal solution.

If you want request to be logged into two logs, you have to define
two access_log directives where requests are logged, i.e.

    location / {
        access_log /var/log/nginx/access.log;
        access_log /var/log/nginx/access2.log;
        ...
    }

Maxim Dounin
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.