I am doing some testing with the NodeJS smtp-server module. It exposes a listening SMTP server on any specified port. SMTP usually runs on port 25, but in order to run the Node app as a non-root user, I am prevented from binding to ports below 1000.

Since I am already using nginx on this machine, I thought the simplest way to get around this would be to bind the server internally to a higher port, for example, 2500. Then use nginx to proxy the SMTP port (25) and directly pass through traffic to the internal listening port.

How can I configure nginx to proxy/passthrough incoming SMTP connections on port 25 to the port on which smtp-server is listening? In this case, incoming TCP connections on port 25 should be directly forwarded to localhost:2500.

Note that the smtp-server app already handles SMTP authentication, TLS, etc, so nginx should not attempt to do those operations. It should just pass the traffic directly through.

  • 1
    Just answered this here for a related, but not duplicate, question.
    – tanius
    Jan 20 at 17:05

1 Answer 1


I figured it out:

Edit the /etc/nginx/nginx.conf file and add the following:

                listen 25;
  • not worked for me
    – erhan355
    Mar 9 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .