Fix: Working out-of-box config for traefik #165
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues
As previously configured, traefik would not properly proxy any of the services in harbor due to several issues addressed by this PR.
seed-traefik.ts
script was extracting the host (external) port instead of the container port, causing traefik to proxy port numbers that were not valid inside each container.traefik.yml
was 'traefik-public', which is invalid in a normal harbor installation, as it is not an externally defined docker network. This would cause traefik to pick randomly between the two networks each proxied container was connected to.traefik.yml
was configured to redirect all requests to websecure, which was not configured for any of the services.traefik.yml
was commented out, previous attempts to access the specified domain via HTTPS would set HSTS for the domain in Chrome/Chromium, causing it to redirect attempts to access the services over HTTP.traefik.yml
Changes
This PR modifies the port extraction logic in
.scripts/seed-traefik.ts
:"HOST:CONTAINER"
syntax.harbor_traefik-public
for the Docker provider.traefik.http.services.<serviceName>.loadbalancer.server.port
label is now populated with this correctly extracted container port.websecure
entrypoint.tls=true
) for these routers, allowing Traefik to use its default self-signed certificates for HTTPS access on the specified domain (for example, when ACME certs are not obtainable).${HARBOR_TRAEFIK_HTTPS_HOST_PORT}
, is defined to map to container port 443.Testing
This configuration should allow traefik to work out of the box, but if using a custom domain or TLD (like .lan) a local DNS or dnsmasq entry will be needed to route to the IP of your harbor instance. For example in dnsmasq
address=/*.lan/192.168.0.30
(replace 192.168.0.30 with the LAN ip of your harbor host).You may want to tell your web browser to accept Traefik's self-signed cert as valid.