Welcome! Log In Create A New Profile


Nginx proxy - Hide backend mailserver IP

Posted by joaomourato 
Nginx proxy - Hide backend mailserver IP
July 28, 2016 10:58AM

I'm trying to create a proxy with Nginx (1.11.2) in a dedicated VPS to a remote client mail server with a DDNS ip (hmailserver). I have two network interfaces in this VPS and i want to use one just for the mail proxy. Authentication, SMTP, POP3 and IMAP are all working fine.

The first problem is that mail sent from this server is showing it's own IP (point 1 in attached picture). Of course SPF fails (point 2) and mail will end up in spam. The received line appears to be added by gmail.

The second problem is that Nginx is sending mail through the VPS main IP and not the one specified in the listen directive.

The third problem is i cannot pass client ip address to the mail server. I've tried xclient but hmailserver doesn't seem to support it and i get a 451 4.3.2 internal server error when authenticating smtp. Is there another way?

I cannot change the client's mail solution, so i need to overcome this problems. Can this be done in Nginx or i should move on to another solution?


my mail conf

mail {

server {
server_name remote_server;
listen x.x.x.x:25;
protocol smtp;
smtp_auth none;

proxy on;

xclient off; # hmailserver doesn't seem to support it

auth_http auth.x.com:80/smtp.php;

server {
server_name remote_server;

listen x.x.x.x:110;
protocol pop3;
pop3_auth plain apop cram-md5;

pop3_capabilities "TOP" "USER";

auth_http auth.x.com:80/pop3.php;

server {

server_name remote_server;
listen x.x.x.x:143;
protocol imap;

imap_capabilities "IMAP4rev1" "UIDPLUS";

auth_http auth.x.com:80/imap.php;

open | download - nginx-proxy.png (88.9 KB)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 78
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready