NGINX and IMAP
nginx-forum at nginx.us
Sat Sep 5 03:03:42 MSD 2009
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".
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.
Thanks in advance for your assistance.
-John Mark Mitchell
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5651,5651#msg-5651
More information about the nginx