Skip to content

Send the master hostname as the Host header on the ws transport - #70998

Open
cestercian wants to merge 1 commit into
saltstack:3008.xfrom
cestercian:fix/70988-ws-host-header
Open

cestercian wants to merge 1 commit into
saltstack:3008.xfrom
cestercian:fix/70988-ws-host-header

Conversation

@cestercian

Copy link
Copy Markdown

What does this PR do?

The ws transport connects to the resolved master IP, so aiohttp sends that IP as the HTTP Host header. A load balancer or proxy that routes on Host can't send those minions to the right master.

When master is a hostname and the connection target is the resolved master_ip, the publish client and the request client now pass Host: <master>:<port> to ws_connect, and still connect to the resolved IP. The header is left alone when master is an IP, unset, or a list, when the target isn't master_ip, and for ipc/unix socket connections. IPv6 literals get bracketed. ZeroMQ and TCP are unchanged.

What issues does this PR fix or reference?

Fixes #70988

Previous Behavior

The Host header on ws transport connections was the master's resolved IP.

New Behavior

The Host header is the configured master hostname (with port), while the TCP connection still goes to the resolved IP.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

New tests in tests/pytests/unit/transport/test_ws_host_header.py cover the hostname case for both clients plus the IP, list, unset, non-master target and ipc cases. pytest tests/pytests/unit/transport/ -k ws passes (20 passed), black 24.2.0 and isort 5.13.2 are clean.

Commits signed with GPG?

Yes

Websocket clients connect to the resolved master IP, so the HTTP Host
header was that IP. A load balancer that routes on Host could not send
those minions to the right master. When master is a hostname, pass that
name in the Host header and keep the connection on the resolved IP.
@cestercian
cestercian requested a review from a team as a code owner December 1, 2026 07:21
@dwoz dwoz added the test:full Run the full test suite label Dec 6, 2026

This branch was previously deployed

1 inactive deployment
ci — 47660a2c Deployed Dec 6, 2026 by dwoz via Build Onedir Packages / RPM (x86_64) #29880
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants