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 have a lot of services attached to a single domain, so I was hoping to serve Tomcat under, say, http://server_name/tomcat, with Nginx as a reverse proxy to Tomcat's HTTP connector.

The Nginx configuration is as simple as it gets:

location /tomcat {
   include proxy_pass.conf;
   proxy_pass http://127.0.0.1:8080;
}

If I leave it as it is, Tomcat is unable to resolve requests that begin with /tomcat, but if I otherwise set alias /; in Nginx, then Tomcat works just fine, but unfortunately it can't resolve the path under which it is being served, so all of the URLs are missing /tomcat.

I've went through the configuration reference for Tomcat 7 several times over, but I couldn't find anything that would allow me to configure Tomcat to serve all the applications under the /tomcat path, or otherwise add it as a prefix to the context path for every application.

I could manually configure server.xml with a <context/> container for every single app, but that'd just make me feel uneasy. Could anyone please tell me what is it that I'm obviously missing?

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

I tried to do the same thing on a several occasions in the past 4-5 years and I tried many different ways but I failed miserably on all attempts. Finally, I came to a conclusion that (a) it is not possible (b) even if by some means this can be done it would not worth the effort. Although, I would be pleasantly surprised if someone has figured this out.

share|improve this answer
    
How disappointing :/! I've searched far and wide and it all seems to indicate that your absolutely right. –  Filip Dupanović Apr 22 '11 at 8:16
add comment

Untested but your best bet would be to load a Java Bridge into APACHE2/PHP so that it runs java code when it encounters it.

http://www.dsl.uow.edu.au/~sk33/php5java.htm

share|improve this answer
add comment

Apparently, Tomcat 6 introduced a mechanism to achieve this, by prefixing the webapp folder or .war filename with that prefix, separated by a hash. So, e.g.:

${catalina.base}/webapps/tomcat#app1
${catalina.base}/webapps/tomcat#app2.war

...would make both accessible via http://localhost:8080/tomcat/app1/ and http://localhost:8080/tomcat/app2/, respectively, without any further configuration.

It is explained somewhat cryptically in the Tomcat Context Container reference, but see this helpful message on the Tomcat-users mailing list.

Unfortunately, there's a catch: apparently, Cocoon (up to 2.1.11) chokes on webapps whose paths contain a hash (see https://issues.apache.org/jira/browse/COCOON-2270).

So, when you don't have any Cocoon-based webapps running inside Tomcat, adding the 'hashed' prefix to their folder name seems like a possible solution.

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.