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!

  • @Zikeji@programming.dev
    link
    fedilink
    English
    151 year ago

    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.

    • HousePantherOP
      link
      fedilink
      English
      51 year ago

      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.

    • @kill_dash_nine@lemm.ee
      link
      fedilink
      English
      31 year ago

      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.

  • @Decronym@lemmy.decronym.xyzB
    link
    fedilink
    English
    5
    edit-2
    1 year ago

    Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

    Fewer Letters More Letters
    DNS Domain Name Service/System
    HTTP Hypertext Transfer Protocol, the Web
    IP Internet Protocol
    NAT Network Address Translation
    SMTP Simple Mail Transfer Protocol
    VPN Virtual Private Network
    VPS Virtual Private Server (opposed to shared hosting)
    nginx Popular HTTP server

    7 acronyms in this thread; the most compressed thread commented on today has 10 acronyms.

    [Thread #10 for this sub, first seen 19th Jul 2023, 15:00] [FAQ] [Full list] [Contact] [Source code]

  • Ratz
    link
    fedilink
    English
    21 year ago

    I see you, fellow data sovereignty aficionado.

    My first thought would be to try and set up iptables/nftables forwarding for this.

    Personally I opted to just use my VPS as a MITM mail relay and just forward inbound mail for my domains to my own on-prem dovecot instance.

    …your way is probably easier

    • HousePantherOP
      link
      fedilink
      English
      21 year ago

      I actually considered doing port forwarding and NAT for this but I would run into a problem with NAT reflection. I’d have to implement split-brain DNS to avoid this. It’s more efficient to simple proxy the connection. If I am unsuccessful, however, I will resort to port forwarding.

    • HousePantherOP
      link
      fedilink
      English
      21 year ago

      I will use my VPS as an SMTP smart host because I have a residential dynamic DNS connection and many mail providers block those IPs by default. I have to see if my Oracle always free tier will let me use port 25. I have a feeling I may bit shit out of luck on that front.

      • Ratz
        link
        fedilink
        English
        31 year ago

        Yeah I shell out ~$3 per month for the privilege of indulging in the insanity of self hosting email.

        • HousePantherOP
          link
          fedilink
          English
          21 year ago

          Right now I pay 15.00 a year for email through Zoho and it works really well so maybe it is folly for me to change it up. It’s more the principle of having to pay for email chaps at my ass when I have the technical know-how to do it myself. But Zoho is probably not selling my data since I am a paid member.

          • Ratz
            link
            fedilink
            English
            11 year ago

            It really comes down to what value you assign to having private email storage… unless you’re having GPG encrypted convos, its probably pretty moot anyway as one side is going to have a copy of the email trail and theres a 98% probability its google, microsoft or …yahoo I guess?

            I might be talking myself out of this, this is now a therapy session