Francis Daly
November 14, 2019 02:14PM
On Wed, Nov 13, 2019 at 08:00:58PM +0100, nsclick@gmx.de wrote:

Hi there,

Untested, but...

> I would like to setup a Nginx mail proxy which handles IMAP and SMTP for two different mail domains and two different backend servers (one server for each of the domains).
>

The easiest way is probably to have nginx listening on two IP addresses;
each one handling one domain.

> Let's say we have the two mail domains:
> - mail.foo.com
> - mail.bar.com
>  
> Then we can setup a minimalistic mail block like:
>  
> mail {
> server_name mail.foo.com; <-- ############ Can I simply add 'mail.bar.com' here? ############

No.

http://nginx.org/en/docs/mail/ngx_mail_core_module.html#server_name

says when this is used. If it is important in your case to have two
different names, then you will want to set it in each server{}.

> $backend_ip["mailhost_foo"] ="192.168.1.10";
> $backend_ip["mailhost_bar"] ="192.168.1.20";
>
> $selection <-- ############ How to make this selection? ############
> Do we have information about the requested mail domain here?
> If yes, in which $_SERVER item?

If you use something like

server {
server_name foo;
listen ip1:25;
}

server {
server_name bar;
listen ip2:25;
}

then you can also include an auth_http_header to say "this is foo", or
"this is bar".

Or you can use a different auth_http url for foo and for bar, so that
each one "knows" the backend ip for itself.

> But how to solve the questions marked with "###" above?
> I tried to find something in the Nginx documentation, but without success.
> Any ideas?

http://nginx.org/en/docs/mail/ngx_mail_core_module.html#listen says

"""
Different servers must listen on different address:port pairs.
"""

Alternatively,
http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html#protocol
shows that you will probably have an Auth-User for IMAP, and an
Auth-SMTP-To for SMTP. If those values make it clear which mail domain is
used in this request, then your auth_http script can use the appropriate
logic.

Cheers,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Mail Proxy with Multiple Mail Domains

Anonymous User November 13, 2019 02:02PM

Re: Mail Proxy with Multiple Mail Domains

Patrick November 13, 2019 07:38PM

Re: Mail Proxy with Multiple Mail Domains

Phillip Odam November 13, 2019 08:12PM

Re: Mail Proxy with Multiple Mail Domains

Francis Daly November 14, 2019 02:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 211
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