It appears that using dovecot to proxy to nginx imap proxy doesn't work.
From tcpdump and browsing the source it appears dovecot sends,
C CAPABILITY\r\nL LOGIN <user> <pass>\r\n
and nginx only responds to the CAPABILITY command. Is this a problem with dovecot sending the two commands without waiting for the first to complete or is it nginx's trouble with not handling it correctly?
A quick test with a perl script confirms:
#!/usr/bin/perl -w $|++;
use IO::Socket; use strict;
my ($host, $user, $pass) = @ARGV;
my $s = new IO::Socket::INET(Proto => 'tcp', PeerAddr => $host, PeerPort => 143); die "Could not create socket $!\n" unless $s;
while(<$s>) { print $_; last if /OK/; } print $s "C CAPABILITY\r\nL LOGIN $user $pass\r\n"; while(<$s>) { print $_; last if /OK/; } print $s "Q logout\r\n"; while(<$s>) { print $_; last if /OK/; }
close($s);
## Output:
- CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS UIDPLUS LIST-EXTENDED I18NLEVEL=1 QUOTA AUTH=PLAIN C OK completed
- BYE Q OK completed