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

Maxim Dounin mdounin at mdounin.ru
Thu Oct 28 19:18:28 MSD 2010


Hello!

On Thu, Oct 28, 2010 at 10:59:21AM -0400, moorthi wrote:

>  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 mailauth.pm handler function on nginx server 192.168.1.1:[/b]
> sub handler {
>    my $r = shift;
>    $r->header_out("Auth-Status", "OK");
>    $r->header_out("Auth-Server", '192.168.1.2');
>    $r->header_out("Auth-Port", '143');
>    $r->send_http_header("text/html");
>    warn 'H: ',$r->remote_addr;
>    return OK;
> }
> 
> [b]from 192.168.1.3[/b]
> telnet 192.168.1.1 143
> . login user1 pass1
> . OK [CAPABILITY IMAP4 IMAP4rev1 logged in
> 
> [b]on 192.168.1.1 tail -f /var/log/nginx/error_log[/b]
> H: [b]127.0.0.1[/b] at /usr/share/nginx/perl/lib/mailauth.pm line 59.
> 
> actually i have to get 192.168.1.3
> how to get this remote_addr can u plz help me.

Connection to auth_http server is obviously from nginx, not 
client.  Client's ip address as seen on nginx mail proxy is 
available in Client-IP header.

Maxim Dounin



More information about the nginx mailing list