Vinicius Andrade
Vinicius Andrade

Reputation: 586

Harbor - Configure Http using Cloudflare

I'm making some tests with harbor container registry. In order to publish it to production I wanted to add the ssl support.

As cloudflare provides it I'm wondering if is it possible to make it work.

So far I've created a dns record in cloudflare pointing to my harbor instance, proxied.

I've followed the steps under documentation to configure the https from harbor.

I was able to access the registry with the domain name and the certificates appears to be valid..

But when I tried to push the image to it, it complained about the certificate being invalid

Do you have any clues why?

Upvotes: 0

Views: 1218

Answers (1)

Vinicius Andrade
Vinicius Andrade

Reputation: 586

I've just found out my mistake.

In order to setup the certificate I needed to use the cloud-flare full strict mode.

I'll leave all my steps here, in case someone needs it.

Cloud flare

Setup dns registry.

enter image description here

SSL/TLS

Go to SSL/TLS => Overview

And change to Full (strict) enter image description here

Origin Server

Now go to SSl/TLS Origin Server and create a new certificate enter image description here

Copy the value from Origin Certificate to a text file with .crt extension enter image description here

Copy the value from Private Key to a text file with .key extension enter image description here

Save de cloud flare CA certificate in the same place.more info

Harbor(Linux)

Create two folders:

  • mkdir -p /data/cert
  • mkdir -p /etc/docker/certs.d

Copy the files you have created with names:

  • cert.crt =>domain.com.crt
  • key.key => domain.com.key
  • ca.crt=> ca.key

In the harbor hosts run the following commands

openssl x509 -inform PEM -in /data/cert/domain.com.crt -out /data/cert/domain.com.cert

Convert domain.com.crt to yourdomain.com.cert, for use by Docker.

  • cp /data/cert/domain.com.cert /etc/docker/certs.d/
  • cp /data/cert/domain.com.key /etc/docker/certs.d/
  • cp /data/cert/ca.crt /etc/docker/certs.d/

Copy the server certificate, key and CA files into the Docker certificates folder on the Harbor host. You must create the appropriate folders first.

Edit the harbor.yaml file

In order to make the ssl works you need to uncomment and change the properties in the ssl section

Also it's recommended to change the hostname(both on machine and harbor.yaml) with the same you've set up in your dns

If you have already started the harbor:

  • stop with the docke-compose down command
  • run /harbor/prepare script
  • run the docker-compose up -d command

Upvotes: 2

Related Questions