MySQL Proxy_protocol_networks
The mysql proxy_protocol_networks setting tells a database which network proxies can forward client IP addresses. It lets the server read the true source IP instead of the load balancer IP. Database teams place load balancers or routers in front of their database clusters. Without this setting, every login looks like it came from the middle network hop. That breaks host-based user rules and makes audit logs hard to read. How mysql proxy_protocol_networks works in practice When an engineer or
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.
The mysql proxy_protocol_networks setting tells a database which network proxies can forward client IP addresses. It lets the server read the true source IP instead of the load balancer IP.
Database teams place load balancers or routers in front of their database clusters. Without this setting, every login looks like it came from the middle network hop. That breaks host-based user rules and makes audit logs hard to read.
How mysql proxy_protocol_networks works in practice
When an engineer or an AI agent connects through a load balancer, the network address changes. The database only sees the address of the load balancer that forwarded the traffic. The proxy protocol fixes this by adding a small header to the very first packet. This header holds the original client IP address and port number.
A database cannot trust this header from every machine on the network. Any bad actor could send a fake header to spoof a trusted internal IP. To stop this, admins define trusted proxy subnets in the server settings. When traffic arrives from a listed subnet, the database reads the header and sets the client IP. If traffic arrives from any other address, the database blocks the header or drops the packet.
This mechanism helps both human engineers and automated AI tools pass network checks. Host grants in the database can match the true source machine again. Audit logs also record the actual origin of the connection for later review.
Security and operational tradeoffs in active sessions
Passing the real client IP solves network routing blind spots, but major security gaps remain. Network addresses and static database roles only check who is allowed to open a connection. Once the session starts, the user or AI agent has full power within that role.
Teams also face daily operational toil when they manage IP lists across dynamic cloud networks. Every time a proxy subnet changes, admins must update the database settings and check routing rules. If a subnet rule is too wide, any host in that range can spoof another client IP.
Database Proxy (ProxySQL, PgBouncer) + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Even with accurate source IPs, static credentials do not control what happens inside an active session. A valid user or script can run a broad query that pulls sensitive customer data. Standard proxy headers cannot inspect query text or block a dangerous write command on the fly.
Controlling queries and data beyond network headers
Modern engineering teams need controls that work at the query level, not just the network edge. Tying database sessions to real human or service identities gives much clearer audit trails than IP addresses. Teams can see which specific engineer or AI workflow ran each statement.
Query-level controls also let admins ask for peer approval before a risky command runs. Instead of giving a developer permanent write permissions, a team can review individual changes in real time. Dynamic data masking adds another layer of safety during live queries. Masking rewrites matched fields in results, such as emails, phone numbers, card numbers, and national IDs. This lets engineers and AI agents query production tables while keeping sensitive fields protected in the output.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.
Frequently asked questions
Why does my database log show the load balancer IP instead of the client IP?
A standard load balancer opens a new network connection to the database using its own IP address. Unless both the proxy and the database use the proxy protocol, the original client IP stays hidden.
What happens if an untrusted host sends a proxy protocol header to MySQL?
The database checks the sender against its list of trusted proxy subnets before reading the header. If the sender IP is not on that list, the server rejects the connection right away.
Does the proxy protocol protect sensitive data inside database queries?
No, the protocol only passes network address metadata when a session first starts. It does not encrypt traffic, inspect SQL statements, or mask sensitive fields like card numbers in results.
Related guides
In this post