Skip to content

Commit 7f5dbb7

Browse files
authored
Merge branch 'main' into tests/nfr-tests-edge
2 parents e69da44 + dd60012 commit 7f5dbb7

File tree

25 files changed

+689
-373
lines changed

25 files changed

+689
-373
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ jobs:
193193
fail-build: false
194194

195195
- name: Upload scan result to GitHub Security tab
196-
uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
196+
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
197197
if: ${{ !inputs.dry_run }}
198198
continue-on-error: true
199199
with:

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ jobs:
374374
375375
- name: Generate Assertion Document
376376
id: assertiondoc
377-
uses: nginxinc/compliance-rules/.github/actions/assertion@83e452166aaf0ad8f07caf91a4f1f903b3dea1e6
377+
uses: nginxinc/compliance-rules/.github/actions/assertion@b0bda4baf00b030fd4e365821878b4857078e494
378378
with:
379379
artifact-name: ${{ github.event.repository.name }}_${{ github.sha }}_${{ github.run_number }}_${{ matrix.gateway.os }}_${{ matrix.gateway.arch }}
380380
artifact-digest: ${{ matrix.gateway.digest }}
@@ -393,7 +393,7 @@ jobs:
393393

394394
- name: Sign and Store Assertion Document
395395
id: sign
396-
uses: nginxinc/compliance-rules/.github/actions/sign@83e452166aaf0ad8f07caf91a4f1f903b3dea1e6
396+
uses: nginxinc/compliance-rules/.github/actions/sign@b0bda4baf00b030fd4e365821878b4857078e494
397397
with:
398398
assertion-doc: ${{ steps.assertiondoc.outputs.assertion-document-path }}
399399

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
5151
with:
5252
working-directory: ${{ matrix.directory }}
53-
version: v2.5.0 # renovate: datasource=github-tags depName=golangci/golangci-lint
53+
version: v2.6.0 # renovate: datasource=github-tags depName=golangci/golangci-lint
5454

5555
njs-lint:
5656
name: NJS Lint

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ jobs:
6060

6161
# Upload the results to GitHub's code scanning dashboard.
6262
- name: "Upload to code-scanning"
63-
uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
63+
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
6464
with:
6565
sarif_file: results.sarif

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ repos:
3838
- javascript
3939

4040
- repo: https://github.com/golangci/golangci-lint
41-
rev: v2.5.0
41+
rev: v2.6.0
4242
hooks:
4343
- id: golangci-lint-full
4444
name: golangci-lint-root

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_OPTIMIZATIONS) $(GO_LINKER_FlAGS_VARS)
2424

