Skip to content

Add support for PROXY protocol command - #12

Merged
jhumphreys merged 2 commits into
salesforce:mainfrom
breed:proxy-command
Jun 30, 2025
Merged

Add support for PROXY protocol command#12
jhumphreys merged 2 commits into
salesforce:mainfrom
breed:proxy-command

Conversation

@breed

@breed breed commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

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.

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.
@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @breed to sign the Salesforce Inc. Contributor License Agreement.

@breed

breed commented Jun 24, 2025

Copy link
Copy Markdown
Contributor Author

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

@jhumphreys

Copy link
Copy Markdown
Collaborator

@breed Sorry about that. I let them know about the CLA site and it seems to be fixed now.

Thanks for the contribution.

@breed

breed commented Jun 25, 2025

Copy link
Copy Markdown
Contributor Author

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.

@jhumphreys

Copy link
Copy Markdown
Collaborator

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.

@breed

breed commented Jun 25, 2025

Copy link
Copy Markdown
Contributor Author

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.

@jhumphreys
jhumphreys merged commit 19345b0 into salesforce:main Jun 30, 2025
2 checks passed
@breed
breed deleted the proxy-command branch June 30, 2025 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants