Skip to content

Uses sed to copy and modify ports to create PROXY Protocol ports#174

Merged
cfis merged 4 commits intodocker-mailserver:masterfrom
DougReeder:sed-copy-modify
Jun 19, 2025
Merged

Uses sed to copy and modify ports to create PROXY Protocol ports#174
cfis merged 4 commits intodocker-mailserver:masterfrom
DougReeder:sed-copy-modify

Conversation

@DougReeder
Copy link
Copy Markdown
Contributor

@DougReeder DougReeder commented Jun 17, 2025

This produces a /etc/postfix/master.cf file with only these differences from the current version:

78,79d77
< 
< # Submission with proxy
81c79
<   -o syslog_name=postfix/submission
---
>     -o syslog_name=postfix/submission-proxyprotocol
94,95d91
< 
< # Submissions with proxy
97c93
<   -o syslog_name=postfix/submissions
---
>     -o syslog_name=postfix/submissions-proxyprotocol
110,111d105
< 
< # Smtp with proxy
113d106
<   -o syslog_name=postfix/smtpd-proxy
115c108,109
<   -o postscreen_cache_map=btree:/postscreen_10025_cache
---
>     -o postscreen_cache_map=proxy:btree:$data_directory/postscreen_12525_cache
>     -o syslog_name=postfix/smtpd-proxyprotocol

Fixes #173

References:

https://github.com/docker-mailserver/docker-mailserver-helm/pull/156#issuecomment-2814036639 + https://github.com/docker-mailserver/docker-mailserver-helm/pull/172#discussion_r2136949187 PR feedback comments.
Postscreen ports 25 + 12525 should be configured to share a cache map: 

docker-mailserver/docker-mailserver#4066 (additional ref)
v15 Docs reference (rendered page)
docker-mailserver/docker-mailserver#3866 (comment) to simplify this process.

@DougReeder DougReeder requested a review from funkypenguin as a code owner June 17, 2025 20:49
enabled: true
# List of sources (in CIDR format, space-separated) to permit PROXY protocol from
trustedNetworks: "10.0.0.0/8 192.168.0.0/16 172.16.0.0/16"
trustedNetworks: "10.0.0.0/8 192.168.0.0/16 172.16.0.0/12"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, you should be certain you can trust these subnets.

In Docker, at least historically due to the userland-proxy process, if the host could be reached by IPv6 but the container only had a private range IPv4 network, what would happen is Docker rerouted the IPv6 connection to IPv4 through the IPv4 subnet gateway IP (eg: 172.16.0.0), so all IPv6 clients appeared to be internal traffic as that gateway IP was trusted.

If the container had an IPv6 network as well, then it would retain the original client IPv6 IP and that wouldn't happen. Likewise if the userland-proxy feature was disabled, it would not try to route it like described and the connection would just fail.

When it comes to PROXY protocol trust, the risk would have been any IPv6 client could provide their own PROXY protocol header and that would be trusted. However, since there should be a proxy service inbetween the client and DMS/Dovecot here, that should be enforcing that any untrusted connection has PROXY protocol stripped away before the connection is forwarded to DMS, where PROXY protocol headers are added from your proxy service.

Just thought I'd mention this for context, as I think our official docs caution about such (such as only setting to an IP of your proxy service, if you have the control to pin that in a deterministic manner).

Any container compromised in the network could likewise fake PROXY protocol otherwise, which unlike the non-PROXY protocol ports, could allow for bypassing some security restraints if manipulating the client IP to Dovecot/Postfix provides more access/trust.

Comment thread charts/docker-mailserver/values.yaml
Comment thread charts/docker-mailserver/values.yaml
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great updates, thanks! LGTM 👍

@cfis cfis merged commit 90b9a27 into docker-mailserver:master Jun 19, 2025
5 checks passed
@cfis
Copy link
Copy Markdown
Collaborator

cfis commented Jun 19, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TODO: PROXY protocol config should be consistent with docs

3 participants