Compare commits

...

6 Commits

Author SHA1 Message Date
974f82e9be debug fix 2024-07-20 15:53:05 +02:00
d7dc75c18f debug fix 2024-07-20 15:45:49 +02:00
c62c63249c debug fix 2024-07-20 14:44:45 +02:00
6c290eb66b tls fix 2024-07-20 14:43:47 +02:00
31ce7fc48e tls fix 2024-07-20 14:42:16 +02:00
99957861dc fix ssl support 2024-07-20 14:24:38 +02:00

View File

@@ -17,6 +17,7 @@ type Service struct {
appID string appID string
domain string domain string
pathPrefix string pathPrefix string
tls bool
port int port int
ttl time.Duration ttl time.Duration
client *consul.Client client *consul.Client
@@ -37,6 +38,7 @@ func NewService(servAddr, id, name, useDomainOverIp, addr, domain, pathPrefix st
s.appID = id s.appID = id
s.domain = domain s.domain = domain
s.pathPrefix = pathPrefix s.pathPrefix = pathPrefix
s.tls = true // FIXME add arg
s.port = appPort s.port = appPort
s.ttl = time.Second * 10 s.ttl = time.Second * 10
@@ -68,12 +70,11 @@ func (s *Service) GetID() string {
} }
func (s *Service) GetFullAddr() string { func (s *Service) GetFullAddr() string {
isTLS := s.port == 443
proto := "http" proto := "http"
if isTLS { if s.tls {
proto = "https" proto = "https"
} }
return fmt.Sprintf("%s://%s:%d/", proto, s.Address, s.port) return fmt.Sprintf("%s://%s:%d/", proto, s.domain, s.port)
} }
func (s *Service) Register() error { func (s *Service) Register() error {
@@ -203,9 +204,9 @@ func (s *Service) getTags() []string {
// "treafik.http.middlewares.retryif_" + s.Name + ".plugin.retryif.attempts=3", // "treafik.http.middlewares.retryif_" + s.Name + ".plugin.retryif.attempts=3",
// "treafik.http.middlewares.retryif_" + s.Name + ".plugin.retryif.statusCode=503", // "treafik.http.middlewares.retryif_" + s.Name + ".plugin.retryif.statusCode=503",
"traefik.http.routers." + s.Name + ".rule=PathPrefix(`" + s.pathPrefix + "`)", "traefik.http.routers." + s.Name + ".rule=PathPrefix(`" + s.pathPrefix + "`)",
// "traefik.http.routers." + s.Name + ".rule=Host(`" + s.domain + "`)", "traefik.http.routers." + s.Name + ".rule=Host(`" + s.domain + "`)",
"traefik.http.routers." + s.Name + ".entryPoints=https", "traefik.http.routers." + s.Name + ".entryPoints=https",
// "traefik.http.routers." + s.Name + ".tls=true", "traefik.http.routers." + s.Name + ".tls=true",
"traefik.http.routers." + s.Name + ".service=" + s.Name, "traefik.http.routers." + s.Name + ".service=" + s.Name,
// "traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",stripprefix_" + s.Name, // "traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",stripprefix_" + s.Name,
"traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",stripprefix_" + s.Name + ",requestid_" + s.Name + "", "traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",stripprefix_" + s.Name + ",requestid_" + s.Name + "",
@@ -215,8 +216,8 @@ func (s *Service) getTags() []string {
"traefik.http.services." + s.Name + ".loadbalancer.healthcheck.interval=1s", "traefik.http.services." + s.Name + ".loadbalancer.healthcheck.interval=1s",
"traefik.http.services." + s.Name + ".loadbalancer.healthcheck.timeout=1s", "traefik.http.services." + s.Name + ".loadbalancer.healthcheck.timeout=1s",
"traefik.http.services." + s.Name + ".loadbalancer.healthcheck.path=/health", "traefik.http.services." + s.Name + ".loadbalancer.healthcheck.path=/health",
"traefik.tls.certificates.certfile=/certs/client.cert", "traefik.tls.certificates.certfile=certs/client.cert",
"traefik.tls.certificates.keyfile=/certs/client.key", "traefik.tls.certificates.keyfile=certs/client.key",
} }
return tags return tags