mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-19 03:57:17 +02:00
config: add rewrite_response_headers option (#1961)
* add lua script to rewrite response headers * add policy config * update docs
This commit is contained in:
parent
b6ec01f377
commit
7f6107051f
12 changed files with 348 additions and 35 deletions
|
@ -1294,6 +1294,30 @@ Remove Request Headers allows you to remove given request headers. This can be u
|
|||
```
|
||||
|
||||
|
||||
### Rewrite Response Headers
|
||||
- Config File Key: `rewrite_response_headers`
|
||||
- Type: `object`
|
||||
- Optional
|
||||
- Example: `[{ "header": "Location", "prefix": "http://localhost:8000/two/", "value": "http://frontend/one/" }]`
|
||||
|
||||
Rewrite Response Headers allows you to modify response headers before they are returned to the client. The `header` field will match the HTTP header name, and `prefix` will be replaced with `value`. For example, if the downstream server returns a header:
|
||||
|
||||
```text
|
||||
Location: http://localhost:8000/two/some/path/
|
||||
```
|
||||
|
||||
And the policy has this config:
|
||||
|
||||
```yaml
|
||||
rewrite_response_headers:
|
||||
- header: Location
|
||||
prefix: http://localhost:8000/two/
|
||||
value: http://frontend/one/
|
||||
```
|
||||
|
||||
The browser would be redirected to: `http://frontend/one/some/path/`. This is similar to nginx's [`proxy_redirect` option](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect), but can be used for any header.
|
||||
|
||||
|
||||
### Redirect
|
||||
- `yaml`/`json` setting: 'redirect'
|
||||
- Type: object
|
||||
|
|
|
@ -1427,6 +1427,30 @@ settings:
|
|||
- X-Email
|
||||
- X-Username
|
||||
```
|
||||
- name: "Rewrite Response Headers"
|
||||
keys: ["rewrite_response_headers"]
|
||||
attributes: |
|
||||
- Config File Key: `rewrite_response_headers`
|
||||
- Type: `object`
|
||||
- Optional
|
||||
- Example: `[{ "header": "Location", "prefix": "http://localhost:8000/two/", "value": "http://frontend/one/" }]`
|
||||
doc: |
|
||||
Rewrite Response Headers allows you to modify response headers before they are returned to the client. The `header` field will match the HTTP header name, and `prefix` will be replaced with `value`. For example, if the downstream server returns a header:
|
||||
|
||||
```text
|
||||
Location: http://localhost:8000/two/some/path/
|
||||
```
|
||||
|
||||
And the policy has this config:
|
||||
|
||||
```yaml
|
||||
rewrite_response_headers:
|
||||
- header: Location
|
||||
prefix: http://localhost:8000/two/
|
||||
value: http://frontend/one/
|
||||
```
|
||||
|
||||
The browser would be redirected to: `http://frontend/one/some/path/`. This is similar to nginx's [`proxy_redirect` option](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect), but can be used for any header.
|
||||
- name: "Redirect"
|
||||
keys: ["redirect"]
|
||||
attributes: |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue