Add pass_headers support to FastCGI plugin
This commit is contained in:
parent
91da35650d
commit
5eee2fcf19
4 changed files with 135 additions and 17 deletions
|
|
@ -18,14 +18,39 @@ Automatically generates HAProxy `fcgi-app` configuration that defines required C
|
|||
|
||||
## Configuration Options
|
||||
|
||||
| Option | Description | Default |
|
||||
|-------------------|-----------------------------------------|------------------------------------|
|
||||
| `enabled` | Enable/disable plugin | `true` |
|
||||
| `document_root` | Document root path | `/var/www/html` |
|
||||
| `script_filename` | Custom pattern for SCRIPT_FILENAME | `%[path]` (uses HAProxy's default) |
|
||||
| `index_file` | Default index file | `index.php` |
|
||||
| `path_info` | Enable PATH_INFO support | `true` |
|
||||
| `custom_params` | Dictionary of custom FastCGI parameters | (optional) |
|
||||
| Option | Description | Default |
|
||||
|-------------------|--------------------------------------------|--------------------------------------|
|
||||
| `enabled` | Enable/disable plugin | `true` |
|
||||
| `document_root` | Document root path | `/var/www/html` |
|
||||
| `script_filename` | Custom pattern for SCRIPT_FILENAME | `%[path]` (uses HAProxy's default) |
|
||||
| `index_file` | Default index file | `index.php` |
|
||||
| `path_info` | Enable PATH_INFO support | `true` |
|
||||
| `custom_params` | Dictionary of custom FastCGI parameters | (optional) |
|
||||
| `pass_headers` | HTTP headers to forward to the FastCGI app | (optional) |
|
||||
|
||||
### `pass_headers` — Forwarding HTTP Headers
|
||||
|
||||
:::important
|
||||
HAProxy strips `Authorization`, `Proxy-Authorization`, and all hop-by-hop headers before forwarding requests to the FastCGI backend. Applications that rely on these headers (e.g. APIs using Bearer tokens, Basic auth, or JWT) will fail silently without this option.
|
||||
:::
|
||||
|
||||
`pass_headers` accepts a comma-separated string or a list of strings/dicts:
|
||||
|
||||
```yaml
|
||||
# Simple — single header
|
||||
pass_headers: "Authorization"
|
||||
|
||||
# Multiple — comma-separated
|
||||
pass_headers: "Authorization, Proxy-Authorization"
|
||||
|
||||
# With ACL condition — list of dicts
|
||||
pass_headers:
|
||||
- Authorization
|
||||
- name: X-Custom-Header
|
||||
condition: "if { ssl_fc }"
|
||||
```
|
||||
|
||||
> **Note:** `Content-Type` and `Content-Length` cannot be passed here — they are automatically converted to the CGI parameters `CONTENT_TYPE` and `CONTENT_LENGTH`.
|
||||
|
||||
## Configuration Examples
|
||||
|
||||
|
|
@ -78,6 +103,7 @@ metadata:
|
|||
easyhaproxy.plugin.fastcgi.document_root: "/var/www/html"
|
||||
easyhaproxy.plugin.fastcgi.index_file: "index.php"
|
||||
easyhaproxy.plugin.fastcgi.script_filename: "/var/www/html/index.php"
|
||||
easyhaproxy.plugin.fastcgi.pass_headers: "Authorization, Proxy-Authorization"
|
||||
spec:
|
||||
ingressClassName: easyhaproxy
|
||||
rules:
|
||||
|
|
@ -113,13 +139,13 @@ easymapping:
|
|||
|
||||
### Environment Variables
|
||||
|
||||
| Environment Variable | Config Key | Type | Default | Description |
|
||||
|----------------------------------------------|-------------------|----------|------------------------|---------------------------------------|
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_ENABLED` | `enabled` | boolean | `true` | Enable/disable plugin for all domains |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_DOCUMENT_ROOT` | `document_root` | string | `/var/www/html` | Document root path |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_SCRIPT_FILENAME` | `script_filename` | string | `%[path]` | Custom pattern for SCRIPT_FILENAME |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_INDEX_FILE` | `index_file` | string | `index.php` | Default index file |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_PATH_INFO` | `path_info` | boolean | `true` | Enable PATH_INFO support |
|
||||
| Environment Variable | Config Key | Type | Default | Description |
|
||||
|----------------------------------------------|-------------------|----------|-------------------------|---------------------------------------|
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_ENABLED` | `enabled` | boolean | `true` | Enable/disable plugin for all domains |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_DOCUMENT_ROOT` | `document_root` | string | `/var/www/html` | Document root path |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_SCRIPT_FILENAME` | `script_filename` | string | `%[path]` | Custom pattern for SCRIPT_FILENAME |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_INDEX_FILE` | `index_file` | string | `index.php` | Default index file |
|
||||
| `EASYHAPROXY_PLUGIN_FASTCGI_PATH_INFO` | `path_info` | boolean | `true` | Enable PATH_INFO support |
|
||||
|
||||
## Generated HAProxy Configuration
|
||||
|
||||
|
|
@ -129,6 +155,8 @@ fcgi-app fcgi_phpapp_local
|
|||
docroot /var/www/html
|
||||
index index.php
|
||||
path-info ^(/.+\.php)(/.*)?$
|
||||
pass-header Authorization
|
||||
pass-header Proxy-Authorization
|
||||
|
||||
# Backend configuration (added to the backend section)
|
||||
backend srv_phpapp_local_80
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue