Skip to content

Commit b56c6da

Browse files
haywoodshpre-commit-ci[bot]vepatel
authored andcommitted
Add command line argument for custom TLS Passthrough port (#4108)
* Allow custom port for TLS Passthrough * update helm chart and add automated tests --------- Signed-off-by: Haywood Shannon <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Venktesh Shivam Patel <[email protected]>
1 parent 6bf8bb0 commit b56c6da

File tree

23 files changed

+318
-16
lines changed

23 files changed

+318
-16
lines changed

cmd/nginx-ingress/flags.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ var (
164164
`The namespace/name of the GlobalConfiguration resource for global configuration of the Ingress Controller. Requires -enable-custom-resources. Format: <namespace>/<name>`)
165165

166166
enableTLSPassthrough = flag.Bool("enable-tls-passthrough", false,
167-
"Enable TLS Passthrough on port 443. Requires -enable-custom-resources")
167+
"Enable TLS Passthrough on default port 443. Requires -enable-custom-resources")
168+
169+
tlsPassthroughPort = flag.Int("tls-passthrough-port", 443, "Set custom port for TLS Passthrough. [1024 - 65535]")
168170

169171
spireAgentAddress = flag.String("spire-agent-address", "",
170172
`Specifies the address of the running Spire agent. Requires -nginx-plus and is for use with NGINX Service Mesh only. If the flag is set,

cmd/nginx-ingress/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func main() {
9797
NginxStatusPort: *nginxStatusPort,
9898
StubStatusOverUnixSocketForOSS: *enablePrometheusMetrics,
9999
TLSPassthrough: *enableTLSPassthrough,
100+
TLSPassthroughPort: *tlsPassthroughPort,
100101
EnableSnippets: *enableSnippets,
101102
NginxServiceMesh: *spireAgentAddress != "",
102103
MainAppProtectLoadModule: *appProtect,
@@ -166,6 +167,7 @@ func main() {
166167
IsPrometheusEnabled: *enablePrometheusMetrics,
167168
IsLatencyMetricsEnabled: *enableLatencyMetrics,
168169
IsTLSPassthroughEnabled: *enableTLSPassthrough,
170+
TLSPassthroughPort: *tlsPassthroughPort,
169171
SnippetsEnabled: *enableSnippets,
170172
CertManagerEnabled: *enableCertManager,
171173
ExternalDNSEnabled: *enableExternalDNS,
@@ -459,6 +461,10 @@ func createGlobalConfigurationValidator() *cr_validation.GlobalConfigurationVali
459461
forbiddenListenerPorts[*serviceInsightListenPort] = true
460462
}
461463

464+
if *enableTLSPassthrough {
465+
forbiddenListenerPorts[*tlsPassthroughPort] = true
466+
}
467+
462468
return cr_validation.NewGlobalConfigurationValidator(forbiddenListenerPorts)
463469
}
464470

deployments/helm-chart/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ The following tables lists the configurable parameters of the NGINX Ingress Cont
251251
|`controller.enableCustomResources` | Enable the custom resources. | true |
252252
|`controller.enablePreviewPolicies` | Enable preview policies. This parameter is deprecated. To enable OIDC Policies please use `controller.enableOIDC` instead. | false |
253253
|`controller.enableOIDC` | Enable OIDC policies. | false |
254-
|`controller.enableTLSPassthrough` | Enable TLS Passthrough on port 443. Requires `controller.enableCustomResources`. | false |
254+
|`controller.enableTLSPassthrough` | Enable TLS Passthrough on default port 443. Requires `controller.enableCustomResources`. | false |
255+
|`controller.tlsPassThroughPort` | Set the port for the TLS Passthrough. Requires `controller.enableCustomResources` and `controller.enableTLSPassthrough`. | 443 |
255256
|`controller.enableCertManager` | Enable x509 automated certificate management for VirtualServer resources using cert-manager (cert-manager.io). Requires `controller.enableCustomResources`. | false |
256257
|`controller.enableExternalDNS` | Enable integration with ExternalDNS for configuring public DNS entries for VirtualServer resources using [ExternalDNS](https://github.com/kubernetes-sigs/external-dns). Requires `controller.enableCustomResources`. | false |
257258
|`controller.globalConfiguration.create` | Creates the GlobalConfiguration custom resource. Requires `controller.enableCustomResources`. | false |

deployments/helm-chart/templates/controller-daemonset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ spec:
228228
- -disable-ipv6={{ .Values.controller.disableIPV6 }}
229229
{{- if .Values.controller.enableCustomResources }}
230230
- -enable-tls-passthrough={{ .Values.controller.enableTLSPassthrough }}
231+
{{ if .Values.controller.enableTLSPassthrough }}
232+
- -tls-passthrough-port={{ .Values.controller.tlsPassthroughPort }}
233+
{{ end }}
231234
- -enable-preview-policies={{ .Values.controller.enablePreviewPolicies }}
232235
- -enable-cert-manager={{ .Values.controller.enableCertManager }}
233236
- -enable-oidc={{ .Values.controller.enableOIDC }}

deployments/helm-chart/templates/controller-deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ spec:
233233
- -disable-ipv6={{ .Values.controller.disableIPV6 }}
234234
{{- if .Values.controller.enableCustomResources }}
235235
- -enable-tls-passthrough={{ .Values.controller.enableTLSPassthrough }}
236+
{{ if .Values.controller.enableTLSPassthrough }}
237+
- -tls-passthrough-port={{ .Values.controller.tlsPassthroughPort }}
238+
{{ end }}
236239
- -enable-preview-policies={{ .Values.controller.enablePreviewPolicies }}
237240
- -enable-cert-manager={{ .Values.controller.enableCertManager }}
238241
- -enable-oidc={{ .Values.controller.enableOIDC }}

deployments/helm-chart/values.schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,14 @@
619619
false
620620
]
621621
},
622+
"tlsPassthroughPort": {
623+
"type": "integer",
624+
"default": 443,
625+
"title": "The tlsPassthroughPort",
626+
"examples": [
627+
443
628+
]
629+
},
622630
"enableCertManager": {
623631
"type": "boolean",
624632
"default": false,
@@ -1332,6 +1340,7 @@
13321340
"enableOIDC": false,
13331341
"includeYear": false,
13341342
"enableTLSPassthrough": false,
1343+
"tlsPassthroughPort": 443,
13351344
"enableCertManager": false,
13361345
"enableExternalDNS": false,
13371346
"globalConfiguration": {

deployments/helm-chart/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ controller:
239239
## Enable TLS Passthrough on port 443. Requires controller.enableCustomResources.
240240
enableTLSPassthrough: false
241241

242+
## Set the port for TLS Passthrough. Requires controller.enableCustomResources and controller.enableTLSPassthrough.
243+
tlsPassthroughPort: 443
244+
242245
## Enable cert manager for Virtual Server resources. Requires controller.enableCustomResources.
243246
enableCertManager: false
244247

docs/content/configuration/global-configuration/command-line-arguments.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ See [-report-ingress-status](#cmdoption-report-ingress-status) flag.
9494

9595
Enable TLS Passthrough on port 443.
9696

97+
Requires [-enable-custom-resources](#cmdoption-enable-custom-resources).
98+
&nbsp;
99+
<a name="cmdoption-tls-passthrough-port"></a>
100+
101+
### -tls-passthrough-port `<int>`
102+
103+
Set the port for TLS Passthrough.
104+
Format: `[1024 - 65535]` (default `443`)
105+
97106
Requires [-enable-custom-resources](#cmdoption-enable-custom-resources).
98107
&nbsp;
99108
<a name="cmdoption-enable-cert-manager"></a>

docs/content/installation/installation-with-helm.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ The following tables lists the configurable parameters of the NGINX Ingress Cont
228228
|`controller.enableCustomResources` | Enable the custom resources. | true |
229229
|`controller.enablePreviewPolicies` | Enable preview policies. This parameter is deprecated. To enable OIDC Policies please use `controller.enableOIDC` instead. | false |
230230
|`controller.enableOIDC` | Enable OIDC policies. | false |
231-
|`controller.enableTLSPassthrough` | Enable TLS Passthrough on port 443. Requires `controller.enableCustomResources`. | false |
231+
|`controller.enableTLSPassthrough` | Enable TLS Passthrough on default port 443. Requires `controller.enableCustomResources`. | false |
232+
|`controller.tlsPassThroughPort` | Set the port for the TLS Passthrough. Requires `controller.enableCustomResources` and `controller.enableTLSPassthrough`. | 443 |
232233
|`controller.enableCertManager` | Enable x509 automated certificate management for VirtualServer resources using cert-manager (cert-manager.io). Requires `controller.enableCustomResources`. | false |
233234
|`controller.enableExternalDNS` | Enable integration with ExternalDNS for configuring public DNS entries for VirtualServer resources using [ExternalDNS](https://github.com/kubernetes-sigs/external-dns). Requires `controller.enableCustomResources`. | false |
234235
|`controller.globalConfiguration.create` | Creates the GlobalConfiguration custom resource. Requires `controller.enableCustomResources`. | false |

examples/custom-resources/tls-passthrough/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ You can see how the Secure App is implemented in the `secure-app.yaml` file.
3434
and
3535
[`-enable-tls-passthrough`](https://docs.nginx.com/nginx-ingress-controller/configuration/global-configuration/command-line-arguments/#cmdoption-enable-tls-passthrough)
3636
command-line arguments of the Ingress Controller to enable the TLS Passthrough feature.
37+
- If you would like to use any other port than 443 for TLS Passthrough, set
38+
the [`-tls-passthrough-port`](https://docs.nginx.com/nginx-ingress-controller/configuration/global-configuration/command-line-arguments/#cmdoption-tls-passthrough-port)
39+
command-line argument of the Ingress Controller, and configure the load balancer to forward traffic to that port.
40+
3741
1. Save the public IP address of the Ingress Controller into a shell variable:
3842

3943
```console
4044
IC_IP=XXX.YYY.ZZZ.III
4145
```
4246

47+
1. Save the HTTPS port of the Ingress Controller where TLS Passthrough is enabled into a shell variable:
48+
49+
```console
50+
$ IC_HTTPS_PORT=<port number>
51+
4352
1. Save the HTTPS port of the Ingress Controller into a shell variable:
4453

4554
```console

0 commit comments

Comments
 (0)