-
Notifications
You must be signed in to change notification settings - Fork 621
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
Issue #548 added enable/disable glob matching #550
Changes from 5 commits
062a8ea
054be87
eda6cf4
ea75fb8
1eb2e36
da67268
8920153
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,4 +77,5 @@ var defaultConfig = &Config{ | |
Color: "light-green", | ||
Access: "rw", | ||
}, | ||
DisableGlobMatching: false, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: "glob.matching.disabled" | ||
--- | ||
|
||
`glob.matching.disabled` Disables glob matching on route lookups. | ||
|
||
Valid options are `true`, `false` | ||
|
||
The default is | ||
|
||
glob.matching.disabled = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -743,6 +743,17 @@ | |
# registry.consul.checksRequired = one | ||
|
||
|
||
# glob.matching.disabled Disables glob matching on route lookups | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/Disables/disables/ |
||
# If glob matching is enabled there is a performance decrease | ||
# for every route lookup. At a large number of services (> 500) this | ||
# can have a significant impact on performance. If glob matching is disabled | ||
# Fabio performs a static string compare for route lookups. | ||
# | ||
# The default is | ||
# | ||
# glob.matching.disabled = false | ||
|
||
|
||
# metrics.target configures the backend the metrics values are | ||
# sent to. | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,7 @@ func main() { | |
|
||
func newHTTPProxy(cfg *config.Config) http.Handler { | ||
var w io.Writer | ||
globDisabled := cfg.DisableGlobMatching | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of the var? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed. I'll update. |
||
switch cfg.Log.AccessTarget { | ||
case "": | ||
log.Printf("[INFO] Access logging disabled") | ||
|
@@ -183,7 +184,7 @@ func newHTTPProxy(cfg *config.Config) http.Handler { | |
Transport: newTransport(nil), | ||
InsecureTransport: newTransport(&tls.Config{InsecureSkipVerify: true}), | ||
Lookup: func(r *http.Request) *route.Target { | ||
t := route.GetTable().Lookup(r, r.Header.Get("trace"), pick, match) | ||
t := route.GetTable().Lookup(r, r.Header.Get("trace"), pick, match, globDisabled) | ||
if t == nil { | ||
notFound.Inc(1) | ||
log.Print("[WARN] No route for ", r.Host, r.URL) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,6 +175,8 @@ func TestProxyNoRouteStatus(t *testing.T) { | |
} | ||
|
||
func TestProxyStripsPath(t *testing.T) { | ||
//Glob Matching True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you add this var to all tests you can also add some constants, e.g. const (
// helper constants for the Lookup function
globEnabled = false
globDisabled = true
) |
||
globDisabled := false | ||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
switch r.RequestURI { | ||
case "/bar": | ||
|
@@ -188,7 +190,7 @@ func TestProxyStripsPath(t *testing.T) { | |
Transport: http.DefaultTransport, | ||
Lookup: func(r *http.Request) *route.Target { | ||
tbl, _ := route.NewTable("route add mock /foo/bar " + server.URL + ` opts "strip=/foo"`) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"]) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"], globDisabled) | ||
}, | ||
}) | ||
defer proxy.Close() | ||
|
@@ -215,6 +217,7 @@ func TestProxyHost(t *testing.T) { | |
routes += "route add mock /hostcustom http://b.com/ opts \"host=bar.com\"\n" | ||
routes += "route add mock / http://a.com/" | ||
tbl, _ := route.NewTable(routes) | ||
globDisabled := false | ||
|
||
proxy := httptest.NewServer(&HTTPProxy{ | ||
Transport: &http.Transport{ | ||
|
@@ -224,7 +227,7 @@ func TestProxyHost(t *testing.T) { | |
}, | ||
}, | ||
Lookup: func(r *http.Request) *route.Target { | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"]) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"], globDisabled) | ||
}, | ||
}) | ||
defer proxy.Close() | ||
|
@@ -266,12 +269,13 @@ func TestHostRedirect(t *testing.T) { | |
routes := "route add https-redir *:80 https://$host$path opts \"redirect=301\"\n" | ||
|
||
tbl, _ := route.NewTable(routes) | ||
globDisabled := false | ||
|
||
proxy := httptest.NewServer(&HTTPProxy{ | ||
Transport: http.DefaultTransport, | ||
Lookup: func(r *http.Request) *route.Target { | ||
r.Host = "c.com" | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"]) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"], globDisabled) | ||
}, | ||
}) | ||
defer proxy.Close() | ||
|
@@ -306,11 +310,12 @@ func TestPathRedirect(t *testing.T) { | |
routes += "route add mock /foo http://a.com/abc opts \"redirect=301\"\n" | ||
routes += "route add mock /bar http://b.com/$path opts \"redirect=302 strip=/bar\"\n" | ||
tbl, _ := route.NewTable(routes) | ||
globDisabled := false | ||
|
||
proxy := httptest.NewServer(&HTTPProxy{ | ||
Transport: http.DefaultTransport, | ||
Lookup: func(r *http.Request) *route.Target { | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"]) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"], globDisabled) | ||
}, | ||
}) | ||
defer proxy.Close() | ||
|
@@ -472,13 +477,14 @@ func TestProxyHTTPSUpstream(t *testing.T) { | |
server.TLS = tlsServerConfig() | ||
server.StartTLS() | ||
defer server.Close() | ||
globDisabled := false | ||
|
||
proxy := httptest.NewServer(&HTTPProxy{ | ||
Config: config.Proxy{}, | ||
Transport: &http.Transport{TLSClientConfig: tlsClientConfig()}, | ||
Lookup: func(r *http.Request) *route.Target { | ||
tbl, _ := route.NewTable("route add srv / " + server.URL + ` opts "proto=https"`) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"]) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"], globDisabled) | ||
}, | ||
}) | ||
defer proxy.Close() | ||
|
@@ -497,6 +503,7 @@ func TestProxyHTTPSUpstreamSkipVerify(t *testing.T) { | |
server.TLS = &tls.Config{} | ||
server.StartTLS() | ||
defer server.Close() | ||
globDisabled := false | ||
|
||
proxy := httptest.NewServer(&HTTPProxy{ | ||
Config: config.Proxy{}, | ||
|
@@ -506,7 +513,7 @@ func TestProxyHTTPSUpstreamSkipVerify(t *testing.T) { | |
}, | ||
Lookup: func(r *http.Request) *route.Target { | ||
tbl, _ := route.NewTable("route add srv / " + server.URL + ` opts "proto=https tlsskipverify=true"`) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"]) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"], globDisabled) | ||
}, | ||
}) | ||
defer proxy.Close() | ||
|
@@ -699,6 +706,8 @@ func BenchmarkProxyLogger(b *testing.B) { | |
b.Fatal("logger.NewHTTPLogger:", err) | ||
} | ||
|
||
globDisabled := false | ||
|
||
proxy := &HTTPProxy{ | ||
Config: config.Proxy{ | ||
LocalIP: "1.1.1.1", | ||
|
@@ -707,7 +716,7 @@ func BenchmarkProxyLogger(b *testing.B) { | |
Transport: http.DefaultTransport, | ||
Lookup: func(r *http.Request) *route.Target { | ||
tbl, _ := route.NewTable("route add mock / " + server.URL) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"]) | ||
return tbl.Lookup(r, "", route.Picker["rr"], route.Matcher["prefix"], globDisabled) | ||
}, | ||
Logger: l, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the default so you can remove it.