Proxy pass with rewrite

Hello,

I would like to configure ngix with jenkins, nginx should be a proxy for
the jenkins instance. I have configuration the proxy pass options in
this way:

location /jenkins  {
    proxy_pass         http://localhost:8080/;
    proxy_redirect     off;
    proxy_set_header   Host $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
}

My jenkins instance uses the port 8080 and I would like to pass the data
from the URL http://mydomain/jenkins to the jerkins instance.
If I change the location to / everything works fine, but with the
subdirectory alias I get an error with the URL. Jenkins result pages
uses only
URLs to http://mydomain/ but in my case it should be
http://mydomain/jenkins/
I have modified the Jenkins URL (in the admin panel) to
http://mydomain/jenkins/ but it seems to be an error on the reverse data
call.
I must substitute all URL, which comes from the proxy_pass URL with
http://mydomain/jenkins
How can I do this in a correct way?

Thanks

Phil

On Fri, Oct 25, 2013 at 07:57:01AM +0200, Philipp Kraus wrote:

Hi there,

I would like to configure ngix with jenkins, nginx should be a proxy for the
jenkins instance. I have configuration the proxy pass options in this way:

https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy
looks like it may have useful information.

If I change the location to / everything works fine, but with the subdirectory
alias I get an error with the URL. Jenkins result pages uses only
URLs to http://mydomain/ but in my case it should be
http://mydomain/jenkins/

Fix jenkins so that it knows it is below /jenkins/, not below /.

I must substitute all URL, which comes from the proxy_pass URL with
http://mydomain/jenkins
How can I do this in a correct way?

The best way in general is to arrange the back-end so that it doesn’t
need doing.

f

Francis D. [email protected]

Hi,

Am 25.10.2013 um 10:01 schrieb Francis D. [email protected]:

https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy

looks like it may have useful information.

I have used this how to, but I cannot create a working solution

Fix jenkins so that it knows it is below /jenkins/, not below /.

I have set in Jenkins System panel the field “Jenkins URL” to
“myserver/jenkins/”

Any URLs are working correct but other are working. CSS are not working
because the /jenkins/ part
is not exists. So it seems that nginx removes on some URL the /jenkins/
part in the URL

Phil

On Fri, Oct 25, 2013 at 01:25:10PM +0200, Philipp Kraus wrote:

Am 25.10.2013 um 10:01 schrieb Francis D. [email protected]:

Hi there,

https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy

looks like it may have useful information.

I have used this how to, but I cannot create a working solution

The config in this howto, and the config that you showed, are not the
same.

Note particularly the “location” and the “proxy_pass” lines.

Fix jenkins so that it knows it is below /jenkins/, not below /.

I have set in Jenkins System panel the field “Jenkins URL” to
“myserver/jenkins/”

The howto say to do something else as well.

I don’t know if it is correct – I don’t use Jenkins – but I also don’t
know what you’ve done, because you haven’t said.

Any URLs are working correct but other are working. CSS are not working because
the /jenkins/ part
is not exists. So it seems that nginx removes on some URL the /jenkins/ part in
the URL

That could be due to proxy_pass.

http://nginx.org/r/proxy_pass

“specified with a URI” means “any slash after the host:port part”.

If that doesn’t fix things, then can you find one request which does
not work as you expect it to, and show what url nginx gets, and what
url jenkins gets, and see if that helps find where things go wrong?

Good luck with it,

f

Francis D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs