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've asked this question in a few places and I've found no answer. It should be pretty simple and a pretty common problem. Unfortunately I know nothing about tomcat and mod_proxy so I'm unable to figure it out.

I have a few apps running in tomcat, installed as wars and I can access them at myserver.com:8080/myapp

I simply want to create an apache vhost that forwards myapp.myserver.com to this myserver.com:8080/myapp using mod_proxy.

Hudson is a perfect example, there's no extra config, just a deployed war. So I set up the following apache vhost:

<VirtualHost *:80>
  ServerName hudson.myserver.ca

  ProxyPreserveHost On
  ProxyPass / http://localhost:8080/hudson
  ProxyPassReverse / http://localhost:8080/hudson

</VirtualHost>

and my proxy.conf is:

<IfModule mod_proxy.c>
  ProxyRequests Off

  <Proxy *>
    AddDefaultCharset off
    Order deny,allow
    Allow from all
  </Proxy>

  # Enable/disable the handling of HTTP/1.1 "Via:" headers.
  # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
  # Set to one of: Off | On | Full | Block

  ProxyVia On
</IfModule>

Every request on every app has the same behavior. I go to hudson.myserver.ca for example, and it for some reason forwards on to hudson.myserver.ca/hudson, which gives a tomcat 404 that says

The requested resource (/hudsonhudson/) is not available.

happens for hudson, jira, confluence, and any other app.

What's with the extra 'hudson' and why isn't this working?

share|improve this question
    
What URL are you going to that gets that? What do the logs say? –  Bill Weiss Oct 20 '09 at 22:40
    
as mentioned, the url is hudson.myserver.ca. Logs say: hudson.myserver.ca:80 206.248.167.169 - - [20/Oct/2009:18:57:36 -0400] "GET / HTTP/1.1" 302 - "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9" hudson.myserver.ca:80 206.248.167.169 - - [20/Oct/2009:18:57:36 -0400] "GET /hudson/ HTTP/1.1" 404 389 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9" –  brad Oct 20 '09 at 22:58

1 Answer 1

up vote 3 down vote accepted

Your proxy configuration should read:

ProxyPass / http://localhost:8080/hudson/
ProxyPassReverse / http://localhost:8080/hudson/

Then, you need to find out what is causing the 302 redirect in the first instance. There might be a rewrite rule somewhere else that is causing it.

On another note, you may want to consider using *mod_proxy_ajp* instead for Tomcat connections simply because that is what it was made for.

share|improve this answer
    
Ah, so the trailing / after my proxypass was causing the problem (or lack thereof rather) Adding that properly proxied. However, the stylesheets aren't loaded properly as they all are linked with /hudson. So do I need a rewrite rule here? –  brad Oct 21 '09 at 19:05
    
yup, RewriteRule ^/hudson(.*)$ localhost:8080/hudson$1 [P,L] did the trick, thx again! –  brad Oct 21 '09 at 20:42

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.