@@ -110,7 +110,7 @@ func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
110
110
)
111
111
for k , v := range proxy .Aliases {
112
112
// Docker api request
113
- if strings .HasPrefix (r .URL .Path , "/v2/" + k + "/" ) || strings . HasPrefix ( r . URL . Path , "/" + k + "/" ) {
113
+ if strings .HasPrefix (r .URL .Path , "/v2/" + k + "/" ) {
114
114
repo = & v
115
115
alias = k
116
116
rewriteDockerAPIURL (r .URL , alias , repo .Repo , repo .Host , repo .Tag )
@@ -202,6 +202,10 @@ func (proxy *Proxy) reverse(alias string) *httputil.ReverseProxy {
202
202
//
203
203
// @link https://golang.org/src/net/http/httputil/reverseproxy.go
204
204
r .Header .Set ("X-Forwarded-For" , "127.0.0.1" )
205
+ // if strings.Contains(r.URL.Path, "artifacts-uploads") {
206
+ // str := strings.SplitN(r.URL.Path, "/artifacts-uploads", 2)
207
+ // r.URL.Path = "/artifacts-uploads" + str[1]
208
+ // }
205
209
auth , ok := r .Context ().Value (authKey ).(docker.Authorizer )
206
210
if ! ok || auth == nil {
207
211
return
@@ -218,7 +222,7 @@ func (proxy *Proxy) reverse(alias string) *httputil.ReverseProxy {
218
222
// through this proxy.
219
223
// We support only relative URLs and not absolute URLs.
220
224
if loc := r .Header .Get ("Location" ); loc != "" {
221
- // We don't want / prefix for relative URL
225
+ log . Infof ( "Original location: %s" , loc )
222
226
lurl , err := url .Parse (loc )
223
227
if err != nil {
224
228
return err
@@ -238,6 +242,7 @@ func (proxy *Proxy) reverse(alias string) *httputil.ReverseProxy {
238
242
// force scheme to http assuming this proxy never runs as https
239
243
lurl .Scheme = proxy .Host .Scheme
240
244
r .Header .Set ("Location" , lurl .String ())
245
+ log .Infof ("Rewrote location: %s" , r .Header .Get ("Location" ))
241
246
}
242
247
243
248
if r .StatusCode == http .StatusBadGateway {
0 commit comments