Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map domain to harbor proxied registry #924

Closed
dioguerra opened this issue Apr 9, 2021 · 8 comments
Closed

Map domain to harbor proxied registry #924

dioguerra opened this issue Apr 9, 2021 · 8 comments

Comments

@dioguerra
Copy link
Contributor

dioguerra commented Apr 9, 2021

For example, i want to map my Harbor proxied docker.io project by means of a domain.

dockerio-registry.foo.bar -> registry.foo.bar/docker.io

The use case is configuring the pull-through cache directly in the docker daemon, as subpaths are not allowed. This does not work:

{
  "registry-mirrors": ["https://registry.foo.bar/docker.io"]
}

So something like this is required:

{
  "registry-mirrors": ["https://dockerio-registry.foo.bar"]
}
@dioguerra dioguerra changed the title Map subdomain/domain to reverse-proxy Map domain to harbor proxied registry Apr 9, 2021
@reasonerjt
Copy link
Contributor

Let me clarify, is docker.io a proxy cache project?

I don't think we can map a project's URI to a host.

@dioguerra
Copy link
Contributor Author

dioguerra commented Apr 15, 2021

I can almost do it, but im having a 401 unauthorized error. I manage to have the same errors with 2 different configurations.
One using the server-script from nginx reverse proxy, the other way by duplicating the ingress rules to a new "virtual host"

I dont have the currect setup anymore, but it was something like:


      nginx.ingress.kubernetes.io/server-snippet: |
        if ($host ~ "dockerio-registry-staging.foo.bar")
        {
            rewrite ^https://dockerio-registry-staging.foo.bar(/docker.io)/v2(/.*)$ https://registry-staging.foo.bar/v2$1$2
        }

OR

cat templates/proxy.yaml 
{{- range $domain,$project := .Values.domains.proxy }}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    {{ $.Values.harbor.expose.ingress.annotations | toYaml | nindent 4 }}
    nginx.ingress.kubernetes.io/rewrite-target: /v2/{{ $project }}/$2
  name: harbor-staging-harbor-ingress-{{ $domain }}
spec:
  rules:
  - host: {{ $domain }}-{{ $.Values.harbor.expose.ingress.hosts.core }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          serviceName: {{ $.Release.Name }}-harbor-portal
          servicePort: 80
      - path: /api
        pathType: Prefix
        backend:
          serviceName: {{ $.Release.Name }}-harbor-core
          servicePort: 80
      - path: /service
        pathType: Prefix
        backend:
          serviceName: {{ $.Release.Name }}-harbor-core
          servicePort: 80
      - path: /v2(/|$)(.+)
        pathType: Prefix
        backend:
          serviceName: {{ $.Release.Name }}-harbor-core
          servicePort: 80
      - path: /chartrepo
        pathType: Prefix
        backend:
          serviceName: {{ $.Release.Name }}-harbor-core
          servicePort: 80
      - path: /c
        pathType: Prefix
        backend:
          serviceName: {{ $.Release.Name }}-harbor-core
          servicePort: 80
  tls:
  - hosts:
    - {{ $domain }}-registry-staging.foo.bar
    secretName: {{ $.Release.Name }}-harbor-ingress-{{ $domain }}
---
{{ end }}

I think with a litle teak this is possible. Definetly this last way its easyer to understand

@dioguerra
Copy link
Contributor Author

Let me clarify, is docker.io a proxy cache project?

I don't think we can map a project's URI to a host.

Yes, docker.io is a proxy cache project

@davgia
Copy link

davgia commented Jul 12, 2022

Any update on this? @dioguerra did you managed to make it work?

@dioguerra
Copy link
Contributor Author

Sorry, no. I did not make this work and since then i didnt try it again... still interested tho.

@ricardojdsilva87
Copy link

Hello @dioguerra We had that issue in the past for the docker.io proxy, the thing is that you need to rewrite the request of the token also that happens in the back of the communications:
Please check:
goharbor/harbor#8082 (comment)
goharbor/harbor#13579 (comment)

For your question the issue I see is having a subfolder as endpoint, maybe you can check the examples in the comments and adapt to your needs.

Hope it helps

Copy link

github-actions bot commented Feb 8, 2024

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

@github-actions github-actions bot added the Stale label Feb 8, 2024
Copy link

This issue was closed because it has been stalled for 30 days with no activity. If this issue is still relevant, please re-open a new issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants