Skip to content

proxy/haproxy: Update haproxy documentation#1499

Open
cmouse wants to merge 1 commit into
dovecot:mainfrom
cmouse:haproxy
Open

proxy/haproxy: Update haproxy documentation#1499
cmouse wants to merge 1 commit into
dovecot:mainfrom
cmouse:haproxy

Conversation

@cmouse
Copy link
Copy Markdown
Contributor

@cmouse cmouse commented Apr 9, 2026

JIRA: DOV-6879

@github-actions

This comment has been minimized.

@cmouse cmouse force-pushed the haproxy branch 2 times, most recently from e9171b4 to c8da05b Compare April 9, 2026 10:50
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@cmouse cmouse force-pushed the haproxy branch 2 times, most recently from 3b7c4da to 943faf4 Compare April 9, 2026 10:55
Comment thread docs/core/config/proxy/haproxy.md
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md
Comment thread docs/core/config/proxy/haproxy.md Outdated
Comment thread docs/core/config/proxy/haproxy.md Outdated
@cmouse cmouse force-pushed the haproxy branch 2 times, most recently from 8228946 to a57f3eb Compare May 11, 2026 09:20
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.


Dovecot must be configured to accept PROXY protocol headers:

- Set `haproxy = yes` on the listener
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Set [[setting,inet_listener_haproxy,yes]] on the [[setting,inet_listener]].

- Set [[setting,haproxy_trusted_networks]] to the IP address(es) or CIDR
range(s) of HAProxy. The value is a space-separated list and accepts CIDR
notation, e.g. `haproxy_trusted_networks = 127.0.0.1 10.0.0.0/24
2001:db8::/32`. Dovecot rejects PROXY headers from any unlisted address.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could expand what "rejects" means: If a client from unlisted address connects to a haproxy listener, a warning is logged and the client is disconnected.


* Consistent TLS handling at a single point
* End-to-end encryption (client → HAProxy → Dovecot)
* Reduced risk of configuration drift
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What configuration drift? Does this mean it avoids having to keep ssl settings in sync between Dovecot and HAProxy when STARTTLS is provided by Dovecot? Should say that clearly.

Backend TLS only adds security when the HAProxy ↔ Dovecot path can be observed
or tampered with. When both run on the same host and traffic stays on
`127.0.0.1`, backend TLS adds CPU overhead with no threat-model benefit; a
plaintext backend with the PROXY protocol is acceptable in that case.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"plaintext connection to backend"?

```

```doveconf[dovecot_tls_listener]
# ssl = required: HAProxy always connects via TLS, so Dovecot can enforce it
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A bit repetitive to have ssl = required: here

perform SNI-based routing, or do TLS offloading.

Because HAProxy never decrypts the stream, the PROXYv2 header is the only way
for Dovecot to learn the original client IP. Add `send-proxy-v2` on the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

First sentence is confusing. PROXYv2 header is always the only way to learn the original client IP.


backend dovecot_imap_tls
mode tcp
server dovecot1 127.0.0.1:993 send-proxy-v2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again an issue with bind *:993 conflicting with Dovecot's 127.0.0.1:993.

defaults
mode tcp
timeout client 1h
timeout server 1h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about 31min? There is hardcoded 30 min timeout in Dovecot, suggested also by IMAP RFC.

backend dovecot_imap_tls
mode tcp
option ssl-hello-chk
server dovecot1 127.0.0.1:993 check ssl verify required \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again here better to use non-127.0.0.1

mode tcp
option tcp-check
tcp-check expect string * OK
server dovecot1 127.0.0.1:143 check send-proxy-v2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no 127.0.0.1

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.

2 participants