Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I tried googling and the only articles I found comparing these two were from 2005 down to 2002. I just set up my first Tomcat instance to run Jira for a project I'm doing. I want to proxy this through port 80 and apache. From what I can tell, I can easily forward the traffic using mod_proxy. What's the difference iwth using mod_jk? Are there any performance/security differences between these two mods? Anyone have any tips/experience setting up forwarding through apache? I'm running debian Lenny.

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

JIRA don't officially support putting tomcat behind apache unless you use mod_proxy_http. The recommended configuration goes something like this

/etc/httpd/vhosts.d/jira.company.com.conf

...
ProxyPreserveHost On
<Location />
   ProxyPass http://localhost:8080/
</Location>
...

/opt/j2ee/domains/company.com/jira/tomcat/conf/server.xml

...
<Connector address="localhost" port="8080" URIEncoding="UTF-8"
   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
   enableLookups="false" redirectPort="8443" acceptCount="100"
   debug="0" connectionTimeout="20000"
   proxyName="jira.company.com" proxyPort="80"
   disableUploadTimeout="true" /> 
...

This should get your going on http, let me know if you want an example for https

disclaimer: I am currently an Atlassian employee, although I don't work on the JIRA team

share|improve this answer
    
so I've never used mod_proxy. I'm running jira through tomcat installed with the War, so I actually access it at mydomain.ca:8080/jira. I'm assuming then that my ProxyPass directive should look like: ProxyPass localhost:8080/jira ?? –  brad Oct 14 '09 at 18:06
    
Another question, since I'm running a few apps in tomcat (confluence and hudson to name a few) I can't really add the proxyName to my connector in server.xml as it will be different for each of those apps. How do I configure mod_proxy to work so I can have an apache VHost file for each, and forward each to their respective apps. –  brad Oct 14 '09 at 21:23
    
@brad, yes, ProxyPass localhost:8080/jira. For the second question you can probably get away with using ProxyPreserveHost On in the apache config. –  Dave Cheney Oct 15 '09 at 9:19
add comment

Both methods forward requests from apache to tomcat. mod_proxy uses the HTTP that we all know an love. mod_jk uses a binary protocol AJP. The main advantages of mod_jk are:

  • AJP is a binary protocol, so is slightly quicker for both ends to deal with and uses slightly less overhead compared to HTTP, but this is minimal.
  • AJP includes information like original host name, the remote host and the SSL connection. This means that ServletRequest.isSecure() works as expected, and that you know who is connecting to you and allows you to do some sort of virtualhosting in your code.

A slight disadvantage is that AJP is based on fixed sized chunks, and can break with long headers, particularly request URLs with long list of parameters, but you should rarely be in a position of having 8K of URL parameters. (It would suggest you were doing it wrong. :) )

The position is slightly complicated by the existence of mod_proxy_ajp. Between them, mod_jk is the more mature of the two, but mod_proxy_ajp works in the same framework as the other mod_proxy modules. I have not yet used mod_proxy_ajp, but would consider doing so in the future, as mod_jk involves configuration outside of Apache.

Given a choice, I would prefer a AJP based connector, mostly due to my second stated advantage, more than the performance aspect. Of course, if Atlassian doesn't support anything other than mod_proxy_http, that does tie your hands somewhat, but mod_jk does work with JIRA.

share|improve this answer
add comment

Yes there is some difference. However, which you choose to use would depend on your application.

As an example, *mod_proxy* will function as a normal reverse proxy which will forward only regular headers across while *mod_jk* would function as a special connector that forwards not only regular headers but also certain other environment variables. A simile can be drawn to scgi and fastcgi connectors.

For the purpose of working with JSP, you should use *mod_jk* which it was designed for. Use only *mod_proxy* when forwarding to regular web-servers only (that may launch other ajp connectors behind them).

[front apache]---proxy---[back apache]---ajp---[tomcat]
       |
       +--------- ajp----[tomcat]

Hope this helps.

share|improve this answer
add comment

mod_proxy will truely "proxy" all requests to tomcat using the normal http connectors.

mod_jk opens up "ajp13" connections to the tomcat server which are separate from the normal tomcat http connectors and passes traffic that way.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.