2525
# tools versions
2626
# renovate: datasource=github-tags depName=golangci/golangci-lint
27-
GOLANGCI_LINT_VERSION = v2.5.0
27+
GOLANGCI_LINT_VERSION = v2.6.0
2828
# renovate: datasource=docker depName=kindest/node
2929
KIND_K8S_VERSION = v1.34.0
3030
# renovate: datasource=github-tags depName=norwoodj/helm-docs
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Enhancement Proposal-4052: Authentiation Filter
2+
3+
- Issue: https://github.com/nginx/nginx-gateway-fabric/issues/4052
4+
- Status: Provisional
5+
6+
## Summary
7+
8+
Design and implement a means for users of NGINX Gateway Fabric to enable authentication on requests to their backend applications.
9+
This new filter should eventually expose all forms of authentication available through NGINX, both Open Source and Plus.
10+
11+
## Goals
12+
13+
- Design a means of configuring authentication for NGF
14+
- Design Authentication CRD with Basic Auth and JWT Auth in mind
15+
- Determine initial resource specification
16+
- Evaluate filter early in request processing, occurring before URLRewrite, header modifiers and backend selection
17+
- Authentication failures returns 401 Unauthorized by default
18+
- Ensure response codes are configurable
19+
20+
## Non-Goals
21+
22+
- Design for OIDC Auth
23+
- An Auth filter for TCP and UDP routes
24+
- Design for integration with [ExternalAuth in the Gateway API](https://gateway-api.sigs.k8s.io/geps/gep-1494/)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Enhancement Proposal-4051: Session Persistence for NGINX Plus and OSS
2+
3+
- Issue: https://github.com/nginx/nginx-gateway-fabric/issues/4051
4+
- Status: Provisional
5+
6+
## Summary
7+
8+
Enable NGINX Gateway Fabric to support session persistence for both NGINX Plus and NGINX OSS, allowing application developers to configure basic session persistence using the `ip_hash` load balancing method in OSS and cookie-based session persistence in NGINX Plus.
9+
10+
## Goals
11+
12+
- Extend the Upstream Settings Policy API to allow specifying `ip_hash` load balancing method to support basic session persistence.
13+
- Design the translation of the Gateway API `sessionPersistence` specification, which can be configured on both HTTPRoute and GRPCRoute, into NGINX Plus cookie-based session persistence directives with `secure` and `httpOnly` mode enforced by default.
14+
15+
## Non-Goals
16+
17+
- Describe or implement low-level configuration details for enabling session persistence.
18+
- Extend session persistence support to TLSRoutes or other Layer 4 route types.
19+
- Supporting the `sameSite` cookie directive for NGINX Plus session persistence, which may be considered in the future as the Gateway API `sessionPersistence` specification evolves.
20+
21+
## Useful Links
22+
23+
- Session Persistence [specification](https://gateway-api.sigs.k8s.io/reference/spec/#sessionpersistence).
24+
- Extended Session Persistence [GEP](https://gateway-api.sigs.k8s.io/geps/gep-1619).
25+
- RFC standard for [Set-Cookie](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1) header.

examples/externalname-service/README.md

Lines changed: 130 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@ This example demonstrates how to use NGINX Gateway Fabric to route traffic to ex
77
In this example, we will:
88

99
1. Deploy NGINX Gateway Fabric with DNS resolver configuration
10-
2. Create an ExternalName service pointing to an external API
11-
3. Configure HTTP and TLS routes to route traffic to this external service
12-
4. Test both HTTP and TLS routing functionality
10+
2. Create an ExternalName service pointing to an external API (httpbin.org)
11+
3. Deploy an internal service (coffee) to demonstrate mixed routing
12+
4. Configure an HTTPRoute that routes to both external and internal services
13+
5. (Optional) Configure BackendTLSPolicy for HTTPS connections to external services
14+
6. Test HTTP routing with both external and internal services
15+
7. (Optional) Test HTTPS backend connections and TLS passthrough
1316

1417
## Running the Example
1518

1619
## 1. Deploy NGINX Gateway Fabric
1720

1821
1. Follow the [installation instructions](https://docs.nginx.com/nginx-gateway-fabric/install/) to deploy NGINX Gateway Fabric.
1922

23+
**Note**: To use BackendTLSPolicy or TLSRoute for HTTPS connections to external services, you must:
24+
25+
- Install NGINX Gateway Fabric with `enableExperimental=true`
26+
- Install the experimental Gateway APIs on the cluster
27+
2028
## 2. Deploy the Gateway with DNS Resolver
2129

2230
Create the Gateway and NginxProxy configuration that enables DNS resolution for ExternalName services:
@@ -30,30 +38,64 @@ This creates:
3038
- A Gateway with HTTP and TLS listeners
3139
- An NginxProxy resource with DNS resolver configuration
3240

33-
## 3. Deploy ExternalName Services
41+
## 3. Deploy Services
3442

35-
Create the ExternalName service that points to external APIs:
43+
Create the ExternalName service and internal service:
3644

3745
```shell
38-
kubectl apply -f external-service.yaml
46+
kubectl apply -f cafe.yaml
3947
```
4048

41-
This creates an ExternalName service which points to `httpbin.org` with both HTTP and HTTPS ports
49+
This creates:
50+
51+
- An ExternalName service which points to `httpbin.org` with both HTTP and HTTPS ports
52+
- A coffee deployment and service for internal routing
4253

4354
## 4. Configure Routing
4455

45-
Create the HTTPRoute and TLSRoute that route traffic to the external service:
56+
Create the HTTPRoute and TLSRoute that route traffic to the services:
4657

4758
```shell
4859
kubectl apply -f route.yaml
4960
```
5061

5162
This creates:
5263

53-
- An HTTPRoute that routes HTTP traffic to the httpbin service
54-
- A TLSRoute that routes TLS traffic to the httpbin service
64+
- An HTTPRoute with two paths:
65+
- `/external/*` - Routes to the ExternalName service (httpbin.org) with a URLRewrite filter that strips the `/external` prefix
66+
- `/coffee` - Routes to the internal coffee service
67+
- A TLSRoute for TLS passthrough to the external httpbin service (commented out by default)
68+
69+
## 5. (Optional) Configure HTTPS Backend
70+
71+
If your external service requires HTTPS connections (like `https://httpbin.org`), you need to:
72+
73+
1. Update the HTTPRoute to use port 443 for the httpbin service in `route.yaml`:
74+
75+
```yaml
76+
backendRefs:
77+
- name: httpbin
78+
port: 443 # Change from 80 to 443
79+
```
5580
56-
## 5. Test the Configuration
81+
2. Create a BackendTLSPolicy:
82+
83+
```shell
84+
kubectl apply -f backendtlspolicy.yaml
85+
```
86+
87+
This configures NGINX Gateway Fabric to:
88+
89+
- Establish TLS connections to the backend service
90+
- Verify the backend's TLS certificate using system CA certificates
91+
- Match the certificate's hostname against the external service hostname
92+
93+
**Note**: BackendTLSPolicy is different from TLSRoute:
94+
95+
- **BackendTLSPolicy**: NGF terminates client TLS/HTTP and establishes HTTPS to the backend. Allows HTTP-level routing (paths, headers, etc.)
96+
- **TLSRoute**: TLS passthrough where the client establishes TLS directly with the backend. No HTTP-level routing possible.
97+
98+
## 6. Test the Configuration
5799

58100
Wait for the Gateway to be ready:
59101

@@ -66,43 +108,106 @@ Save the public IP address and ports of the NGINX Service into shell variables:
66108
```text
67109
GW_IP=XXX.YYY.ZZZ.III
68110
GW_PORT_HTTP=<port number>
69-
GW_PORT_HTTPS=<port number>
70111
```
71112

72-
Test the httpbin service via HTTP:
113+
Test the ExternalName service (httpbin.org) via HTTP:
73114

74115
```shell
75-
curl --resolve httpbin.example.com:$GW_PORT_HTTP:$GW_IP http://httpbin.example.com:$GW_PORT_HTTP/get
116+
curl --resolve cafe.example.com:$GW_PORT_HTTP:$GW_IP http://cafe.example.com:$GW_PORT_HTTP/external/get
76117
```
77118

78-
Test the httpbin service via TLS passthrough:
79-
80-
```shell
81-
curl -k --resolve httpbin.example.com:$GW_PORT_HTTPS:$GW_IP https://httpbin.example.com:$GW_PORT_HTTPS/get
82-
```
83-
84-
You should see a JSON response from httpbin.org showing request details e.g.
119+
You should see a JSON response from httpbin.org. Notice the `Host` header is correctly set to `httpbin.org`:
85120

86121
```json
87122
{
88123
"args": {},
89124
"headers": {
90125
"Accept": "*/*",
91-
"Host": "httpbin.example.com",
126+
"Host": "httpbin.org",
92127
"User-Agent": "curl/8.7.1",
93-
"X-Amzn-Trace-Id": "Root=1-68a49086-1e1dabb51155e05c1ebc1f63"
128+
"X-Amzn-Trace-Id": "Root=1-6901e342-2ce43cf518ee439d4e4d4867",
129+
"X-Forwarded-Host": "cafe.example.com"
94130
},
95131
"origin": "xxx.xxx.xxx.xx",
96-
"url": "https://httpbin.example.com/get"
132+
"url": "http://cafe.example.com/get"
97133
}
98134
```
99135

136+
Test the internal coffee service:
137+
138+
```shell
139+
curl --resolve cafe.example.com:$GW_PORT_HTTP:$GW_IP http://cafe.example.com:$GW_PORT_HTTP/coffee
140+
```
141+
142+
You should see a response from the coffee service:
143+
144+
```text
145+
Server address: 10.244.0.7:8080
146+
Server name: coffee-<pod-id>
147+
Date: ...
148+
URI: /coffee
149+
Request ID: ...
150+
```
151+
152+
You can also test other httpbin.org endpoints:
153+
154+
```shell
155+
# Test /anything endpoint
156+
curl --resolve cafe.example.com:$GW_PORT_HTTP:$GW_IP http://cafe.example.com:$GW_PORT_HTTP/external/anything
157+
158+
# Test /headers endpoint
159+
curl --resolve cafe.example.com:$GW_PORT_HTTP:$GW_IP http://cafe.example.com:$GW_PORT_HTTP/external/headers
160+
```
161+
162+
### Testing HTTPS Backend (Optional)
163+
164+
If you configured BackendTLSPolicy in step 5, NGF will establish HTTPS connections to the external service. The client connection remains HTTP, but the backend connection uses HTTPS:
165+
166+
```shell
167+
curl --resolve cafe.example.com:$GW_PORT_HTTP:$GW_IP http://cafe.example.com:$GW_PORT_HTTP/external/get
168+
```
169+
170+
The response will show the request was successfully proxied to `https://httpbin.org` with proper TLS verification.
171+
172+
### Testing TLS Passthrough (Optional)
173+
174+
To test TLS passthrough, first uncomment the TLSRoute section in `route.yaml` and reapply:
175+
176+
```shell
177+
kubectl apply -f route.yaml
178+
```
179+
180+
Then save the HTTPS port:
181+
182+
```text
183+
GW_PORT_HTTPS=<port number>
184+
```
185+
186+
Test the httpbin service via TLS passthrough:
187+
188+
```shell
189+
curl -k --resolve httpbin.example.com:$GW_PORT_HTTPS:$GW_IP https://httpbin.example.com:$GW_PORT_HTTPS/get
190+
```
191+
192+
You should see a JSON response from httpbin.org via HTTPS.
193+
194+
## How It Works
195+
196+
This example demonstrates key features for routing to external services:
197+
198+
1. **DNS Resolution**: The NginxProxy resource configures DNS resolvers (8.8.8.8, 1.1.1.1) so NGINX can resolve external hostnames
199+
2. **Host Header Handling**: NGF automatically detects ExternalName services and sets the `Host` header to the external hostname (`httpbin.org`) instead of the Gateway hostname (`cafe.example.com`), ensuring external services receive the correct Host header
200+
3. **URL Rewriting**: The URLRewrite filter strips the `/external` prefix before proxying to httpbin.org, so `/external/get` becomes `/get` on the external service
201+
4. **Mixed Routing**: The same HTTPRoute can route to both ExternalName services and internal Kubernetes services seamlessly
202+
5. **HTTPS Backends**: BackendTLSPolicy enables secure HTTPS connections to external services while allowing HTTP-level routing based on paths, headers, etc.
203+
6. **TLS Passthrough**: The TLSRoute allows direct TLS connections to external services without termination at the Gateway (no HTTP-level routing)
204+
100205
## Cleanup
101206

102207
Remove all resources created in this example:
103208

104209
```shell
105210
kubectl delete -f route.yaml
106-
kubectl delete -f external-service.yaml
211+
kubectl delete -f cafe.yaml
107212
kubectl delete -f gateway.yaml
108213
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: gateway.networking.k8s.io/v1alpha3
2+
kind: BackendTLSPolicy
3+
metadata:
4+
name: httpbin-tls
5+
spec:
6+
targetRefs:
7+
- group: ""
8+
kind: Service
9+
name: httpbin
10+
validation:
11+
hostname: httpbin.org
12+
wellKnownCACertificates: System

0 commit comments

Comments
 (0)