Discussion:
Reverse Proxy with Jenkins
David Weintraub
2011-08-11 18:14:24 UTC
Permalink
I'm attempting to follow the directions to get reverse proxy to work.
Here's my setup:

Machine #1: sys1
Machine #2: sys2

Jenkins runs on Machine #2 on port 8080 as http://sys2:8080 using the
Winstone appserver. I am running the website from Machine #1.

I want:

http://sys1/jenkins

to redirect to:

http://sys2:8080

Following the directions on this page:
https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache

I have the following configured in my httpd configuration:

ProxyPass /jenkins http://sys2:8080
ProxyPassReverse /jenkins http://sys2:8080
<Proxy http://sys2:8080/*>
Order deny,allow
Allow from all
</Proxy>

Starting httpd shows no errors. And, I can go to
sys1.company.com/jenkins, and the main Jenkins page gets pulled up,
but with a bunch of broken links.

The link URLs are missing the Jenkins directory name. For example, if
I click on one line, it tries to load
http://sys1.company.com/view/Claims, and I get 404'd. However, if I
add in the Jenkins directory:

http://sys1.company.com/jenkins/view/Claims

it works (except for all the broken links).

Does anyone see what I'm doing wrong?
--
David Weintraub
qazwart-***@public.gmane.org
Jesse Farinacci
2011-08-11 18:20:47 UTC
Permalink
greetings,
Post by David Weintraub
I'm attempting to follow the directions to get reverse proxy to work.
While it is common to run Jenkins behind a reverse proxy, your usage
is fairly exotic. The Apache HTTPD mailing lists might be a better
place to yield a useful response..

-Jesse
--
There are 10 types of people in this world, those
that can read binary and those that can not.
Les Mikesell
2011-08-11 18:49:19 UTC
Permalink
Post by David Weintraub
I'm attempting to follow the directions to get reverse proxy to work.
Machine #1: sys1
Machine #2: sys2
Jenkins runs on Machine #2 on port 8080 as http://sys2:8080 using the
Winstone appserver. I am running the website from Machine #1.
http://sys1/jenkins
http://sys2:8080
https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache
ProxyPass /jenkins http://sys2:8080
ProxyPassReverse /jenkins http://sys2:8080
<Proxy http://sys2:8080/*>
Order deny,allow
Allow from all
</Proxy>
Starting httpd shows no errors. And, I can go to
sys1.company.com/jenkins, and the main Jenkins page gets pulled up,
but with a bunch of broken links.
The link URLs are missing the Jenkins directory name. For example, if
I click on one line, it tries to load
http://sys1.company.com/view/Claims, and I get 404'd. However, if I
http://sys1.company.com/jenkins/view/Claims
it works (except for all the broken links).
Does anyone see what I'm doing wrong?
You need to make the /jenkins URL act like a directory, and it isn't
quite one in your setup. When apache gets a URL that does refer to a
directory but doesn't include the required trailing /, it sends a
redirect to the client that does include the slash, so subsequent
relative links will be interpreted correctly by the browser.

The really simple fix is to proxy /jenkins/ and make a dummy jenkins
directory in your sys1 server's default documentroot (so it will issue
the redirect for you). Or if you think you might forget the subtlety
you could put an explicit rewriterule redirect in the config to force
it. Personally, I'd use an ajp:: proxy instead, and just for sanity I
would move sys2's jenkins instance to appear under /jenkins too (with
--prefix=/jenkins in the startup arguments).
--
Les Mikesell
lesmikesell-***@public.gmane.org
Richard Mortimer
2011-08-11 18:59:33 UTC
Permalink
Hi,
Post by David Weintraub
I'm attempting to follow the directions to get reverse proxy to work.
Machine #1: sys1
Machine #2: sys2
Jenkins runs on Machine #2 on port 8080 as http://sys2:8080 using the
Winstone appserver. I am running the website from Machine #1.
http://sys1/jenkins
http://sys2:8080
https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache
ProxyPass /jenkins http://sys2:8080
ProxyPassReverse /jenkins http://sys2:8080
You might want to add

ProxyPreserveHost On

That makes apache pass the original (sys1) hostname to jenkins in the
http request headers.

I suspect you also want to start jenkins on sys2 with

--prefix=/jenkins

added to /etc/default/jenkins as per the Running behind apache that you
mentioned above.

Regards

Richard
Post by David Weintraub
<Proxy http://sys2:8080/*>
Order deny,allow
Allow from all
</Proxy>
Starting httpd shows no errors. And, I can go to
sys1.company.com/jenkins, and the main Jenkins page gets pulled up,
but with a bunch of broken links.
The link URLs are missing the Jenkins directory name. For example, if
I click on one line, it tries to load
http://sys1.company.com/view/Claims, and I get 404'd. However, if I
http://sys1.company.com/jenkins/view/Claims
it works (except for all the broken links).
Does anyone see what I'm doing wrong?
Didier Durand
2011-08-12 04:47:23 UTC
Permalink
Hi,

you can read http://jenkins.361315.n4.nabble.com/Apache-reverse-proxy-to-Jenkins-servlet-on-port-8080-td3444546.html
for more details if needed

regards

didier
Post by Richard Mortimer
Hi,
Post by David Weintraub
I'm attempting to follow the directions to get reverse proxy to work.
Machine #1: sys1
Machine #2: sys2
Jenkins runs on Machine #2 on port 8080 ashttp://sys2:8080using the
Winstone appserver. I am running the website from Machine #1.
     http://sys1/jenkins
     http://sys2:8080
https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Ap...
ProxyPass /jenkinshttp://sys2:8080
ProxyPassReverse /jenkinshttp://sys2:8080
You might want to add
ProxyPreserveHost On
That makes apache pass the original (sys1) hostname to jenkins in the
http request headers.
I suspect you also want to start jenkins on sys2 with
--prefix=/jenkins
added to /etc/default/jenkins as per the Running behind apache that you
mentioned above.
Regards
Richard
Post by David Weintraub
<Proxyhttp://sys2:8080/*>
     Order deny,allow
     Allow from all
</Proxy>
Starting httpd shows no errors. And, I can go to
sys1.company.com/jenkins, and the main Jenkins page gets pulled up,
but with a bunch of broken links.
The link URLs are missing the Jenkins directory name. For example, if
I click on one line, it tries to load
http://sys1.company.com/view/Claims, and I get 404'd. However, if I
http://sys1.company.com/jenkins/view/Claims
it works (except for all the broken links).
Does anyone see what I'm doing wrong?
Loading...