Haproxy MySQL Check

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an haproxy mysql check to test if database nodes are alive. The load balancer sends a login packet to each node and reads the reply. Teams often use a shared database user with broad rights for these checks. Broad permissions create big risks when an attacker steals that check account. Even worse, app teams might reuse that same account to run manual queries. How an haproxy mysql check works in your setup A plain TCP check only tests if the database port is open. The database might

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.

You set up an haproxy mysql check to test if database nodes are alive. The load balancer sends a login packet to each node and reads the reply. Teams often use a shared database user with broad rights for these checks. Broad permissions create big risks when an attacker steals that check account. Even worse, app teams might reuse that same account to run manual queries.

How an haproxy mysql check works in your setup

A plain TCP check only tests if the database port is open. The database might still be frozen or unable to take new queries. A protocol check goes one step further than a port test. The load balancer opens a connection and starts a database login handshake. It sends a specific username to the database server during this step. The server checks its user table and replies with a status packet. If the reply shows a working engine, the node stays in rotation. If the server times out or sends an error, traffic stops going there. You must create a dedicated user inside the database for this task. This user needs no password and no rights to read any tables. You lock this user to the exact IP address of the load balancer. That way, external hosts cannot use the check account to log in.

Why basic health checks leave a security gap

Health checks keep your database cluster online and route app traffic well. They make sure broken nodes do not take requests from your apps. Yet they do nothing to control what happens after a user logs in. Engineers and scripts still log in through the load balancer to fix bugs. Native database roles decide who can log in and which tables they see. Once a session starts, the database trusts every command from that user. A tired engineer can run a bad delete query on a live table. A script can pull raw emails, phone numbers, or card numbers in seconds. Standard load balancers just pass those packets back and forth without looking inside. They cannot tell a safe read query from a huge data dump. They also do not tie queries back to an individual person on your team. Shared database accounts hide who ran which command during an outage.

Ways to lock down database check and user accounts

Start by separating your health check user from all human and app users. Give the check user zero permissions on all schemas and tables. Next, review the accounts your engineers use to reach the database cluster. Remove shared admin logins that multiple people use at the same time. Give each person or app a distinct role with narrow table rights. Turn on database query logs so you have a record of events. Keep in mind that native logs grow fast and take work to search. You also need a way to review high-risk changes before they run. Putting controls on live queries stops mistakes before they hurt your data.

MySQL Access Governance + HAProxy Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.

With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

Why does my database block the load balancer IP address?

The database blocks hosts after too many failed handshakes without a full login. Use a real protocol check with a valid username to stop error counts.

Does the check user need permission to read tables?

No, the check user needs zero table permissions to test node health. A successful login handshake proves the database engine is running and ready.

Can a protocol check tell if a node is read-only?

A basic login check only proves the database service is awake and responding. To check read-only state, run an external script that queries server variables.

The query runs. The emails stay hidden.