Ruby Forum NGINX > pop3 proxy

Posted by Istvan Szukacs (Guest)
on 03.09.2008 13:14
(Received via mailing list)
Hi folks!


I am preparing a pop3 proxy with nginx and wondering if somebody could
help...

I have N hosts behind one firewall and I would like to reach the
external pop3 server through this proxy.

pop3 {



    pop3_capabilities 
<http://wiki.codemongers.com/NginxMailCoreModule#pop3_capabilities> 
"TOP"  "USER";


    server <http://wiki.codemongers.com/NginxHttpCoreModule#server> {
        listen <http://wiki.codemongers.com/NginxHttpCoreModule#listen> 
110;
        protocol 
<http://wiki.codemongers.com/NginxMailCoreModule#protocol>   pop3;
        proxy <http://wiki.codemongers.com/NginxMailProxyModule#proxy> 
on;
    }

}


Where and how should i define the real pop3 server?


Regards,
Istvan
Posted by Maxim Dounin (Guest)
on 03.09.2008 13:31
(Received via mailing list)
Hello!

On Wed, Sep 03, 2008 at 12:06:08PM +0100, Istvan Szukacs wrote:

>    pop3_capabilities <http://wiki.codemongers.com/NginxMailCoreModule#pop3_capabilities>  "TOP"  "USER";
>
>Where and how should i define the real pop3 server?

Real pop3 server ip address must be returned by your auth_http
script in Auth-Server header.

See http://wiki.codemongers.com/NginxMailCoreModule#auth and
http://wiki.codemongers.com/NginxMailAuthModule for details.

Maxim Dounin
Posted by Istvan Szukacs (Guest)
on 03.09.2008 13:54
(Received via mailing list)
Thank you!

Is it possible to use a local file wo/ http server?

/blabla/auth.php


Or what is the lightweight solution?

Regards,
Istvan
Posted by Maxim Dounin (Guest)
on 03.09.2008 14:54
(Received via mailing list)
Hello!

On Wed, Sep 03, 2008 at 12:45:36PM +0100, Istvan Szukacs wrote:

>Thank you!
>
>Is it possible to use a local file wo/ http server?
>
>/blabla/auth.php

No, only http is supported.

>Or what is the lightweight solution?

You may use the same nginx instance to work with http for this.  This
also allows load-balancing and so on.

E.g. if you want to use php with fastcgi for this, try something
like:

mail {
    auth_http  http://localhost:8080/auth.php
    ...
}

http {
     server {
         listen 8080;
         fastcgi_pass ...;
         ...
     }
}

And then run appropriate php fastcgi application as you usually do
for normal php scripts under nginx.

Of course for really simple cases you may implement your auth
server in embedded perl or even with rewrite module.  :)  But this
isn't an option in real life since normally you need to do some
database lookups and therefore need some context where you may use
blocking calls.

Maxim Dounin
Posted by Istvan Szukacs (Guest)
on 03.09.2008 16:02
(Received via mailing list)
Hi!


Thank you.

This is the php code:


<?php
$username=$_SERVER["HTTP_AUTH_USER"];
$userpass=$_SERVER["HTTP_AUTH_PASS"];
$protocol=$_SERVER["HTTP_AUTH_PROTOCOL"];
$backend_port=110;
$server_ip="193.252.118.133";
pass($server_ip, $backend_port);

function pass($server,$port){
       header("Auth-Status: OK");
       header("Auth-Server: $server");
       header("Auth-Port: $port");
       exit;
}

?>

Regards,
Istvan