We have a server that needs to connect to an IMAP server outside of our network.
Unfortunately, the server we need to connect to requires a connection on port 993. The problem is our host blocks port port 993 going in or out.
The option I am exploring, if it is even an option at all, is whether or not we can set up a relay that we can use to connect to the external IMAP server.
Say we set up an IMAP server listening on port 499 on another host we control, and then forward that traffic to the other IMAP server on port 993. Is that possible or an option? I have not much experience with relays, and may be completely off base.
What you can do is a tunnel (port forwarding) or SOCK proxy. This is something ssh can do. Then you might want to have something like autossh to monitor an ssh tunnel and restart it as needed. Using ssh key pairs will allow you authentication without having to enter password
You can try this
then you'll be able to see your.proxy.server:993 on your localhost:499 By default the port will not be exposed to external network interfaces unless you add the option
-g Allows remote hosts to connect to local forwarded ports.
You can also set up a SOCK proxy (if your client is able to use it)
Then set up your network connection to use it as a SOCK v4 on port 1234. To your host all outgoing connections will be seen as a ssh (probably port 22) to your.proxy.server.