Skip to content

Commit

Permalink
Handle the proxy headers
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jun 11, 2024
1 parent 6c10662 commit 0628026
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/crproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
)

var (
behind bool
address string
userpass []string
disableKeepAlives []string
Expand All @@ -41,6 +42,7 @@ var (
)

func init() {
pflag.BoolVar(&behind, "behind", false, "Behind the reverse proxy")
pflag.StringSliceVarP(&userpass, "user", "u", nil, "host and username and password -u user:pwd@host")
pflag.StringVarP(&address, "address", "a", ":8080", "listen on the address")
pflag.StringSliceVar(&disableKeepAlives, "disable-keep-alives", nil, "disable keep alives for the host")
Expand Down Expand Up @@ -189,11 +191,17 @@ func main() {
}

mux.Handle("/v2/", crp)

var handler http.Handler = mux
handler = handlers.LoggingHandler(os.Stderr, handler)
if behind {
handler = handlers.ProxyHeaders(handler)
}
server := http.Server{
BaseContext: func(listener net.Listener) context.Context {
return ctx
},
Handler: handlers.LoggingHandler(os.Stderr, mux),
Handler: handler,
Addr: address,
}

Expand Down

0 comments on commit 0628026

Please sign in to comment.