• 3 Posts
  • 6 Comments
Joined 1 year ago
cake
Cake day: June 19th, 2023

help-circle




  • z3bra@lemmy.sdf.orgtoSelfhosted@lemmy.worldMy first E-Mail server
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    11 months ago

    Congratulations! A mail server is quite demanding in terms of initial setup, but it’s also very rewarding !

    Here are a few pointers I can give you:

    • Using a good domain is important, some provider block entire TLDs for cheap domains (eg. .tk or .pw). I learnt it the hard way…
    • Set your MX records to A records, not CNAME
    • Ensure your PTR records match your A records for the mail server
    • Learn about SPF and DKIM
    • Set them up, and verify with mxtoolbox
    • Use the ip4:<ipv4> and/or ip6:<ipv6> selectors for SPF
    • Setup a spamfilter (I like spamassassin)
    • Leave it all running for a few weeks/months
    • Publish a DMARC policy on your DNS, and verify with mxtoolbox

    This should limit a lot your likeliness to end up in spam folders (which is usually the hardest part about running your mail server)



  • Short answer: Don’t bother, it’s too complex to setup (unless your app is HTTP or supports the PROXY protocol). You better read your proxy logs instead.

    Long answer: What you want is called “IP transparency” and require your proxy to “spoof” the IP address of the client when forwarding packets to the remote server. Some proxies do it (Nginx plus, Avi Vantage, Fortinet) but are paid services. I don’t know for free solutions as I only ever implemented it with those listed above.

    This require a fairly complex setup though:

    0. IP address spoofing

    The proxy must rewrite all downstream request to spoof the client IP address, making it look like the traffic originates from the client at the TCP layer.

    1. Backend server routing

    As the packet will most likely originate from random IP on the internet, your backend server must have a way to route back the traffic to the proxy, instead of it’s default gateway. Otherwise you’d implement what is called "Direct Server Return*, which won’t work in your case (packet will be dropped by the client as originating from your backend server directly, and not from the proxy).

    You have two solutions here:

    • set your default gateway to the proxy over its VPN interface (don’t do that unless you truly understand all the implications of such a setup)
    • use packet tagging and VRF on the backend server to route back all traffic coming from the VPN, back to the VPN interface (I’m not even sure this would work with an IPsec VPN though because of ACL…)

    3. Intercept and route back return traffic

    The proxy must be aware that it must intercept this traffic targeted at the destination IP of the client as part of a proxied request. This require a proxy that can bind on an IP that is not configured on the system.

    So yeah, don’t do that unless you NEED to do that (trust me as I had to do it, and hated setting it up).

    Edit: apparently haproxy supports this feature, which they call transparent mode