Compare commits

...

6 Commits

Author SHA1 Message Date
c052904266 Route fix 2022-12-24 17:50:29 +01:00
73447dfa80 Route fix 2022-12-24 17:45:56 +01:00
ebb1eab10b DEBUG change 2022-12-24 17:25:41 +01:00
cb5933ccf0 DEBUG change 2022-12-24 17:10:47 +01:00
e6bec060db DEBUG change 2022-12-24 16:43:19 +01:00
4daefbe1c7 DEBUG change 2022-12-24 16:40:31 +01:00

View File

@@ -14,6 +14,7 @@ type Service struct {
Address string
appID string
domain string
pathPrefix string
port int
ttl time.Duration
agent *consul.Agent
@@ -22,12 +23,13 @@ type Service struct {
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
func NewService(servAddr, id, name, hostname, domain string, appPort int) (*Service, error) {
func NewService(servAddr, id, name, hostname, domain, pathPrefix string, appPort int) (*Service, error) {
s := new(Service)
s.Name = name
s.Address = hostname
s.appID = id
s.domain = domain
s.pathPrefix = pathPrefix
s.port = appPort
s.ttl = time.Second * 15
@@ -140,16 +142,16 @@ func (s *Service) getTags() []string {
tags := []string{
"traefik.enable=true",
// "traefik.http.routers." + s.Name + ".rule=Header(`X-API-SERVICE`, `" + s.Name + "`)",
"traefik.http.routers." + s.Name + ".rule=PathPrefix(`/catalog`)",
"traefik.http.routers." + s.Name + ".rule=PathPrefix(`" + s.pathPrefix + "`)",
"traefik.http.routers." + s.Name + ".entryPoints=https",
"traefik.http.routers." + s.Name + ".tls=true",
"traefik.http.routers." + s.Name + ".service=" + s.Name,
"traefik.http.routers." + s.Name + ".middlewares=requestid,compress,stripPrefix",
"traefik.http.routers." + s.Name + ".middlewares=requestid,compress,stripprefix",
"traefik.http.services." + s.Name + ".loadbalancer.server.scheme=http",
"traefik.http.services." + s.Name + ".loadbalancer.server.port=" + strconv.Itoa(s.port),
"traefik.http.services." + s.Name + ".loadbalancer.passhostheader=false",
"traefik.http.middlewares.requestid.plugin.requestid.headerName=X-Request-ID",
"traefik.http.middlewares.stripPrefix.stripprefix.prefixes=/foobar"
"traefik.http.middlewares.stripprefix.stripprefix.prefixes=" + s.pathPrefix,
"traefik.http.middlewares.compress.compress=true",
// "traefik.http.middlewares.cors.headers.accesscontrolallowmethods=*",
// "traefik.http.middlewares.cors.headers.accesscontrolalloworiginlist=*",