On my server I am running a mailcow:dockerized solution on a debian server and I want to use the nginx not only as an http reverse proxy but also as an SMTP imap and pop3 too as seen in https://www.nginx.com/resources/admin-guide/mail-proxy/
But the further I read in the link the difficult it becomes to figure out how this will be done. In http it is obvious how this will be done:
server {
listen 80;
server_name mail.example.tk;
location /.well-known {
proxy_pass http://127.0.0.1:8080/.well-known ;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
}
location / {
rewrite ^(.*) https://$server_name$1 permanent;
}
}
server {
listen 443 ssl;
server_name mail.example.tk;
ssl_certificate /opt/docker-mailcow/data/assets/ssl/cert.pem;
ssl_certificate_key /opt/docker-mailcow/data/assets/ssl/key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
}
}
But using smtp, pop3 and imap how will this be done? Please keep in ming that the docker images run on the same server with nginx and these are:
827c20cee898 mailcow/dovecot:1.0 "/docker-entrypoin..." 50 minutes ago Up 50 minutes 24/tcp, 10001/tcp, 0.0.0.0:2110->110/tcp, 0.
76a977a8064e mailcow/postfix:1.0 "/bin/sh -c 'exec ..." 50 minutes ago Up 50 minutes 588/tcp, 0.0.0.0:2525->25/tcp, 0.0.0.0:2465-
Any ideas?