Below is my manifests:
apiVersion: v1
kind: Service
metadata:
name: jenkins
spec:
type: NodePort
ports:
- port: 8080
protocol: TCP
targetPort: 8080
nodePort: 80
selector:
app: jenkins
#externalTrafficPolicy: "Cluster"
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-ingress-entry
annotations:
kubernetes.io/ingress.class: "nginx"
#nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
#ingress.bluemix.net/rewrite-path: "serviceName=jenkins rewrite=/"
spec:
tls:
- hosts:
- ingress.hygon.cn
secretName: nginx-cert
rules:
- host: ingress.hygon.cn
http:
paths:
- path: /jenkins
backend:
serviceName: jenkins
servicePort: 8080
I use an nginx ingress to control access backend service Jenkins. If I set http.paths.path equal "/" everything works well, but if I set path field for the URL the browser will show a 403 error.
You didn't specify what URLs you are hitting from the outside. But I'm guessing with http.paths.path: /
you were hitting:
http://hosname/jenkins
Then you modified it to http.paths.path: /jenkins
, and hitting the same URL you are getting a 403
. If that's the case you need to remove nginx.ingress.kubernetes.io/rewrite-target: /
because that's actually rewriting /jenkins
to /
and your Jenkins server doesn't know how to serve it.
Alternatively, you can just change the configs on your Jenkins server to serve under /
and keep the current setup with http.paths.path: /jenkins
and nginx.ingress.kubernetes.io/rewrite-target: /
.
✌️