0

I have configured my harbor docker registry using HA Proxy. Here is my HA Proxy configuration.

frontend ashok_registry
  bind 0.0.0.0:8080
  use_backend maven-repo if { path_beg -i /repository }
  use_backend harbor-repo if { path_beg -i /v2/dev-images/ }
 
backend maven-repo
  server maven-repo mvn01-ashok-dev.net:443 ssl verify none check inter 5s

backend harbor-repo
  server harbor-repo hub.ashok.com:443 ssl verify none check inter 5s

Here whenever i used multiple paths (/v2/dev-images) in path_beg. I am unable to pull the docker image. Getting following error

$ docker pull localhost:8080/dev-images/myapp/myapp-image:1.1.0
Error response from daemon: unauthorized: authorize header needed to send HEAD to repository: authorize header needed to send HEAD to repository

Here is my HAProxy server logs

Dec 28 12:39:42 hydlpt391 haproxy[40706]: 127.0.0.1:53422 [28/Dec/2022:12:39:42.908] ashok_registry ashok_registry/<NOSRV> -1/-1/-1/-1/0 400 0 - - PR-- 1/1/0/0/0 0/0 "<BADREQ>"
Dec 28 12:39:42 hydlpt391 haproxy[40706]: 127.0.0.1:53436 [28/Dec/2022:12:39:42.909] ashok_registry ashok_registry/<NOSRV> -1/-1/-1/-1/0 503 216 - - SC-- 1/1/0/0/0 0/0 "GET /v2/ HTTP/1.1"
Dec 28 12:39:43 hydlpt391 haproxy[40706]: 127.0.0.1:53448 [28/Dec/2022:12:39:42.914] ashok_registry harbor-repo/harbor-repo 0/0/756/309/1065 401 480 - - ---- 1/1/0/0/0 0/0 "HEAD /v2/dev-images/myapp/myapp-image/manifests/1.1.0 HTTP/1.1"
Dec 28 12:39:44 hydlpt391 haproxy[40706]: 127.0.0.1:53452 [28/Dec/2022:12:39:43.981] ashok_registry harbor-repo/harbor-repo 0/0/758/251/1009 401 632 - - ---- 1/1/0/0/0 0/0 "GET /v2/dev-images/myapp/myapp-image/manifests/1.1.0 HTTP/1.1"

If i remove multiple paths in the path_beg then iam able to pull the image through HAProxy

frontend ashok_registry
  bind 0.0.0.0:8080
  use_backend maven-repo if { path_beg -i /repository }
  use_backend harbor-repo if { path_beg -i /v2/ }
 
backend maven-repo
  server maven-repo mvn01-ashok-dev.net:443 ssl verify none check inter 5s

backend harbor-repo
  server harbor-repo hub.ashok.com:443 ssl verify none check inter 5s

And pull command usage

docker pull localhost:8080/dev-images/myapp/myapp-image:1.1.0
1.0.0: Pulling from dev-images/myapp/myapp-image
213ec9aee27d: Already exists 
24b464698217: Pull complete 
4f4fb700ef54: Pull complete 
b4c5e6d1ca25: Pull complete 
4c437a1beb75: Pull complete 
357d1bd31d98: Pull complete 
72cf3d73d8a4: Pull complete 
6476114140cd: Pull complete 
f1f11b5c7106: Pull complete

Here I need /v2/dev-images/ in bath_beg because i have multiple /v2/ paths in multiple urls. How can i solve this issue?

0 Answers0