Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6b03fdd02 | |||
| 1018e24060 | |||
| ebef6e138d | |||
| 7bd8f754d8 |
@@ -2,12 +2,9 @@ package consul
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ego.cloudns.be/egommerce/go-api-pkg/config"
|
|
||||||
consul "github.com/hashicorp/consul/api"
|
consul "github.com/hashicorp/consul/api"
|
||||||
"github.com/hashicorp/consul/connect"
|
"github.com/hashicorp/consul/connect"
|
||||||
)
|
)
|
||||||
@@ -61,7 +58,6 @@ func NewService(servAddr, id, name, useDomainOverIp, addr, domain, pathPrefix st
|
|||||||
|
|
||||||
func newClientConfig(serverAddr string) *consul.Config {
|
func newClientConfig(serverAddr string) *consul.Config {
|
||||||
conf := consul.DefaultConfig()
|
conf := consul.DefaultConfig()
|
||||||
log.Printf("Setting consul server addr: %s", serverAddr)
|
|
||||||
conf.Address = serverAddr
|
conf.Address = serverAddr
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
@@ -129,7 +125,7 @@ func (s *Service) RegisterHealthChecks() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() { // TTL
|
go func() { // TTL
|
||||||
t := time.NewTicker(s.ttl)
|
t := time.NewTicker(time.Second * 5)
|
||||||
for range t.C {
|
for range t.C {
|
||||||
if _, err := s.healthCheck(); err != nil {
|
if _, err := s.healthCheck(); err != nil {
|
||||||
// fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
// fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
||||||
@@ -197,29 +193,29 @@ func (s *Service) healthCheck() (bool, error) {
|
|||||||
|
|
||||||
func (s *Service) getTags() []string {
|
func (s *Service) getTags() []string {
|
||||||
tags := []string{
|
tags := []string{
|
||||||
"traefik.enable=true",
|
// "traefik.enable=true",
|
||||||
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.trustForwardHeader=true",
|
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.trustForwardHeader=true",
|
||||||
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authRequestHeaders=Cookie",
|
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authRequestHeaders=Cookie",
|
||||||
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authResponseHeaders=Set-Cookie, Server",
|
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authResponseHeaders=Set-Cookie, Server",
|
||||||
"traefik.http.middlewares.auth_" + s.Name + ".plugin.auth.handlerURL=" + config.GetEnv("AUTH_HANDLER_URL", "https://identity.service.ego.io/api/v1/traefik"),
|
// "traefik.http.middlewares.auth_" + s.Name + ".plugin.auth.handlerURL=" + config.GetEnv("AUTH_HANDLER_URL", "https://identity.service.ego.io/api/v1/traefik"),
|
||||||
"traefik.http.middlewares.stripprefix_" + s.Name + ".stripprefix.prefixes=" + s.pathPrefix,
|
// "traefik.http.middlewares.stripprefix_" + s.Name + ".stripprefix.prefixes=" + s.pathPrefix,
|
||||||
"traefik.http.middlewares.requestid_" + s.Name + ".plugin.requestid.headerName=X-Request-ID",
|
// "traefik.http.middlewares.requestid_" + s.Name + ".plugin.requestid.headerName=X-Request-ID",
|
||||||
// "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=Host(`" + s.domain + "`) && PathPrefix(`" + s.pathPrefix + "`)",
|
// "traefik.http.routers." + s.Name + ".rule=Host(`" + s.domain + "`) && PathPrefix(`" + s.pathPrefix + "`)",
|
||||||
"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 + "",
|
||||||
"traefik.http.services." + s.Name + ".loadbalancer.server.scheme=https",
|
// "traefik.http.services." + s.Name + ".loadbalancer.server.scheme=https",
|
||||||
"traefik.http.services." + s.Name + ".loadbalancer.server.port=" + strconv.Itoa(s.port),
|
// "traefik.http.services." + s.Name + ".loadbalancer.server.port=" + strconv.Itoa(s.port),
|
||||||
"traefik.http.services." + s.Name + ".loadbalancer.passhostheader=true",
|
// "traefik.http.services." + s.Name + ".loadbalancer.passhostheader=true",
|
||||||
"traefik.http.services." + s.Name + ".loadbalancer.healthcheck.interval=5s",
|
// "traefik.http.services." + s.Name + ".loadbalancer.healthcheck.interval=5s",
|
||||||
"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.crt",
|
// "traefik.tls.certificates.certfile=certs/client.crt",
|
||||||
"traefik.tls.certificates.keyfile=certs/client.key",
|
// "traefik.tls.certificates.keyfile=certs/client.key",
|
||||||
}
|
}
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
|
|||||||
Reference in New Issue
Block a user