Welcome! Log In Create A New Profile

Advanced

Re: NGINX and IMAP

All files from this thread

File Name File Size   Posted by Date  
mail_seq.png 40.5 KB open | download Joshua Zhu 09/05/2009 Read message
Maxim Dounin
September 07, 2009 10:14AM
Hello!

On Fri, Sep 04, 2009 at 07:03:42PM -0400, brainjuice wrote:

> Hello all,
> I am writing to ask that you consider if you have any knowledge to share regarding creating Filter or Upstream Handlers for NGINX or, more specifically, in extending the Mail Modules.
>
> My goal is to be able to build code capable of filtering IMAP commands that the user is sending to the upstream IMAP server (through an NGINX proxying the IMAP commands) as well as the responses the upstream server would send back to those specific commands; all other traffic would pass unaltered as it does in existing IMAP proxy module. This would, in effect, be the makings of what one might call an "IMAP Rewrite Module" but that seems quite ambitious at this point. I am at a point where, from day-to-day, I switch from thinking that "yeah, I can probably do this" to "ugh, why am I wasting my time".

Basically nginx doesn't have full-featured IMAP protocol parser
now, and after establishment of proxied connection there is no
safe way to intercept client commands or server responses.

Not event mentioning that there is no interface to do it.

> I am new to writing modules for NGINX and googling has brought me to George Malamidis' "Hello world nginx module" (http://nutrun.com/weblog/hello-world-nginx-module/), and Evan Miller's "Emiller's Guide To Nginx Module Development" (http://www.evanmiller.org/nginx-modules-guide.html); I have read them both as well as parts of Evan's "Advanced Topics In Nginx Module Development" (http://www.evanmiller.org/nginx-modules-guide-advanced.html); and I have also searched the Nginx Mailing List, all in an attempt to better understand the structure of module development and the overall architecture in NGINX.
>
> I am still learning my way through and trying to make sense of all the internals of NGINX. Though a bit thick, I do like what I have read thus far about how things are structured. Fortunately I don't have to just rely on documentation as there are those that have gone before me in developing other modules and serve as a reference. Some Modules that I have found promising / interesting:
>
> * ngx_http_rewrite_module - example of string replacement with regex patterns in the user request
> * ngx_mail_imap_module - capturing user requests sent to IMAP server (ex. login) instead of simply passing them upstream (as it does with all other requests)
> * ngx_http_ssi_filter_module - filtering response before returning to the end user
> * ngx_http_sub_filter_module - another example of filtering response before returning to the end user
>
> I have some questions that linger that I am hoping one of you on the list might know how to answer or might be familiar enough with the code to point me in the right direction. If you would, I have the following question:
>
> How are Mail / IMAP requests characterized in the NGINX model / event chain? Meaning, do they follow a similar pattern as Web / HTTP requests and responses with Header and Body content parts or is there a different model for these? I am guessing they follow a different model but some clarification, if you have any, would be helpful. So far, most, if not all, documentation I have found has a heavy focus (rightfully so) on handling or modifying Web / HTTP requests so I am finding that reading code has been my only hint in finding the context and callbacks needed but so far that has been VERY slow going. Any help you would have in differentiating the Mail / IMAP request-response model from the somewhat well documented Web / HTTP model would greatly appreciated.

Mail module infrastructure is quite different. It does use the
same low-level operations for connection handling, config parsing
etc. But there is no such http-specific things as request
processing phases, filter chains and so on.

And AFAIK there is no programming documentation available except
source code.

The good thing is that mail module is small and simple enough. ;)

Maxim Dounin
Subject Author Posted

NGINX and IMAP

brainjuice September 04, 2009 07:03PM

Re: NGINX and IMAP Attachments

Joshua Zhu September 05, 2009 02:02AM

Re: NGINX and IMAP

Maxim Dounin September 07, 2009 10:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 240
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready