I am using nginx reverse proxy with ingress object to route my requests to kubernetes pod.
With the below config in place, when I place a request to my LB url http://myservices.myorg.com/jenkins
My request is going to http://myservices.myorg.com/login?from=%2F But i want it to go to http://myservices.myorg.com/jenkins/login?from=%2F
So after I manually replaced to above correct path, all the resources like css, js are rendered with wrong path as http://myservices.myorg.com/static/beacae7e/css/simple-page.css
But it must be http://myservices.myorg.com/jenkins/static/beacae7e/css/simple-page.css
Similarly, after I logged in (I think http POST method) it is going to home page (in browser it changes from http://myservices.myorg.com/jenkins/login to
http://myservices.myorg.com/jenkins
But all the resources rendered again are with wrong path (without /jenkins) - http://myservices.myorg.com/static/beacae7e/css/layout-common.css
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myingress
spec:
rules:
- host: myservices.myorg.com
http:
paths:
- path: /jenkins
backend:
serviceName: jenkins
service port: 80
And below is nginx.conf -
http {
server {
listen 80;
server_name ip-10-118-6-35.ec2.internal;
location /jenkins {
proxy_pass https://backend_nodes_jenkins/;
}
}
upstream backend_nodes_jenkins {
server 10.102.194.242:80;
}
}
As you can see in above nginx.conf , in proxy_pass I am having slash at the end of the URL since I should not pass /jenkins to my pod.
So this is working as expected but only issue is get requests are rewriting my url I believe. Please help.
Figured it out by passing as env variable in docker CMD - JENKINS_OPTS="--prefix=/jenkins"