@@ -46,6 +46,7 @@ import (
46
46
"k8s.io/ingress-nginx/internal/k8s"
47
47
"k8s.io/ingress-nginx/internal/nginx"
48
48
"k8s.io/ingress-nginx/pkg/apis/ingress"
49
+ "k8s.io/ingress-nginx/pkg/tcpproxy"
49
50
utilingress "k8s.io/ingress-nginx/pkg/util/ingress"
50
51
"k8s.io/klog/v2"
51
52
)
@@ -185,6 +186,44 @@ func (n *NGINXController) syncIngress(interface{}) error {
185
186
n .metricCollector .SetSSLExpireTime (servers )
186
187
n .metricCollector .SetSSLInfo (servers )
187
188
189
+ if n .cfg .EnableSSLPassthrough {
190
+ servers := []* tcpproxy.TCPServer {}
191
+ for _ , pb := range pcfg .PassthroughBackends {
192
+ svc := pb .Service
193
+ if svc == nil {
194
+ klog .Warningf ("Missing Service for SSL Passthrough backend %q" , pb .Backend )
195
+ continue
196
+ }
197
+ port , err := strconv .Atoi (pb .Port .String ()) // #nosec
198
+ if err != nil {
199
+ for _ , sp := range svc .Spec .Ports {
200
+ if sp .Name == pb .Port .String () {
201
+ port = int (sp .Port )
202
+ break
203
+ }
204
+ }
205
+ } else {
206
+ for _ , sp := range svc .Spec .Ports {
207
+ //nolint:gosec // Ignore G109 error
208
+ if sp .Port == int32 (port ) {
209
+ port = int (sp .Port )
210
+ break
211
+ }
212
+ }
213
+ }
214
+
215
+ // TODO: Allow PassthroughBackends to specify they support proxy-protocol
216
+ servers = append (servers , & tcpproxy.TCPServer {
217
+ Hostname : pb .Hostname ,
218
+ IP : svc .Spec .ClusterIP ,
219
+ Port : port ,
220
+ ProxyProtocol : false ,
221
+ })
222
+ }
223
+
224
+ n .Proxy .ServerList = servers
225
+ }
226
+
188
227
if n .runningConfig .Equal (pcfg ) {
189
228
klog .V (3 ).Infof ("No configuration change detected, skipping backend reload" )
190
229
return nil
0 commit comments