@@ -377,7 +377,7 @@ func buildHTTPListener(t interface{}, s interface{}) string {
377377 return strings .Join (out , "\n " )
378378}
379379
380- func buildHTTPSListener (t interface {}, s interface {}) string {
380+ func buildHTTPSListener (p interface {}, t interface {}, s interface {}) string {
381381 var out []string
382382
383383 tc , ok := t .(config.TemplateConfig )
@@ -392,14 +392,20 @@ func buildHTTPSListener(t interface{}, s interface{}) string {
392392 return ""
393393 }
394394
395+ port , ok := p .(int )
396+ if ! ok {
397+ klog .Errorf ("expected a 'int' type but %T was returned" , p )
398+ return ""
399+ }
400+
395401 co := commonListenOptions (tc , hostname )
396402
397403 addrV4 := []string {"" }
398404 if len (tc .Cfg .BindAddressIpv4 ) > 0 {
399405 addrV4 = tc .Cfg .BindAddressIpv4
400406 }
401407
402- out = append (out , httpsListener (addrV4 , co , tc )... )
408+ out = append (out , httpsListener (addrV4 , co , tc , port )... )
403409
404410 if ! tc .IsIPV6Enabled {
405411 return strings .Join (out , "\n " )
@@ -410,18 +416,14 @@ func buildHTTPSListener(t interface{}, s interface{}) string {
410416 addrV6 = tc .Cfg .BindAddressIpv6
411417 }
412418
413- out = append (out , httpsListener (addrV6 , co , tc )... )
419+ out = append (out , httpsListener (addrV6 , co , tc , port )... )
414420
415421 return strings .Join (out , "\n " )
416422}
417423
418424func commonListenOptions (template config.TemplateConfig , hostname string ) string {
419425 var out []string
420426
421- if template .Cfg .UseProxyProtocol {
422- out = append (out , "proxy_protocol" )
423- }
424-
425427 if hostname != "_" {
426428 return strings .Join (out , " " )
427429 }
@@ -452,7 +454,6 @@ func httpListener(addresses []string, co string, tc config.TemplateConfig) []str
452454 }
453455
454456 lo = append (lo , co )
455- lo = append (lo , ";" )
456457 return lo
457458 }
458459
@@ -469,28 +470,16 @@ func httpListener(addresses []string, co string, tc config.TemplateConfig) []str
469470 return out
470471}
471472
472- func httpsListener (addresses []string , co string , tc config.TemplateConfig ) []string {
473+ func httpsListener (addresses []string , co string , tc config.TemplateConfig , port int ) []string {
473474 out := make ([]string , 0 )
474475
475476 fn := func (address string ) []string {
476477 lo := []string {"listen" }
477478
478- if tc .IsSSLPassthroughEnabled {
479- if address == "" {
480- lo = append (lo , fmt .Sprintf ("%v" , tc .ListenPorts .SSLProxy ))
481- } else {
482- lo = append (lo , fmt .Sprintf ("%v:%v" , address , tc .ListenPorts .SSLProxy ))
483- }
484-
485- if ! strings .Contains (co , "proxy_protocol" ) {
486- lo = append (lo , "proxy_protocol" )
487- }
479+ if address == "" {
480+ lo = append (lo , fmt .Sprintf ("%v" , port ))
488481 } else {
489- if address == "" {
490- lo = append (lo , fmt .Sprintf ("%v" , tc .ListenPorts .HTTPS ))
491- } else {
492- lo = append (lo , fmt .Sprintf ("%v:%v" , address , tc .ListenPorts .HTTPS ))
493- }
482+ lo = append (lo , fmt .Sprintf ("%v:%v" , address , port ))
494483 }
495484
496485 lo = append (lo , co )
@@ -500,7 +489,6 @@ func httpsListener(addresses []string, co string, tc config.TemplateConfig) []st
500489 lo = append (lo , "http2" )
501490 }
502491
503- lo = append (lo , ";" )
504492 return lo
505493 }
506494
0 commit comments