Trying to get the basic email of mail reverse proxy working on nginx. I'm using the official nginx docker image and I have the following nginx config setup.
error_log /var/log/nginx/error.log info;
mail {
server_name mail.example.com;
auth_http localhost:9000/cgi-bin/nginxauth.cgi;
imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA;
pop3_auth plain apop cram-md5;
pop3_capabilities LAST TOP USER PIPELINING UIDL;
smtp_auth login plain cram-md5;
smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN;
xclient off;
server {
listen 25;
protocol smtp;
}
server {
listen 110;
protocol pop3;
proxy_pass_error_message on;
}
server {
listen 143;
protocol imap;
}
server {
listen 587;
protocol smtp;
}
}
After staring nginx with the following command
nginx -g 'daemon off;'
I get this error:
2017/11/14 22:54:00 [emerg] 1#1: "mail" directive is not allowed here in /etc/nginx/conf.d/default.conf:9
Any suggestion how to resolve this issue?
mail
is a top-level block. Check your /etc/nginx/nginx.conf
file, but I suspect that files in the conf.d
directory are included into the http
block. Adding the below line to the first line of nginx conf
helps me to get rid of this error
load_module /usr/ports/www/nginx-full/work/stage/usr/local/libexec/nginx/ngx_mail_module.so;
you may want to change the path to suit