Skip to content

traefik compatibility #39

@franklaich

Description

@franklaich

hi,

I wanted to switch from nginx to traefik as proxy to forward to clammit.
therefor i was looking how to set the X-Clammit-Backend with the given traefik possibilities.

I did not find any solution suitable for my needs.

my solution now is to patch your forwarder.go:

func (f *Forwarder) getApplicationURL(req *http.Request) *url.URL {
		 // Return the applicationURL if it's set
		 if f.applicationURL != nil && f.applicationURL.String() != "" {
				 return f.applicationURL
		 }
 
		 // Otherwise check for the X-Clammit-Backend header
		 url, err := url.Parse(req.Header.Get(applicationUrlHeader))
		 if err != nil {
				 f.logger.Panicf("Error parsing application URL in %s: %s (%s)", applicationUrlHeader, err.Error(), req.Header.Get(applicationUrlHeader))
				 return nil
		 }
 
		 if len(url.String()) == 0 {
				 **f.logger.Print("No application URL available - header %s is blank", applicationUrlHeader)
				 // patch by Top21
				 f.logger.Print("Try to build from X-Forwarded-")
				 url,err = url.Parse(req.Header.Get("X-Forwarded-Proto") + "://" + req.Header.Get("X-Forwarded-Host"))**
		 }
 
		 return url
 }

maybe this is helpful for others too and you can implement it somehow in the main code.

cheers,

frank

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions