Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

Mail Proxy with Multiple Mail Domains (2 replies)

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

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>