diff --git a/README.md b/README.md index 4a14d2c..31b5998 100755 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ In the examples domain `x.y.z` is used, replace them with your domain ![panel screenshot](screenshots/panel.png) -## How to use (docker) +## How to use 1. Download and extract the latest release (or clone the repository if you want to try out experimental features) diff --git a/bin/go-proxy b/bin/go-proxy index e34c4b7..69c8ecb 100755 Binary files a/bin/go-proxy and b/bin/go-proxy differ diff --git a/src/go-proxy/docker_provider.go b/src/go-proxy/docker_provider.go index c2b7249..7f9bb7b 100755 --- a/src/go-proxy/docker_provider.go +++ b/src/go-proxy/docker_provider.go @@ -162,7 +162,7 @@ func (p *Provider) getDockerProxyConfigs() ([]*ProxyConfig, error) { return nil, fmt.Errorf("unable to create docker client: %v", err) } - containerSlice, err := p.dockerClient.ContainerList(context.Background(), container.ListOptions{}) + containerSlice, err := p.dockerClient.ContainerList(context.Background(), container.ListOptions{All: true}) if err != nil { return nil, fmt.Errorf("unable to list containers: %v", err) } diff --git a/src/go-proxy/http_route.go b/src/go-proxy/http_route.go index f6445d3..fd9d690 100755 --- a/src/go-proxy/http_route.go +++ b/src/go-proxy/http_route.go @@ -52,20 +52,22 @@ func NewHTTPRoute(config *ProxyConfig) (*HTTPRoute, error) { }), } + var rewriteBegin = proxy.Rewrite var rewrite func(*ProxyRequest) + var modifyResponse func(*http.Response) error switch { case config.Path == "", config.PathMode == ProxyPathMode_Forward: - rewrite = proxy.Rewrite + rewrite = rewriteBegin case config.PathMode == ProxyPathMode_Sub: rewrite = func(pr *ProxyRequest) { - proxy.Rewrite(pr) + rewriteBegin(pr) // disable compression pr.Out.Header.Set("Accept-Encoding", "identity") // remove path prefix pr.Out.URL.Path = strings.TrimPrefix(pr.Out.URL.Path, config.Path) } - route.Proxy.ModifyResponse = func(r *http.Response) error { + modifyResponse = func(r *http.Response) error { contentType, ok := r.Header["Content-Type"] if !ok || len(contentType) == 0 { route.l.Debug("unknown content type for ", r.Request.URL.String()) @@ -93,7 +95,7 @@ func NewHTTPRoute(config *ProxyConfig) (*HTTPRoute, error) { } default: rewrite = func(pr *ProxyRequest) { - proxy.Rewrite(pr) + rewriteBegin(pr) pr.Out.URL.Path = strings.TrimPrefix(pr.Out.URL.Path, config.Path) } } @@ -101,8 +103,17 @@ func NewHTTPRoute(config *ProxyConfig) (*HTTPRoute, error) { if logLevel == logrus.DebugLevel { route.Proxy.Rewrite = func(pr *ProxyRequest) { rewrite(pr) + route.l.Debug("Request URL: ", pr.In.Host, pr.In.URL.Path) route.l.Debug("Request headers: ", pr.In.Header) } + route.Proxy.ModifyResponse = func(r *http.Response) error { + route.l.Debug("Response URL: ", r.Request.URL.String()) + route.l.Debug("Response headers: ", r.Header) + if modifyResponse != nil { + return modifyResponse(r) + } + return nil + } } else { route.Proxy.Rewrite = rewrite } diff --git a/src/go-proxy/main.go b/src/go-proxy/main.go index 6476d26..c15c217 100755 --- a/src/go-proxy/main.go +++ b/src/go-proxy/main.go @@ -21,7 +21,6 @@ func main() { DisableColors: false, FullTimestamp: true, }) - InitFSWatcher() InitDockerWatcher()