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

TLS: allow support for different protocols on different hosts #67

Merged
Merged
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
2 changes: 1 addition & 1 deletion internal/ingress/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
}

hosts, servers, pcfg := n.getConfiguration(ings)

n.metricCollector.SetSSLExpireTime(servers)

if n.runningConfig.Equal(pcfg) {
Expand Down Expand Up @@ -228,7 +229,6 @@ func (n *NGINXController) syncIngress(interface{}) error {
// CheckIngress returns an error in case the provided ingress, when added
// to the current configuration, generates an invalid configuration
func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
//TODO: this is wrong
if n == nil {
return fmt.Errorf("cannot check ingress on a nil ingress controller")
}
Expand Down
12 changes: 6 additions & 6 deletions internal/ingress/controller/hotreload.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2022 The Alibaba Authors.
Copyright 2022-2023 The Alibaba Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -232,7 +232,7 @@ func createHotCfg(cfg ngx_config.Configuration, ingressCfg ingress.Configuration
if upsService == nil {
continue
}
service := createVirtualService(loc.Backend, loc, pathServiceName)
service := createVirtualService(cfg, loc.Backend, loc, pathServiceName, server)
path := &route.PathRouter{
Path: loc.Path,
ServiceName: pathServiceName,
Expand All @@ -251,7 +251,7 @@ func createHotCfg(cfg ngx_config.Configuration, ingressCfg ingress.Configuration
tagRouter := &route.TagRouter{}
policy := canary.TrafficShapingPolicy
if len(policy.Header) > 0 {
canaryService, tagRouter = createHeaderCanary(i, server, loc, canary)
canaryService, tagRouter = createHeaderCanary(cfg, i, server, loc, canary)
tags = append(tags, tagRouter)
services = append(services, canaryService)
} else if policy.Weight > 0 {
Expand Down Expand Up @@ -289,7 +289,7 @@ func createHotCfg(cfg ngx_config.Configuration, ingressCfg ingress.Configuration
}
}

func createVirtualService(target string, loc *ingress.Location, serviceName string) *route.VirtualService {
func createVirtualService(cfg ngx_config.Configuration, target string, loc *ingress.Location, serviceName string, server *ingress.Server) *route.VirtualService {
upstream := &route.Upstream{
Target: target,
Weight: DefaultTotalWeightTraffic,
Expand All @@ -306,7 +306,7 @@ func createVirtualService(target string, loc *ingress.Location, serviceName stri
},
TimeoutMs: timeout,
ForceHttps: loc.Rewrite.SSLRedirect,
Metadata: createMetaData(loc),
Metadata: createMetaData(server, loc),
}

return service
Expand Down Expand Up @@ -380,7 +380,7 @@ func createMetaData(server *ingress.Server, loc *ingress.Location) []*route.Meta
}
}

func createHeaderCanary(seq int, server *ingress.Server, loc *ingress.Location, canary *ingress.Canary) (*route.VirtualService, *route.TagRouter) {
func createHeaderCanary(cfg ngx_config.Configuration, seq int, server *ingress.Server, loc *ingress.Location, canary *ingress.Canary) (*route.VirtualService, *route.TagRouter) {
canaryService := &route.VirtualService{}
tagRouter := &route.TagRouter{}
policy := canary.TrafficShapingPolicy
Expand Down