Skip to content

Not possible to use Nginx version 1.31.6 as mailproxy #1827

Open

Description

@GentleRV

Bug Overview

Ubuntu Linux 24.04.5

Although Nginx version 1.31.6 is compiled with the options -with-mail and all the other things needed, the directive mail in the nginx.conf file is not allowed.
Also the /cgi-bin/nginxauth.cgi is missing in the system

Expected Behavior

Configure the mail proxy and get things working

Steps to Reproduce the Bug

Add the parameters as seen https://docs.nginx.com/nginx/admin-guide/mail-proxy/mail-proxy/
Then do the test NGINX -T

NGINX Configuration

Nginx version 1.31.6 on Ubuntu 24.04.5

NGINX version and build configuration options

nginx -V
nginx version: nginx/1.31.6
built by gcc 13.3.0 (Ubuntu 13.3.0-6ubuntu224.04.1)
built with OpenSSL 3.0.13 30 Jan 2024
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/run/nginx.pid --lock-path=/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-control-api --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_json_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/home/builder/debuild/nginx-1.31.6/debian/debuild-base/nginx-1.31.6=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/home/builder/debuild/nginx-1.31.6/debian/debuild-base/nginx-1.31.6=/usr/src/nginx-1.31.6-1
noble -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'

Environment where NGINX is being built and/or deployed

Ubuntu 24.04.5

Architecture where NGINX is being built and/or deployed

uname -a
Linux backup0 6.8.0-146-generic #146-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 3 16:12:30 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux

NGINX Debug Log

none

Additional Context

No response

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions

    👋 Thanks for opening this issue and contributing to the NGINX project!
    A maintainer will review it and follow up when possible. We appreciate your support.

  2. saikrishnakumarreddy commented on Oct 8, 2026

    @saikrishnakumarreddy
    Contributor

    The mail directive is available when compiled with --with-mail (which your build includes). The error you're seeing is likely a configuration mistake, please share the actual error from nginx -t and your mail {} block.

    The nginxauth.cgi script is not part of nginx. It's an example authentication backend that you need to implement yourself. See the mail proxy documentation.

  3. GentleRV commented on Oct 11, 2026

    @GentleRV
    Author

    Please, take my issue serrious.
    You really think I don;t know how to test a configuration be fore use it?
    Everything is as written and NO it does not work

  4. saikrishnakumarreddy commented on Oct 11, 2026

    @saikrishnakumarreddy
    Contributor

    We are not able to reproduce this, the mail directive works as expected when built with --with-mail. Please share the actual nginx -t output and your mail {} configuration so we can investigate further.

  5. GentleRV commented on Oct 12, 2026

    @GentleRV
    Author

    sudo nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    With the mail extras in /etc/nginx/nginx.conf:

    mail {
    server_name mail.dutondata.com;
    auth_http localhost:9000/cgi-bin/nginxauth.cgi;

    proxy_pass_error_message on;
    
    ssl                 on;
    ssl_certificate /etc/letsencrypt/live/videobabbel.nl-0001/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/videobabbel.nl-0001/privkey.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;
    
    server {
        listen     25;
        protocol   smtp;
        smtp_auth  login plain cram-md5;
    }
    
    server {
        listen   143;
        protocol imap;
    }
    

    }

    Then again sudo nginx -t

    sudo nginx -t
    nginx: [emerg] "mail" directive is not allowed here in /etc/nginx/nginx.conf:32
    nginx: configuration file /etc/nginx/nginx.conf test failed

    What I do wrong?

  6. saikrishnakumarreddy commented on Oct 12, 2026

    @saikrishnakumarreddy
    Contributor

    The error "mail" directive is not allowed here means your mail {} block would be placed inside the http {} block. The mail {} block must be at the top level of nginx.conf, as a sibling of http {}, not nested inside it.

    Please share your full nginx.conf if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions