# Reverse proxy imap

**URL:** <https://www.ruby-forum.com/t/reverse-proxy-imap/202939>\
**Category:** NGINX\
**Created:** [February 9, 2011, 9:09am UTC](https://www.ruby-forum.com/t/reverse-proxy-imap/202939 "2011-02-09T09:09:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 9, 2011, 9:09am UTC](https://www.ruby-forum.com/t/reverse-proxy-imap/202939/1 "2011-02-09T09:09:25Z")

</div>

Someone has set up a reverse proxy imap, you connect to a Lotus Domino  
server on port 993? It is the typical question, but could send the  
configuration files? It would help me a lot to understand how to  
configure  
it. Thanks.

I installed nginx from the Fedora repository, version is 0.8.53.

My nginx.conf:

user nginx;  
worker\_processes 1;  
error\_log /var/log/nginx/error.log info;  
pid /var/run/nginx.pid;

events {  
worker\_connections 1024;  
multi\_accept on;  
}

mail {  
auth\_http localhost:80;  
auth\_http\_timeout 6000;  
imap\_auth plain;  
imap\_capabilities “IMAP4rev1” “UIDPLUS”;

```
server {
    listen 993;
    protocol imap;
    proxy on;
}

```

}

http {  
include mime.types;  
default\_type application/octet-stream;  
perl\_modules lib/perl5;  
perl\_require mailauth.pm;

```
    sendfile on;

    keepalive_timeout 65;

    server {
            listen 80;
            server_name localhost;
            location /auth {
             perl mailauth::handler;
            }
    location / {
            root html;
            index index.html index.htm;
            }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root html;
            }
    }

```

}

The mailauth.pm (is in /usr/lib/perl5/ )

package mailauth;  
use nginx;

our $auth\_ok;  
our $mail\_server\_ip={“172.18.1.9”};  
our $protocol\_ports={};  
$domino=“172.18.1.9”;  
$protocol\_ports-\>{‘imap’}=993;

sub handler {  
my $r=shift;  
$auth\_ok=1;  
if ($auth\_ok==1){  
$r-\>header\_out(“Auth-Status”, “OK”);  
$r-\>header\_out(“Auth-Server”, $domino);  
$r-\>header\_out(“Auth-Port”,  
$protocol\_ports-\>{$r-\>header\_in(“Auth-Protocol”)});  
$r-\>header\_out(“Auth Plain”,$r-\>header\_in(“Auth Plain”));  
} else {  
$r-\>header\_out(“Auth-Status”, “Invalid login or password”) ;  
}

$r-\>send\_http\_header(“text/html”);

return OK;  
}

1;

Thanks!

* * *

Jose Antonio Vico Palomino  
E-Mail: removed\_email\_address@domain.invalid

Visita mi Blogs:  
[Thomas Riemer, Author at TechMaze](http://www.vicosoft.org/blog/)  
[http://www.mobileme.es](http://www.mobileme.es)  
[http://www.manchegox.org](http://www.manchegox.org)  
[http://www.todosconsoftwarelibre.es](http://www.todosconsoftwarelibre.es)  
[http://www.caminodesantiago.vicosoft.org](http://www.caminodesantiago.vicosoft.org)

Facebook: [Redirecting...](http://www.facebook.com/Quijote)  
Twitter: [http://twitter.com/vicosoft](http://twitter.com/vicosoft)

Skype: vicosoft  
Google Talk: removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 9, 2011, 11:52am UTC](https://www.ruby-forum.com/t/reverse-proxy-imap/202939/2 "2011-02-09T11:52:02Z")

</div>

Imap works reverse proxy on port 143 successfully. With this setting.

File → mailauth.pm:

package mailauth;  
use nginx;

sub handler {  
my $r = shift;  
$r-\>header\_out(“Auth-Status”, “OK”);  
$r-\>header\_out(“Auth-Server”, ‘172.18.1.9’);  
$r-\>header\_out(“Auth-Port”, ‘143’);  
$r-\>send\_http\_header(“Auth Plain”, “text/html”);

# warn 'H: ',$r-\>remote\_addr;

```
return OK;

```

}  
1;

But I’m not clear how to do work against the SSL port 993. I generate  
certificates in the proxy server or Lotus Domino server? I have no idea.  
Help.

* * *

Jose Antonio Vico Palomino  
E-Mail: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Visita mi Blogs:  
[http://www.vicosoft.org/blog/](http://www.vicosoft.org/blog/)  
[http://www.mobileme.es](http://www.mobileme.es)  
[http://www.manchegox.org](http://www.manchegox.org)  
[http://www.todosconsoftwarelibre.es](http://www.todosconsoftwarelibre.es)  
[http://www.caminodesantiago.vicosoft.org](http://www.caminodesantiago.vicosoft.org)

Facebook: [http://www.facebook.com/Quijote](http://www.facebook.com/Quijote)  
Twitter: [http://twitter.com/vicosoft](http://twitter.com/vicosoft)

Skype: vicosoft  
Google Talk: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

2011/2/9 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 10, 2011, 7:49am UTC](https://www.ruby-forum.com/t/reverse-proxy-imap/202939/3 "2011-02-10T07:49:08Z")

</div>

Thanks.

## Now I understand. And is there any way the proxy server is who would pass the request to port 993 Lotus Domino server and this is who sent the SSL certificate?

Jose Antonio Vico Palomino  
E-Mail: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Visita mi Blogs:  
[http://www.vicosoft.org/blog/](http://www.vicosoft.org/blog/)  
[http://www.mobileme.es](http://www.mobileme.es)  
[http://www.manchegox.org](http://www.manchegox.org)  
[http://www.todosconsoftwarelibre.es](http://www.todosconsoftwarelibre.es)  
[http://www.caminodesantiago.vicosoft.org](http://www.caminodesantiago.vicosoft.org)

Facebook: [http://www.facebook.com/Quijote](http://www.facebook.com/Quijote)  
Twitter: [http://twitter.com/vicosoft](http://twitter.com/vicosoft)

Skype: vicosoft  
Google Talk: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

2011/2/9 Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 9, 2011, 12:10pm UTC](https://www.ruby-forum.com/t/reverse-proxy-imap/202939/4 "2011-02-09T12:10:52Z")

</div>

On Wed, Feb 09, 2011 at 11:50:50AM +0100, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> $r->header_out("Auth-Server", '172.18.1.9');
> $r->header_out("Auth-Port", '143');
> $r->send_http_header("Auth Plain", "text/html");
> 
> ```
> 
> # warn 'H: ',$r-\>remote\_addr;
> 
> ```
> return OK;
> 
> ```
> 
> }  
> 1;
> 
> But I’m not clear how to do work against the SSL port 993. I generate  
> certificates in the proxy server or Lotus Domino server? I have no idea.

nginx can not proxy IMAP using SSL.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 10, 2011, 8:05am UTC](https://www.ruby-forum.com/t/reverse-proxy-imap/202939/5 "2011-02-10T08:05:27Z")

</div>

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) at 2011-2-10 14:47 wrote:

> Thanks.
> 
> Now I understand. And is there any way the proxy server is who would  
> pass the request to port 993 Lotus Domino server and this is who sent  
> the SSL certificate?  
> How about my tcp proxy module  
> ([GitHub - yaoweibin/nginx\_tcp\_proxy\_module: add the feature of tcp proxy with nginx, with health check and status monitor · GitHub](https://github.com/yaoweibin/nginx_tcp_proxy_module))?
> 
> 2011/2/9 Igor S. \<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
> \>  
> \>  
> Igor S.
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.
