mirror of
https://github.com/openziti/zrok.git
synced 2025-06-24 19:51:32 +02:00
zrok http listen logging improvements (#32)
This commit is contained in:
parent
7da2311c6c
commit
4d85dd26c3
@ -71,7 +71,6 @@ func NewServiceProxy(ctx ziti.Context) (*httputil.ReverseProxy, error) {
|
|||||||
director := proxy.Director
|
director := proxy.Director
|
||||||
proxy.Director = func(req *http.Request) {
|
proxy.Director = func(req *http.Request) {
|
||||||
director(req)
|
director(req)
|
||||||
logrus.Debugf("-> %v", req.URL.String())
|
|
||||||
req.Header.Set("X-Proxy", "zrok")
|
req.Header.Set("X-Proxy", "zrok")
|
||||||
}
|
}
|
||||||
proxy.ModifyResponse = func(resp *http.Response) error {
|
proxy.ModifyResponse = func(resp *http.Response) error {
|
||||||
@ -89,11 +88,13 @@ func hostTargetReverseProxy(ctx ziti.Context) *httputil.ReverseProxy {
|
|||||||
targetSvc := resolveService(req.Host)
|
targetSvc := resolveService(req.Host)
|
||||||
if svc, found := getRefreshedService(targetSvc, ctx); found {
|
if svc, found := getRefreshedService(targetSvc, ctx); found {
|
||||||
if cfg, found := svc.Configs[model.ZrokProxyConfig]; found {
|
if cfg, found := svc.Configs[model.ZrokProxyConfig]; found {
|
||||||
logrus.Infof("auth model: %v", cfg)
|
logrus.Debugf("auth model: %v", cfg)
|
||||||
} else {
|
} else {
|
||||||
logrus.Warn("no config!")
|
logrus.Warn("no config!")
|
||||||
}
|
}
|
||||||
if target, err := url.Parse(fmt.Sprintf("http://%v", targetSvc)); err == nil {
|
if target, err := url.Parse(fmt.Sprintf("http://%v", targetSvc)); err == nil {
|
||||||
|
logrus.Infof("[%v] -> %v", targetSvc, req.URL)
|
||||||
|
|
||||||
targetQuery := target.RawQuery
|
targetQuery := target.RawQuery
|
||||||
req.URL.Scheme = target.Scheme
|
req.URL.Scheme = target.Scheme
|
||||||
req.URL.Host = target.Host
|
req.URL.Host = target.Host
|
||||||
@ -156,12 +157,12 @@ func basicAuth(handler http.Handler, realm string, ctx ziti.Context) http.Handle
|
|||||||
if scheme, found := cfg["auth_scheme"]; found {
|
if scheme, found := cfg["auth_scheme"]; found {
|
||||||
switch scheme {
|
switch scheme {
|
||||||
case string(model.None):
|
case string(model.None):
|
||||||
logrus.Infof("auth scheme none '%v'", svcName)
|
logrus.Debugf("auth scheme none '%v'", svcName)
|
||||||
handler.ServeHTTP(w, r)
|
handler.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
|
|
||||||
case string(model.Basic):
|
case string(model.Basic):
|
||||||
logrus.Infof("auth scheme basic '%v", svcName)
|
logrus.Debugf("auth scheme basic '%v", svcName)
|
||||||
inUser, inPass, ok := r.BasicAuth()
|
inUser, inPass, ok := r.BasicAuth()
|
||||||
if !ok {
|
if !ok {
|
||||||
writeUnauthorizedResponse(w, realm)
|
writeUnauthorizedResponse(w, realm)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user