The Simplest Way to Make Haproxy and Teamcity Work Like They Should
Using haproxy and teamcity together lets teams route build traffic to internal servers. HAProxy takes web requests and sends them to the right TeamCity build node. This setup keeps the main build server safe inside a private network. Developers and build agents talk to the public load balancer first. Then the load balancer checks the health of each backend node. It sends traffic only to nodes that are up and ready to work. Teams get fast builds and stable web pages without exposing raw server p
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Using haproxy and teamcity together lets teams route build traffic to internal servers. HAProxy takes web requests and sends them to the right TeamCity build node.
This setup keeps the main build server safe inside a private network. Developers and build agents talk to the public load balancer first. Then the load balancer checks the health of each backend node. It sends traffic only to nodes that are up and ready to work. Teams get fast builds and stable web pages without exposing raw server ports.
How traffic and logins flow between haproxy and teamcity
Good routing starts with clear rules for how data moves between both tools. A user or build agent sends an encrypted request to the HAProxy front end. HAProxy reads the request headers and terminates the outer TLS link if needed. Then it forwards the traffic over a private network path to TeamCity.
TeamCity needs to know the real client IP address and the original host name. HAProxy adds standard forwarding headers to every web request before sending it along. TeamCity reads those headers to build clean links and check user login states. Build agents also use this path to send status updates and big build files. WebSockets need long timeout rules in HAProxy so live build logs do not drop.
Common failure modes and how to scope roles and network paths
Many teams hit trouble when they leave default network and role settings in place. A common mistake is using one shared service account for all build agents. When one agent gets compromised, an attacker gets broad permissions across every project. Another risk comes from long-lived API tokens that never expire or rotate. If a developer saves a broad token in a build script, anyone can read it.
Unlogged changes on the load balancer or build server also create blind spots. If an engineer edits routing rules on the host, teams lose track of who did what. You can fix these gaps by scoping both network paths and user roles. Lock down the firewall so TeamCity only accepts traffic from the HAProxy internal IP.
End-to-End Encryption + HAProxy Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Give each project its own service account with permissions for only that single job. Set short lifetimes on all build tokens and user sessions. Turn on detailed request logs in both tools so you can trace every action. When sensitive fields like emails or phone numbers appear in results, masking rewrites matched fields in results.
Keeping multi-node build clusters fast and safe
Large engineering teams often run a main TeamCity server alongside secondary nodes. HAProxy makes this setup work by splitting user traffic from agent traffic. You can route heavy artifact uploads to one pool and web users to another. Health checks run every few seconds to spot slow or dead nodes right away.
When a node fails a check, HAProxy stops sending new requests to that host. Active builds keep running on healthy machines while admins fix the broken server. Sticky sessions keep each logged-in user tied to the same backend node. This stops random logouts when a developer clicks through build results and test logs. Regular reviews of role rules and network paths keep the whole pipeline safe.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Why do my live build logs keep dropping in the web UI?
TeamCity uses persistent connections to stream live build logs to your browser. If the HAProxy tunnel timeout is too short, it cuts off the stream early. Increase the tunnel and server timeout values so long builds keeps the session active.
How should build agents talk to the TeamCity server through HAProxy?
Build agents should send requests through a dedicated front end on the load balancer. Route agent traffic based on paths or headers so it stays separate from user clicks. Make sure the maximum body size limit allows big build artifacts to pass through.
How do we stop shared admin accounts on our build hosts?
Remove shared keys and tie every server login to a single person on the team. Map each identity to a narrow role that matches their daily job duties. Log every command and session so you have a clear audit trail for reviews.
Related guides
In this post