0%

总结分享-Harbor镜像仓库禁用UI方法

1.找到harborconfigmap配置文件,以harbor-cm.yaml为例,修改配置文件,vim harbor-cm.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
http {
...
server {
listen 80;
server_tokens off;
client_max_body_size 0;

location / {
proxy_pass http://localhost: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;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_buffering off;
proxy_request_buffering off;
return 403; --新增该配置项
}
...

2.执行kubectl apply -f harbor-cm.yaml命令更新配置
3.找到harborpod所在yaml,以harbor1.yaml为例,vim harbor1.yaml,修改harbor nginx的探针,把默认探测 / 修改为探测 /api/systeminfo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- image: goharbor/nginx-photon:v1.6.4
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /api/systeminfo --修改点
port: 80
initialDelaySeconds: 1
periodSeconds: 10
name: nginx
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: /api/systeminfo --修改点
port: 80
initialDelaySeconds: 1
periodSeconds: 10
  1. 执行kubectl apply -f harbor1.yaml重启harbor服务
  2. 重新登录harbor页面,预期返回403 Forbidden,无法登录