Hello fellow self-hosters. Is it possible to use NGINX as a proxy for an IMAP service where the IMAP server is located on a different host? I have a cloud VPS running NGINX which is connected to my home network via a WireGuard tunnel. What I would like to do is run the IMAP server (Dovecot) in my own network and have NGINX proxy the connection. I have tried doing searches based on this but the examples don’t show how to specify the IMAP server for the connection to be redirected to for the lack of a better phrase. I know streaming is possible. Would this be the way to do?

I would love an example to go on. Thanks very much!

What you’re looking for is a reverse proxy, or in this case, a TCP reverse proxy. I believe only NGINX plus (paid?) supports that. You’re probably better off using haproxy.

I haven’t done it so I can’t help in that front, but I found this: https://www.linuxbabe.com/mail-server/smtp-imap-proxy-with-haproxy-debian-ubuntu-centos

Which is close to your scenario (I just looked at the first result). Otherwise the search term “haproxy imap” or “haproxy mail server” may help you find something, maybe throwing in wireguard or VPN.

HousePanther
creator
link
fedilink
English
51Y

Thank you! It never occurred to me to consider haproxy to do something like this and I think it is exactly what I am looking for. It’s definitely worth further exploration. My subscription for email service is about to run out and I’d rather not pay for something I don’t have to.

Derin
link
fedilink
English
51Y

Just so you know, running an email service isn’t as easy as you think. You’ll most likely deal with a lot of blocks from Gmail and the rest.

HousePanther
creator
link
fedilink
English
21Y

I realize this could be a possibility. I don’t think it is going to be easy but I’ll give it a shot.

Derin
link
fedilink
English
31Y

Good luck!

Hominine
link
fedilink
English
11Y
@kill_dash_nine@lemm.ee
link
fedilink
English
31Y

You can do TCP proxying with nginx but many of the same features available in haproxy are behind the paywall. In nginx, layer 4 connections are dealt with through streams. You can do both TCP and UDP. I stick with haproxy for TCP streams with very few exceptions. HAproxy is most definitely more robust for situations where you have a pool of upstream servers. For single upstream instances, it’s not terrible. Most of the features I would use for better control of how the failover and balancing would work isn’t available in the open source nginx.

Create a post

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.

Rules:

  1. Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

  • 1 user online
  • 129 users / day
  • 423 users / week
  • 1.16K users / month
  • 3.85K users / 6 months
  • 1 subscriber
  • 3.68K Posts
  • 74.2K Comments
  • Modlog