The Simplest Way to Make Tcp Proxies and Tomcat Work Like They Should
Running tcp proxies and tomcat together lets teams route raw network traffic to Java web apps. The forwarder accepts client packets on the edge and sends them straight to the app server port. This setup keeps the Java server off the public internet. It also lets ops teams balance load across many app nodes. Teams can swap backend servers without changing the public IP address. How traffic and logins flow between tcp proxies and tomcat A layer four forwarder works at the transport level. It d
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.
Running tcp proxies and tomcat together lets teams route raw network traffic to Java web apps. The forwarder accepts client packets on the edge and sends them straight to the app server port.
This setup keeps the Java server off the public internet. It also lets ops teams balance load across many app nodes. Teams can swap backend servers without changing the public IP address.
How traffic and logins flow between tcp proxies and tomcat
A layer four forwarder works at the transport level. It does not read web headers or change the payload inside the stream. Instead, it opens a socket and pipes raw bytes to the Java server listener.
When a user connects, the edge node completes the initial network handshake. It then opens a second link to the backend Tomcat port. Bytes move back and forth between the two sockets in real time.
Teams have two main choices for handling encryption in this flow. The first option is TLS pass-through at the network edge. With pass-through, encrypted bytes flow straight to the Java server without stopping.
The Java server holds the private key and decrypts the stream itself. This keeps data encrypted all the way to the backend app. Still, it uses more CPU cycles on the Java host.
The second option is terminating encryption on the edge forwarder. The edge node decrypts the traffic and sends plain bytes over a private network. The backend server then processes the request without doing heavy math.
Moving packets at layer four hides the original client IP address. The Java server only sees the internal IP of the edge forwarder. This breaks audit logs and IP allow rules inside the web app.
To fix this, teams turn on the PROXY protocol on both systems. The edge node adds a small text header at the start of the connection. That header holds the real client IP and port number.
The Java connector reads this header before it parses the web request. Now the app logs the true caller IP for every single hit. Security teams can trace actions back to the right source.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Common failure modes and how to scope network paths
Even a clean network setup can fail under heavy load or bad rules. One major issue is mismatched timeout settings between the two tools. If the edge node drops idle links early, the Java server hits errors.
Another big risk comes from shared service accounts and broad tokens. Teams often open an admin port through the forwarder for remote checks. If engineers share one login key, the logs cannot show who made a change.
Broad network access also creates a wide attack path inside the VPC. An open forwarder allows anyone on the subnet to hit the management port. Attackers can use that path to upload bad code or read app data.
Unlogged queries and blind streams make security audits very hard. Because raw forwarders just move bytes, they do not log web paths or user names. If the Java server logs fail, you lose all record of the session.
To fix these gaps, teams must lock down both network paths and roles. First, put the edge nodes and Java servers in separate firewall zones. Only allow the forwarder IP to talk to the specific app port.
Never route traffic to the Tomcat shutdown port or admin app from outside. Keep management ports bound only to the local loopback interface on the host. Give each app component its own narrow role with strict read or write limits.
Match the socket keep-alive timers on both sides of the network link. Set the edge timeout slightly higher than the backend connector timeout. This lets the Java server close idle sockets cleanly without resetting active streams.
Finally, check that health probes test real app state, not just open ports. A plain port check passes even when the Java thread pool is deadlocked. Use a dedicated check endpoint so dead nodes leave the pool fast.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Why does Tomcat log the forwarder IP instead of the client IP?
A layer four forwarder opens a brand new socket to the backend server. Tomcat sees the source IP of that local socket unless you enable the PROXY protocol on both sides.
Should we stop TLS at the edge or on the Java server?
Stop TLS at the edge if you want simpler key rotation and lower CPU load on app nodes. Use pass-through if strict internal rules require encryption all the way to the app process.
How do we stop idle connections from hanging the Tomcat thread pool?
Set clear connection timeouts on both the edge forwarder and the Java connector. Make sure the backend server closes dead sockets before the thread pool hits its limit.
Related guides
In this post