Welcome! Log In Create A New Profile

Advanced

Nginx reverse proxy URL getting rewritten

Posted by gopikrish81 
Nginx reverse proxy URL getting rewritten
February 11, 2019 12:20PM
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 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.
Re: Nginx reverse proxy URL getting rewritten
February 11, 2019 12:51PM
Kindly delete this question from here and please move it to nginx related forum- how to category. Thanks
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 90
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready