4

Environment:

  1. Novice user (thats me) on all mentioned points
  2. CentOS 6.4 x86_64
  3. OpenJDK 1.7.0_65
  4. Apache httpd 2.2.15 + mod_ssl 2.2.15 - Acts as proxy using mod_proxy_ajp, no other webapp
  5. Jenkins 1.562 - Runs only on ajp port 8009, no web prefix

I am able to access URL https://host/ and I see the jenkins UI. [I did not add AllowEncodedSlashes NoDecode, ProxyRequests Off or nocanon, yet it seems to work ... but for the significance of those, I will search/ask another question.]

This is the only line I added to /etc/httpd/conf.d/ssl.conf (just before </VirtualHost> that matches <VirtualHost _default_:443>):

ProxyPass / ajp://localhost:8009/

I was under the impression that fronting Jenkins with Apache httpd would mean

  1. Native binaries (instead of Java bytecode) to handle the remote connection parts
  2. Ability to serve static content (images, build artifacts, console logs) without burdening the Jenkins server process

If that understanding is right, I am looking for Apache httpd configuration rules that will enable Apache httpd to serve static content from Jenkins. I already tried:

ProxyPass /static !

With

DocumentRoot "/var/cache/jenkins/war"

But that leads to an unusual page (hard to identify as Jenkins ... I did not test links). When I enabled access log for Jenkins (via /etc/sysconfig/jenkins), such entries showed up (only excerpts copied below):

/static/6a3788e2/scripts/yui
/static/6a3788e2/css/
/adjuncts/6a3788e2/lib/layout/breadcrumbs.css

When the Jenkins service is restarted, a different text shows up. How do we configure Apache httpd to send out static content ?

I've also tried hosting jenkins.war on tomcat (tomcat6 package deployed via yum) on the default HTTP connector port 8080 (i.e. without mod_proxy_ajp). Each time I restart tomcat, the URL element after static differs.

PS: Don't have enough credits to create a tag mod_proxy_ajp, using mod_proxy instead. However, I can offer a bounty of 50 credits. Please vote up the question if you believe there was genuine effort put into this.

Parag Doke
  • 863
  • 7
  • 17
  • Have you considered using [mod_cache_disk](http://httpd.apache.org/docs/2.4/mod/mod_cache_disk.html) on `/static` instead? It seems like this would be easier than having Apache serve the static content from the exploded WAR directory. – John R Sep 11 '14 at 17:23
  • Maybe you just want to learn how to do this just for the sake of it, but otherwise: What are you trying to fix by using apache for static file serving? Is the load on you jenkins process/machine really that demanding that you'd need that? – Simon Groenewolt Sep 11 '14 at 19:27
  • @JohnR - No. I have not tried that. Given that I'm a novice on the WebServer configuration front, I will read about it and try. Thanks for your comment. – Parag Doke Sep 20 '14 at 06:27
  • @SimonGroenewolt - Build artifacts and logs in my case are large in size (anything up to 500 MB frequently, and close to 50 MB respectively). Reduction in build verbosity is not an option. Given that the Jenkins server is accessed across continents, yes, I did notice performance drops when large files were being downloaded (but I have no statistics on concurrent downloads, etc). – Parag Doke Sep 20 '14 at 06:32
  • @ParagDoke I see your point, while apache _may_ improve the performance, I don't think it the setup with either AJP or reverse proxy is in any way meant to increase performance, but more to make several sites accessible through a common naming scheme. – Simon Groenewolt Sep 21 '14 at 20:18
  • @SimonGroenewolt Okay. Then my assumption #2 above is kinda incorrect. I will continue without running Jenkins behind Apache Httpd then. Thank you for your time and attention. I only wish I could reclaim credits if a bounty doesn't yield what was asked (but it did help me set my understanding right) :-). – Parag Doke Sep 22 '14 at 05:37

2 Answers2

0

You want to use ProxyPassMatch instead of ProxyPass, like in:

ProxyPassMatch ^/(?!static/) ajp://localhost:8009/

This should proxy only the stuff not in /static. Note that you may need to set up a web root for the static content (but first, you may want to check that it works).

llogiq
  • 13,815
  • 8
  • 40
  • 72
  • Sorry, I don't follow. Each time the Jenkins service is restarted, I see a different URL element after /static (from my question, the "6a3788e2" part). – Parag Doke Sep 20 '14 at 06:36
0

As I mentioned in a comment to your question your proposed setup will likely not result in a lower load for Jenkins.

You could reduce the load on Jenkins by configuring Apache (or another webserver like ngix or proxy like squid) like a caching proxy. This will probably (you will have to test) remove part of the load from jenkins. However, since Jenkins by default does not set an expires date somewhere in the future for requests to the artifacts the proxy will still have to to a check with jenkins (returning hopefully a 304 instead of the full file) before serving the content to the client.

Simon Groenewolt
  • 10,607
  • 1
  • 36
  • 64