<p>Below is my manifests:</p>
<ul>
<li>service.yaml</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: jenkins
spec:
  type: NodePort
  ports:
   - port: 8080
     protocol: TCP
     targetPort: 8080
     nodePort: 80
  selector:
    app: jenkins
  #externalTrafficPolicy: &quot;Cluster&quot;
</code></pre>
<ul>
<li>ingress.yaml</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx-ingress-entry
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    #nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /
    #ingress.bluemix.net/rewrite-path: &quot;serviceName=jenkins rewrite=/&quot;

spec:
  tls:
  - hosts:
    - ingress.hygon.cn
    secretName: nginx-cert
  rules:
  - host: ingress.hygon.cn
    http:
      paths:
      - path: /jenkins
        backend:
          serviceName: jenkins
          servicePort: 8080

</code></pre>
<p>I use an nginx ingress to control access backend service Jenkins.
If I set http.paths.path equal &quot;/&quot; everything works well, but if I set path field for the URL the browser will show a 403 error.</p>

Chan Victor
<p>You didn't specify what URLs you are hitting from the outside. But I'm guessing with <code>http.paths.path: /</code> you were hitting:</p>
<pre class="lang-sh prettyprint-override"><code>http://hosname/jenkins
</code></pre>
<p>Then you modified it to <code>http.paths.path: /jenkins</code>, and hitting the same URL you are getting a <code>403</code>. If that's the case you need to remove <code>nginx.ingress.kubernetes.io/rewrite-target: /</code> because that's actually rewriting <code>/jenkins</code> to <code>/</code> and your Jenkins server doesn't know how to serve it.</p>
<p>Alternatively, you can just change the configs on your Jenkins server to serve under <code>/</code> and keep the current setup with <code>http.paths.path: /jenkins</code> and <code>nginx.ingress.kubernetes.io/rewrite-target: /</code>.</p>
<p>✌️</p>
