Sending Traffic to another Server/Port/IP asynchronously

1 view
Skip to first unread message

rishabh

unread,
Feb 9, 2012, 11:25:37 PM2/9/12
to ng...@nginx.org
I have nginx as the HTTP server.

I wanted to write a module which asynchronously send all the traffic to
another IP or PORT where my analytics server will be running. I dont
want to create any lag in serving HTTP requests.

Is there any existing module which I can use as a base and modify to
meet my requirements.

Any help would be greatly appreciated.

Thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222196,222196#msg-222196

_______________________________________________
nginx mailing list
ng...@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Alexandr Gomoliako

unread,
Feb 9, 2012, 11:51:01 PM2/9/12
to ng...@nginx.org
On Fri, Feb 10, 2012 at 6:25 AM, rishabh <nginx...@nginx.us> wrote:
> I have nginx as the HTTP server.
>
> I wanted to write a module which asynchronously send all the traffic to
> another IP or PORT where my analytics server will be running. I dont
> want to create any lag in serving HTTP requests.
>
> Is there any existing module which I can use as a base and modify to
> meet my requirements.
>
> Any help would be greatly appreciated.
>
> Thanks

Try post_action

rishabh

unread,
Feb 10, 2012, 1:20:15 AM2/10/12
to ng...@nginx.org
Thanks, post_action works like a charm.

Just one problem. Nothing is getting logged access_log if i use
post_action ! whats the co-relation ?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222196,222200#msg-222200

rishabh

unread,
Mar 19, 2012, 6:08:15 AM3/19/12
to ng...@nginx.org
That logging issue was a mistake. All the access_log directive need to
be in a single location/server block.

After a lot of testing. I found an issue.

The processing time of post_action is added to the response time. hence
delaying the response.

Here is how i have used post_action to log.

http {

server {

location / {
proxy_pass http://upstream123;
post_action @loglua;
}

location @loglua {
set $log '';
rewrite_by_lua_file /nginx/mylua.lua;
logformat format1 '$log';
access_log /var/log/nginx/newlog.log format1;
}
}
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222196,224021#msg-224021

rishabh

unread,
Mar 19, 2012, 6:08:46 AM3/19/12
to ng...@nginx.org
rishabh Wrote:
-------------------------------------------------------

> Thanks, post_action works like a charm.
>
> Just one problem. Nothing is getting logged
> access_log if i use post_action ! whats the
> co-relation ?

That logging issue was a mistake. All the access_log directive need to


be in a single location/server block.


After a lot of testing. I found another issue.

The processing time of post_action is added to the response time. hence
delaying the response.

Here is how i have used post_action to log.

http {

server {

location / {
proxy_pass http://upstream123;
post_action @loglua;
}

location @loglua {
set $log '';
rewrite_by_lua_file /nginx/mylua.lua;
logformat format1 '$log';
access_log /var/log/nginx/newlog.log format1;
}
}
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222196,224022#msg-224022

Valentin V. Bartenev

unread,
Mar 19, 2012, 6:36:14 AM3/19/12
to ng...@nginx.org
On Monday 19 March 2012 14:08:46 rishabh wrote:
[...]

> After a lot of testing. I found another issue.
>
> The processing time of post_action is added to the response time. hence
> delaying the response.


It doesn't delay response, but block the connection, and that's why we don't
recommend to use it. The best way to gather statistics is parsing access log
files.

wbr, Valentin V. Bartenev

Reply all
Reply to author
Forward
0 new messages