Harbor 配置 external_url 参数及 Nginx 代理设置
在 Harbor 的配置文件 harbor.yml 中,可以通过设置 external_url 参数来配置 Harbor 的外部访问地址。例如:
# The URL to access the UI, registry and auth services
# from a browser. This must be reachable from end users.
# Scheme, hostname and port can be customized.
# DO NOT use localhost or 127.0.0.1 as the hostname,
# because Harbor needs to be accessed by external clients.
external_url: 'https://harbor.example.com'
在以上示例中,external_url 被设置为 'https://harbor.example.com',即 Harbor 的外部访问地址为 https 协议的 harbor.example.com。
如果需要使用 Nginx 代理 Harbor,需要在 Nginx 的配置文件中添加以下配置:
server {
listen 80;
server_name harbor.example.com;
location / {
proxy_pass http://harbor:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
以上示例中,Nginx 监听 80 端口,server_name 为 harbor.example.com。location / 中的 proxy_pass 指向 Harbor 的 IP 地址和端口号,其中 IP 地址可以是容器名或者主机名。proxy_set_header 配置用于设置请求头,以便 Harbor 正确获取客户端的真实 IP 地址。
配置完成后,需要重新加载 Nginx 配置文件使其生效。
原文地址: https://www.cveoy.top/t/topic/j8mr 著作权归作者所有。请勿转载和采集!