Skip to content

How to Configure HAProxy tcp-request Rules

DodaTech Updated 2026-06-24 1 min read

tcp-request rules provide control at the TCP level before HTTP processing. They are essential for protocol-aware load balancing. This guide walks through the specific troubleshooting steps to diagnose and resolve tcp-request issues.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

No TCP inspection rules (all connections accepted)

Wrong: No TCP content inspection

tcp-request inspect-delay 5s\ntcp-request content accept if { req_ssl_hello_type 1 }

Right: TCP content inspection with SSL detection

Output

TCP request rules:\n  Inspect delay: 5s\n  Accept SSL client hello connections immediately

Prevention

To avoid future issues, follow these best practices:

  • Set inspect-delay for content inspection rules
  • Use tcp-request connection for early connection rejection
  • Use tcp-request content for payload-based decisions
  • Use tcp-request session for session-level rules
  • Always end with an accept or reject rule

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with tcp request

  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [Char] with poor performance for large text operations

These mistakes appear frequently in real-world HAPROXY code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

What is inspect-delay in tcp-request?|||It sets how long HAProxy waits to accumulate enough data for content inspection before default action applies.
What is the difference between tcp-request connection and tcp-request content? connection rules run immediately on connection. content rules inspect the payload data.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro