Welcome! Log In Create A New Profile

Advanced

Mail Proxy with Multiple Mail Domains

Anonymous User
November 13, 2019 02:02PM
Hello,
 
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).

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? ############

auth_http localhost/nginxauth.php;

server {
listen 25;
protocol smtp;
}

server {
listen 143;
protocol imap;
}
}

And a minimalistic nginxauth.php script like:

<?php

/*
Variables we have here:
$_SERVER["HTTP_AUTH_USER"]
$_SERVER["HTTP_AUTH_PASS"]
$_SERVER["HTTP_AUTH_USER"]
$_SERVER["HTTP_AUTH_PASS"]
$_SERVER["HTTP_AUTH_PROTOCOL"]
*/

if ($protocol=="imap")
{
$backend_port=143;
}

if ($protocol=="smtp")
{
$backend_port=25;
}

$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?

header("Auth-Status: OK");
header("Auth-Server: $backend_ip[$selection]");
header("Auth-Port: $backend_port");
?>


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

Thanks a lot in advance.

_______________________________________________
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: 166
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