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

traefik compatibility #39

Open
franklaich opened this issue Jul 17, 2024 · 0 comments
Open

traefik compatibility #39

franklaich opened this issue Jul 17, 2024 · 0 comments

Comments

@franklaich
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant