Skip to content

[Serve] Enable HAProxy by default on Linux - #66590

Open
eicherseiji wants to merge 1 commit into
masterfrom
seiji/haproxy-default-tls-compat
Open

eicherseiji wants to merge 1 commit into
masterfrom
seiji/haproxy-default-tls-compat

Conversation

@eicherseiji

@eicherseiji eicherseiji commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable HAProxy by default on Linux. macOS and Windows remain on the Python proxy, and Linux users can opt out with RAY_SERVE_ENABLE_HA_PROXY=0.

TLS configuration automatically falls back to the Python proxy because HAProxy does not yet terminate TLS. This TLS fallback can be removed when HAProxy supports TLS.

Fake multi-node placement tests use a head-only proxy because their logical worker nodes share one host.

Tests

The standard suite remains pinned to the Python proxy so it continues to cover that supported path, including the TLS fallback. Without the explicit pin, changing the Linux default would silently move the existing suite to HAProxy and leave Python-proxy regressions uncovered. A separate HAProxy suite runs the same Serve targets to cover the new default path.

  • The standard CI configurations pin RAY_SERVE_ENABLE_HA_PROXY=0
  • A separate full-suite HAProxy configuration pins RAY_SERVE_ENABLE_HA_PROXY=1 and runs the same Serve targets
  • TLS fallback unit coverage; HTTPS/WSS tests exercise the fallback
  • Pre-commit, including docs, buildifier, mypy, and Pyrefly
  • Full pytest requires CI because this checkout lacks a matching compiled ray._raylet

Duplicate search

No open duplicate found for enabling HAProxy by default.

AI assistance

AI assistance was used; the changes require submitter review before this draft is marked ready.

@eicherseiji
eicherseiji removed this pull request from stack #66591 September 30, 2026 00:48
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from bd5d6d4 to bdf77ef Compare September 30, 2026 00:48
Base automatically changed from seiji/haproxy-ingress-router-dispatch to seiji/multiplexed-ingress-router-app September 30, 2026 00:48
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from bdf77ef to fcfe8a8 Compare September 30, 2026 00:50
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from fcfe8a8 to 9d93e74 Compare September 30, 2026 00:54
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from 9d93e74 to 542822f Compare September 30, 2026 00:57
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from 542822f to 7f6edbb Compare September 30, 2026 01:11
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from 7f6edbb to 489fe8f Compare September 30, 2026 01:22
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch 5 times, most recently from be6ef5f to 94e7b77 Compare September 30, 2026 20:58
@eicherseiji eicherseiji added the go add ONLY when ready to merge, run all tests label Sep 30, 2026
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from 94e7b77 to 1f2a827 Compare September 30, 2026 22:45
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from 1f2a827 to ad01b33 Compare October 1, 2026 17:36
@eicherseiji
eicherseiji marked this pull request as ready for review October 1, 2026 17:39
@eicherseiji
eicherseiji requested review from a team as code owners October 1, 2026 17:39
@eicherseiji
eicherseiji requested review from a team as code owners October 1, 2026 17:39

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request enables HAProxy by default on Linux for Ray Serve, while keeping the Python proxy as the default on other platforms. It introduces an automatic fallback to the Python proxy when TLS is configured, since HAProxy does not terminate TLS, and updates the documentation and tests accordingly. Feedback on the changes highlights a bug in the TLS fallback logic where an incorrect warning about HAProxy not terminating TLS could be logged even if HAProxy was explicitly disabled in the controller's runtime environment variables.

Comment on lines +59 to +61
haproxy_was_enabled = (
RAY_SERVE_ENABLE_HA_PROXY or env_vars.get(_ENABLE_HAPROXY_ENV_VAR) == "1"
)

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.

medium

If RAY_SERVE_ENABLE_HA_PROXY is globally enabled (e.g., on Linux), but a user explicitly disables it in controller_options.runtime_env["env_vars"] by setting "RAY_SERVE_ENABLE_HA_PROXY": "0", haproxy_was_enabled will still evaluate to True due to the or condition. This leads to an incorrect and misleading warning being logged about HAProxy not terminating TLS, even though the user already explicitly opted out of HAProxy.

We should respect the override in env_vars if it is present, and only fall back to the global RAY_SERVE_ENABLE_HA_PROXY constant if it is absent.

Suggested change
haproxy_was_enabled = (
RAY_SERVE_ENABLE_HA_PROXY or env_vars.get(_ENABLE_HAPROXY_ENV_VAR) == "1"
)
haproxy_was_enabled = (
env_vars.get(_ENABLE_HAPROXY_ENV_VAR) == "1"
if _ENABLE_HAPROXY_ENV_VAR in env_vars
else RAY_SERVE_ENABLE_HA_PROXY
)

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread python/ray/serve/_private/api.py Resolved
@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue docs An issue or change related to documentation labels Oct 1, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 16, 2026
@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Oct 16, 2026
Base automatically changed from seiji/multiplexed-ingress-router-app to master October 19, 2026 18:20
@eicherseiji
eicherseiji force-pushed the seiji/haproxy-default-tls-compat branch from ad01b33 to 71ac24a Compare October 19, 2026 18:21

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 71ac24a. Configure here.

RAY_SERVE_ENABLE_HA_PROXY = (
os.environ.get("RAY_SERVE_ENABLE_HA_PROXY", "1" if sys.platform == "linux" else "0")
== "1"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Default HTTP bind becomes public

High Severity

Enabling HAProxy by default on Linux also replaces the implicit HTTP host with all interfaces through DEFAULT_HTTP_HOST. HTTPOptions and serve.start still describe that default as localhost, so Linux users who omit host now expose Serve on the network instead of loopback.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 71ac24a. Configure here.

This branch has not been deployed

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

Labels

docs An issue or change related to documentation go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants