Search code examples
apachereverse-proxyharbor

Harbor 2.5.0 behind Apache reverse proxy


I installed Harbor in a server inside the company farm and I can use it without problem through https://my-internal-server.com/harbor.

I tried to add the reverse proxy rules to Apache to access it through the public server for harbor, v2, chartrepo, service endpoints, like https://my-public-server.com/harbor, but this doesn't work.

For example:

  ProxyPass      /harbor   https://eslregistry.eng.it/harbor
  ProxyPassReverse  /harbor https://eslregistry.eng.it/harbor

I also set in harbor.yaml:

When I try to access to https://my-public-server.com/harbor with the browser I see a Loading... page and 404 errors for static resources because it tries to get them with this GET: https://my-public-server.com/scripts.a459d5a2820e9a99.js

How can I configure it to work?


Solution

  • You should pass the whole domain, not only the path. Take a look at the official Nginx config to have an idea how this might look like.

    upstream harbor {
      server harbor_proxy_ip:8080;
    }
    
    server {
        listen 443 ssl;
        server_name harbor.mycomp.com;
    
        ssl_certificate      /etc/nginx/conf.d/mycomp.com.crt;
        ssl_certificate_key  /etc/nginx/conf.d/mycomp.com.key;
    
        client_max_body_size 0;
        chunked_transfer_encoding on;
    
        location / {
            proxy_pass http://harbor/;
            proxy_set_header  Host              $http_host;
            proxy_set_header  X-Real-IP         $remote_addr;
            proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header  X-Forwarded-Proto $scheme;
    
            proxy_buffering off;
            proxy_request_buffering off;
        }
    

    Note that you should disable proxy or buffering