[英]Unable to access the GUI with Ingress SubPath
This issue has also been posted to the Gitlab Forum.此问题也已发布到 Gitlab 论坛。 https://forum.gitlab.com/t/unable-to-access-the-gui-with-ingress-subpath/32269 I think that it will be read by experts even on StackOverFlow, so I will post it.
https://forum.gitlab.com/t/unable-to-access-the-gui-with-ingress-subpath/32269我认为即使在 StackOverFlow 上专家也会阅读它,所以我会发布它。 Please allow double posting.
请允许双重发布。
I want to build GitLab CE on AWS EKS and access the GUI with the subpath set in Ingress.我想在 AWS EKS 上构建 GitLab CE 并使用 Ingress 中设置的子路径访问 GUI。 If
host
in Ingress is set to /
, it can be accessed normally, but if it is other than /
, for example /gitlab
can not access.如果 Ingress 中的
host
设置为/
可以正常访问,但是如果不是/
,比如/gitlab
就不能访问。 Nginx Ingress Controller is used.使用 Nginx 入口控制器。
How can I solve it?我该如何解决?
Thank you in advance.先感谢您。
The following is attached as reference information.以下附上作为参考信息。
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/service-l4.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/patch-configmap-l4.yaml
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose --file docker-compose.yml convert
kompose.version: 1.17.0 (a74acad)
creationTimestamp: null
labels:
io.kompose.service: gitlab
name: gitlab
spec:
ports:
- name: "12080"
port: 12080
targetPort: 80
selector:
io.kompose.service: gitlab
type: ClusterIP
status:
loadBalancer: {}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose --file docker-compose.yml convert
kompose.version: 1.17.0 (a74acad)
creationTimestamp: null
labels:
io.kompose.service: gitlab
name: gitlab
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: gitlab
spec:
containers:
- envFrom:
- configMapRef:
name: gitlab-deployment-env-config
image: gitlab/gitlab-ce:latest
name: gitlab
ports:
- containerPort: 80
volumeMounts:
- mountPath: /etc/gitlab
name: gitlab-vol0
- mountPath: /var/log/gitlab
name: gitlab-vol1
- mountPath: /var/opt/gitlab
name: gitlab-vol2
imagePullPolicy: Always
restartPolicy: Always
volumes:
- name: gitlab-vol0
hostPath:
path: /data/gitlab/vol0
type: DirectoryOrCreate
- name: gitlab-vol1
hostPath:
path: /data/gitlab/vol1
type: DirectoryOrCreate
- name: gitlab-vol2
hostPath:
path: /data/gitlab/vol2
type: DirectoryOrCreate
status: {}
apiVersion: v1
kind: ConfigMap
metadata:
name: gitlab-deployment-env-config
data:
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails['initial_root_password'] = "password"
unicorn['worker_processes'] = 3
postgresql['shared_buffers'] = "512MB"
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
# host:
- http:
paths:
- path: /gitlab(/|$)(.*)
backend:
serviceName: gitlab
servicePort: 12080
This doesn't work, but I changed the rewrite-target
setting to /
and changed path
to /
Then you can access with GUI.这不起作用,但我将
rewrite-target
设置更改为/
并将path
更改为/
然后您可以使用 GUI 访问。
210.148.59.67 - - [05/Dec/2019:00:44:31 +0000] "GET /gitlab HTTP/1.1" 302 158 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" 515 0.037 [default-gitlab-12080] [] 10.0.32.140:80 158 0.040 302 0e252e1a2ac495d90790ec7d83546444
/gitlab
subpath from browser/gitlab
子路径时的行为The URL will be redirected from /gitlab
to /users/sign_in
and will be 404 Not Found
on the screen. URL 将从
/gitlab
重定向到/users/sign_in
并且将在屏幕上显示404 Not Found
。
Here is the URL you are accessing.这是您正在访问的 URL。
http://{{{AWS CLB DNSName}}}/gitlab
The redirection is happening as a default behavior of the app then you got 404 as you don't have an entry for "/users/sign_in".重定向是作为应用程序的默认行为发生的,然后你得到 404,因为你没有“/users/sign_in”的条目。 So maybe if you add another entry for "/users/sign_in" as path, it would work
所以也许如果你为“/users/sign_in”添加另一个条目作为路径,它会起作用
As another option to resolve that is to use / in path and use a host:作为解决该问题的另一种选择是在路径中使用 / 并使用主机:
spec:
rules:
- host: gitlab.example.com
http:
paths:
- path: /
backend:
serviceName: gitlab
servicePort: 12080
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.