how to get remote_addr in ngix for POP/IMAP with perl module

moorthi nginx-forum at
Thu Oct 28 18:59:21 MSD 2010

 i am running ngnix with perl module for IMAP/POP, but i am not getting
the source remote address from where user is authenticating.
[b]my conf:[/b]
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local]
$request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
    perl_modules  perl/lib;
    server {
       listen 8880;
       location /auth {
          perl  mailauth::handler;

mail {
   auth_http_timeout 6000;

   pop3_capabilities  "TOP"  "USER";
   imap_capabilities  "IMAP4rev1"  "UIDPLUS";

   server {
      listen     110;
      protocol   pop3;
      proxy      on;
      auth_http_header  X-Auth-Port 110;
   server {
      listen     143;
      protocol   imap;
      proxy      on;
      auth_http_header  X-Auth-Port 143;

[b]my handler function on nginx server[/b]
sub handler {
   my $r = shift;
   $r->header_out("Auth-Status", "OK");
   $r->header_out("Auth-Server", '');
   $r->header_out("Auth-Port", '143');
   warn 'H: ',$r->remote_addr;
   return OK;

telnet 143
. login user1 pass1
. OK [CAPABILITY IMAP4 IMAP4rev1 logged in

[b]on tail -f /var/log/nginx/error_log[/b]
H: [b][/b] at /usr/share/nginx/perl/lib/ line 59.

actually i have to get
how to get this remote_addr can u plz help me.

Posted at Nginx Forum:,123661,145342#msg-145342

More information about the nginx mailing list