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

add Header proxy policy #1751

merged 1 commit into from Jul 10, 2017


3 participants

zikes commented Jul 7, 2017

1. What does this change do, exactly?

Add a new proxy policy which routes to upstream based on the hash of a given request header's value.


proxy {
  policy header My-Header

This also changes the Policy registration process to allow policies to receive a single optional string argument.

2. Please link to the relevant issues.


3. Which documentation changes (if any) need to be made because of this PR?

The new policy would need added at

4. Checklist

  • I have written tests and verified that they fail without my change
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I am willing to help maintain this change if there are issues with it later
@@ -22,7 +22,7 @@ import (

var (
supportedPolicies = make(map[string]func() Policy)
supportedPolicies = make(map[string]func(string) Policy)

This comment has been minimized.


abiosoft Jul 7, 2017


Or maybe func(args ...string) Policy to make it dynamic in case of any future policy that may require more than one args.

This comment has been minimized.


zikes Jul 7, 2017


Per @mholt's recommendation in #1463 it's just string, but changing it to ...string would be fairly trivial.

This comment has been minimized.


mholt Jul 10, 2017


This is fine, I'm rewriting this part of the proxy middleware now and will take it into account.


mholt approved these changes Jul 10, 2017

This'll work. Thanks for taking care of this, @zikes!

@mholt mholt merged commit 4c700ef into mholt:master Jul 10, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
license/cla Contributor License Agreement is signed.

@mholt mholt modified the milestone: 0.10.5 Jul 10, 2017


This comment has been minimized.


zikes commented Jul 10, 2017

I'll try to submit a PR to caddyserver/website soon to update the documentation for this.

@zikes zikes deleted the zikes:header_policy branch Jul 10, 2017


This comment has been minimized.


mholt commented Jul 10, 2017

Perfect, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment