0

I'm trying to make an imap server from scratch in node.js (primarily to learn about node.js and imap protocol).

How do I direct traffic from the imap subdomain (imap.mydomain.com) to port 143 on the server (where my server code is listening). I've updated iptables with this rule:

-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT

But it still doesn't work.

My DNS is like this:

A record - mydomain.com => 1.1.1.1 (my example ip address)

CNAME record - mail.mydomain.com => mydomain.com

mydomain.com redirects and is handled by apache. Could apache be overruling it? Maybe I need to add a host in /etc/hosts for the sub-domain?

Also, when doing telnet:

telnet 1.1.1.1 143

I get a "no route to host" error. So that tells me the route direct via the ip from the sub-domain doesn't work either...

I've checked out dovecot and postfix and it seems like they handle the port listening internally, so I couldn't see any clues from their install / config instructions.

It would be great if anyone could offer instructions on how to make sure the imap.mydomain.com subdomain properly forwards to the imap server.

Thanks!!!

1 Answers1

2

There is no redirection or forwarding. IMAP is simply a different protocol than HTTP (i.e. "web") and to use IMAP the server has to listen on port 143 and the client has to connect to this port. Just look at the settings of your mail client.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • This command works: telnet localhost 143. However, this command does not: telnet mydomain.com 143. This tells me the port is open, but when the domain is intermingled, things get screwed up. Also, when going from another server (using the telnet client), doing the ip address or domain doesn't work. – Phyllis Sutherland Nov 29 '15 at 20:33
  • 1
    @PhyllisSutherland: maybe you only listen on 127.0.0.1 ? Maybe this is relevant in your case: http://stackoverflow.com/questions/14043926/node-js-connect-only-works-on-localhost – Steffen Ullrich Nov 29 '15 at 20:34
  • Yeah, you were right here--thanks! The server was listening to 127.0.0.1 (port 143) and should have been listening to 0.0.0.0 (port 143). – Phyllis Sutherland Nov 29 '15 at 23:46