Skip to content

Commit

Permalink
Merge pull request #39 from superfly/tim-nofilter
Browse files Browse the repository at this point in the history
disable path filtering but keep logging
log all path violations, with user agent.
make path filtering configurable, and disable it for now.
add more allowed paths.
  • Loading branch information
timflyio authored Jul 23, 2024
2 parents 7101c24 + baf6de6 commit 8d37d90
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dockerproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
noAuth = os.Getenv("NO_AUTH") == "1"
noAppName = os.Getenv("NO_APP_NAME") == "1"
noHttps = os.Getenv("NO_HTTPS") == "1"
noFilter = true

// build variables
gitSha string
Expand All @@ -58,6 +59,8 @@ var allowedPaths = []*regexp.Regexp{
regexp.MustCompile("^/flyio/.*$"),
regexp.MustCompile("^/grpc$"),
regexp.MustCompile("^/_ping$"),
regexp.MustCompile("^(/v[0-9.]*)?/version$"),
regexp.MustCompile("^(/v[0-9.]*)?/volumes/.*$"),
regexp.MustCompile("^(/v[0-9.]*)?/info$"),
regexp.MustCompile("^(/v[0-9.]*)?/images/.*$"),
}
Expand Down Expand Up @@ -273,9 +276,11 @@ func dockerProxy() http.Handler {
}
}
if !allowed {
log.Warnf("Refusing to proxy %s", r.URL)
http.Error(w, `{"message":"page not found"}`, http.StatusNotFound)
return
log.Warnf("Invalid path path=%s agent=%q", r.URL, r.UserAgent())
if !noFilter {
http.Error(w, `{"message":"page not found"}`, http.StatusNotFound)
return
}
}

reverseProxy.ServeHTTP(w, r)
Expand Down

0 comments on commit 8d37d90

Please sign in to comment.