Routing Part of an Application to a New Version with HAProxy
Sometimes you need to roll out only part of an application to production. This often happens after refactoring or when introducing a new version of specific endpoints. With HAProxy you can route only selected requests to the new backend while keeping the rest of the traffic on the existing servers.
This approach makes it easy to test changes in production without switching the entire application at once.
Haproxy configuration
listen frontend_http
bind *:80
bind *:443 ssl crt /etc/haproxy/crt/ssl.pem
mode http
acl is_legacy_paths path_reg -i ^/(api|api_v1|v1).*
acl is_legacy_method url_reg -i .*method=notify.*
use_backend backend_new if is_legacy_paths is_legacy_method
default_backend backend_main
Backend setup
In the end you need two backends: the default one (backend_main) with the old server pool, and a second backend (backend_new) with the new servers.
Human Logic, AI Syntax...
Note on Content: I'm a Systems Engineer, not a native English writer. To ensure my technical ideas are clear and accessible, I use AI tools to polish the grammar and style. The workflow is simple: I provide the logic, the code, and the real-world experience. The AI handles the "English-to-Human" translation layer. If you find a bug, that's on me. If you find a perfectly placed comma, that's probably the AI.
Comments
Post a Comment