Skip to content

Adding excludeHosts config option allowing for host based exclusions#3

Open
WolverinDEV wants to merge 2 commits intoDesuuuu:masterfrom
WolverinDEV:master
Open

Adding excludeHosts config option allowing for host based exclusions#3
WolverinDEV wants to merge 2 commits intoDesuuuu:masterfrom
WolverinDEV:master

Conversation

@WolverinDEV
Copy link

This PR introduces a new excludeHosts configuration option.
This option allows specific hostnames to bypass the Cloudflare origination check.

By enabling host-based exclusions, this change makes it possible to register the plugin globally as a middleware on an entrypoint while still permitting certain non-proxied domains to operate normally. This avoids the need to attach the middleware individually for each router or domain, greatly simplifying setups that mix Cloudflare-proxied and non-proxied hosts.

Key benefits:

  • Cleaner and more maintainable configuration
  • Reduced duplication in Traefik router definitions
  • Seamless handling of mixed proxy/non-proxy environments

AI Disclaimer:
- All code changes have been made without the use of AI or AI based tools.
- AI-based text tools were used only to improve sentence structure, grammar, and spelling.

Copy link
Owner

@Desuuuu Desuuuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, the feature looks fine to me!

Could you have a look at my two comments?

return nil
}

func getHost(req *http.Request) string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense for this function to behave in a similar way as Traefik does internally.

Here's the relevant code: https://github.com/traefik/traefik/blob/master/pkg/middlewares/requestdecorator/request_decorator.go#L38

In short, they call the parseHost function, then strings.TrimSpace and strings.ToLower (see here).

TrustedCIDRs []string `json:"trustedCIDRs,omitempty"`
RefreshInterval string `json:"refreshInterval,omitempty"`
OverwriteForwardedFor bool `json:"overwriteForwardedFor,omitempty"`
ExcludeHosts []string `json:"excludeHosts,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming the field/option ExcludedHosts/excludedHosts would be more consistent.

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

Successfully merging this pull request may close these issues.

2 participants