Add support for proxy-awareness headers: X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Forwarded-Host, and X-Request-ID
- Updated HAProxy configuration template to set all standard proxy headers for HTTP requests. - Added support for a unique request ID via `unique-id-format` and `unique-id-header` directives. - Implemented E2E tests for header validation, request correlation, and configuration correctness. - Enhanced documentation to explain usage and examples of proxy headers. - Updated CI workflows to include E2E tests for proxy headers.
This commit is contained in:
parent
4aba68dd37
commit
776f216a36
19 changed files with 480 additions and 4 deletions
|
|
@ -134,6 +134,8 @@ backend srv_phpapp_local_80
|
|||
option forwardfor
|
||||
http-request set-header X-Forwarded-Port %[dst_port]
|
||||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||
http-request set-header X-Forwarded-Host %[req.hdr(Host)]
|
||||
http-request set-header X-Request-ID %[uuid()]
|
||||
server srv-0 /run/php/php-fpm.sock check weight 1 proto fcgi
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,26 @@ sidebar_position: 22
|
|||
|
||||
# Other configurations
|
||||
|
||||
## Proxy Headers
|
||||
|
||||
EasyHAProxy automatically sets standard proxy-awareness headers for all HTTP requests:
|
||||
|
||||
| Header | Description | Example Value |
|
||||
|--------|-------------|---------------|
|
||||
| X-Forwarded-For | Client IP address | `203.0.113.50` |
|
||||
| X-Forwarded-Port | Port HAProxy received request on | `443` |
|
||||
| X-Forwarded-Proto | Protocol (http or https) | `https` |
|
||||
| X-Forwarded-Host | Original Host header from client | `example.com` |
|
||||
| X-Request-ID | Unique request identifier (UUID) | `550e8400-e29b-41d4-a716-446655440000` |
|
||||
|
||||
These headers help backend applications:
|
||||
- Determine the original client IP
|
||||
- Detect HTTPS vs HTTP
|
||||
- Generate correct URLs with proper hostname
|
||||
- Correlate requests for debugging and monitoring
|
||||
|
||||
**Note:** Headers are only added in HTTP mode, not TCP mode.
|
||||
|
||||
## Exposing Ports
|
||||
|
||||
Some ports on the EasyHAProxy container and in the firewall are required to be open. However, you don't need to expose the other container ports because EasyHAProxy will handle that.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue