Add support for PROXY protocol command - #12
Conversation
Implements the PROXY protocol https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt used by HAProxy and nginx to pass client connection information. nginx supports the PROXY protocol when it proxies a mail server, but to do things like SPF, we need to know the original client IP address.
|
Thanks for the contribution! Before we can merge this, we need @breed to sign the Salesforce Inc. Contributor License Agreement. |
|
i think the CLA site is broken. the agreement text is just a dump of raw HTML. https://cla.salesforce.com/sign-cla?prUrl=https%3A%2F%2Fgithub.com%2Fsalesforce%2Fmailific%2Fpull%2F12 |
|
@breed Sorry about that. I let them know about the CLA site and it seems to be fixed now. Thanks for the contribution. |
|
yes, it does. i signed it. i'm wondering what you think about making the remote address configurable and setting the proxy's address as a property? it would make the proxying more transparent. i don't feel strongly about it, since we have existing code that figures out the client IP based on the property. |
|
Just to make sure I'm following you -- are you suggesting to have some config so that, in a proxy situation, SmtpSession.getRemoteAddress() will give you the remote MTA's address rather than the proxy's address? I think it makes sense to expose remote MTA address and proxy address separately in the SmtpSession interface. Let me give that a little thought. Tangentially, when I've worked with nginx as a mail proxy, I seem to recall that we configured it to pass the source IP in an XCLIENT command, rather than having it use proxy protocol. But I like the idea of just adding PP support, as well. I should have time to give this a complete review later today. |
|
yeah, i am suggesting that getRemoteAddress shows the remote MTA's address. the same question comes up for an XCLIENT command. i think XCLIENT is a bit more complicated two EHLO messages will come in. XCLIENT command could change the state back to CONNECTED , but the EHLO command would end up running twice. it would be nice to have the option to do either. the other thing I want to add to the PROXY command is a constructor with the list of proxy addresses. i'm a bit paranoid that a misconfigured setup could end up with a mail server running on port 25 with proxy turned on, and then spammers could fake any address they would like. |
Implements the PROXY protocol
https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt used by HAProxy and nginx to pass client connection information. nginx supports the PROXY protocol when it proxies a mail server, but to do things like SPF, we need to know the original client IP address.