Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/contour: Add Support for custom headers on HTTPProxy level #5586

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions apis/projectcontour/v1/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,24 @@ type VirtualHost struct {
// +optional
JWTProviders []JWTProvider `json:"jwtProviders,omitempty"`

// The policy for managing request headers during proxying.
deveshk0 marked this conversation as resolved.
Show resolved Hide resolved
// Headers are appended to requests in the following order,
// service level headers,
// route level headers,
// virtual host level headers,
// global level headers.
// +optional
RequestHeadersPolicy *HeadersPolicy `json:"requestHeadersPolicy,omitempty"`
// The policy for managing response headers during proxying.
// Rewriting the 'Host' header is not supported.
// Headers are appended to responses in the following order,
// service level headers,
// route level headers,
// virtual host level headers,
// global level headers.
// +optional
ResponseHeadersPolicy *HeadersPolicy `json:"responseHeadersPolicy,omitempty"`

// IPAllowFilterPolicy is a list of ipv4/6 filter rules for which matching
// requests should be allowed. All other requests will be denied.
// Only one of IPAllowFilterPolicy and IPDenyFilterPolicy can be defined.
Expand Down Expand Up @@ -584,10 +602,20 @@ type Route struct {
// **NOTE: The header rewrite is only done while forwarding and has no bearing
// on the routing decision.
//
// Headers are appended to requests in the following order,
// service level headers,
// route level headers,
// virtual host level headers,
// global level headers.
// +optional
RequestHeadersPolicy *HeadersPolicy `json:"requestHeadersPolicy,omitempty"`
// The policy for managing response headers during proxying.
// Rewriting the 'Host' header is not supported.
// Headers are appended to responses in the following order,
// service level headers,
// route level headers,
// virtual host level headers,
// global level headers.
// +optional
ResponseHeadersPolicy *HeadersPolicy `json:"responseHeadersPolicy,omitempty"`
// The policies for rewriting Set-Cookie header attributes. Note that
Expand Down Expand Up @@ -1045,10 +1073,20 @@ type Service struct {
// values
Mirror bool `json:"mirror,omitempty"`
// The policy for managing request headers during proxying.
// Headers are appended to requests in the following order,
// service level headers,
// route level headers,
// virtual host level headers,
// global level headers.
// +optional
RequestHeadersPolicy *HeadersPolicy `json:"requestHeadersPolicy,omitempty"`
// The policy for managing response headers during proxying.
// Rewriting the 'Host' header is not supported.
// Headers are appended to responses in the following order,
// service level headers,
// route level headers,
// virtual host level headers,
// global level headers.
// +optional
ResponseHeadersPolicy *HeadersPolicy `json:"responseHeadersPolicy,omitempty"`
// The policies for rewriting Set-Cookie header attributes.
Expand Down
10 changes: 10 additions & 0 deletions apis/projectcontour/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions changelogs/unreleased/5586-deveshk0-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## HTTPProxy: Allow custom host header on HttpProxy level.

This Change allows you set custom host headers on httpProxy level, Please note headers are appended to requests/responses in the following order: weighted cluster level headers, route level headers, virtual host level headers and finally global level headers.

#### Example
```yaml
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: custom-host-header
spec:
fqdn: local.projectcontour.io
requestHeadersPolicy:
set:
- name: x-header
value: somevalue
responseHeadersPolicy:
set:
- name: x-powered-by
value: contour
routes:
- conditions:
- prefix: /
services:
- name: s1
port: 80
```
115 changes: 111 additions & 4 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6383,6 +6383,11 @@ spec:
Provided header must come from trusted source.
**NOTE: The header rewrite is only done while forwarding and has no bearing
on the routing decision.
Headers are appended to requests in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header names
Expand Down Expand Up @@ -6472,6 +6477,11 @@ spec:
description: |-
The policy for managing response headers during proxying.
Rewriting the 'Host' header is not supported.
Headers are appended to responses in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header names
Expand Down Expand Up @@ -6673,8 +6683,13 @@ spec:
- tls
type: string
requestHeadersPolicy:
description: The policy for managing request headers during
proxying.
description: |-
The policy for managing request headers during proxying.
Headers are appended to requests in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header
Expand Down Expand Up @@ -6709,6 +6724,11 @@ spec:
description: |-
The policy for managing response headers during proxying.
Rewriting the 'Host' header is not supported.
Headers are appended to responses in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header
Expand Down Expand Up @@ -7081,8 +7101,13 @@ spec:
- tls
type: string
requestHeadersPolicy:
description: The policy for managing request headers during
proxying.
description: |-
The policy for managing request headers during proxying.
Headers are appended to requests in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header
Expand Down Expand Up @@ -7117,6 +7142,11 @@ spec:
description: |-
The policy for managing response headers during proxying.
Rewriting the 'Host' header is not supported.
Headers are appended to responses in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header
Expand Down Expand Up @@ -7815,6 +7845,83 @@ spec:
- unit
type: object
type: object
requestHeadersPolicy:
description: |-
The policy for managing request headers during proxying.
Headers are appended to requests in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header names
to remove.
items:
type: string
type: array
set:
description: |-
Set specifies a list of HTTP header values that will be set in the HTTP header.
If the header does not exist it will be added, otherwise it will be overwritten with the new value.
items:
description: HeaderValue represents a header name/value
pair
properties:
name:
description: Name represents a key of a header
minLength: 1
type: string
value:
description: Value represents the value of a header
specified by a key
minLength: 1
type: string
required:
- name
- value
type: object
type: array
type: object
responseHeadersPolicy:
description: |-
The policy for managing response headers during proxying.
Rewriting the 'Host' header is not supported.
Headers are appended to responses in the following order,
service level headers,
route level headers,
virtual host level headers,
global level headers.
properties:
remove:
description: Remove specifies a list of HTTP header names
to remove.
items:
type: string
type: array
set:
description: |-
Set specifies a list of HTTP header values that will be set in the HTTP header.
If the header does not exist it will be added, otherwise it will be overwritten with the new value.
items:
description: HeaderValue represents a header name/value
pair
properties:
name:
description: Name represents a key of a header
minLength: 1
type: string
value:
description: Value represents the value of a header
specified by a key
minLength: 1
type: string
required:
- name
- value
type: object
type: array
type: object
tls:
description: |-
If present the fields describes TLS properties of the virtual
Expand Down
Loading