Tomcat, Apache and Application in / context path

J

Joshua

I have Apache configured with Tomcat using mod_jk2. For example:

Apache runs on port 80
Tomcat runs on port 8080

I can access Tomcat resources by connecting to port 80 through apache.

I have deployed a war file using the Tomcat Web Application Manager.
This by default uses the name of the war file as its context path.

What I want is to deploy an application in Tomcat so that when I
access http://<address> on the default port 80 the webapp is served
instead of http://<address>/<context path>/.

I have searched this newsgroup but unfortunately haven't found
anything of help.
 
J

Juha Laiho

(e-mail address removed) (Joshua) said:
I have Apache configured with Tomcat using mod_jk2. For example:

Apache runs on port 80
Tomcat runs on port 8080

I can access Tomcat resources by connecting to port 80 through apache.

I have deployed a war file using the Tomcat Web Application Manager.
This by default uses the name of the war file as its context path.

What I want is to deploy an application in Tomcat so that when I
access http://<address> on the default port 80 the webapp is served
instead of http://<address>/<context path>/.

Two choices;
1.
- you could set up Apache so that requests to anything (except starting
with /<context path>/ are redirected either internally or externally
to resources within /<context path>/
2.
- deploy your webapp so that it takes over the Tomcat root context
(might need manual creation of context XML file)
- configure mod_jk2 to take over the Apache root "directory"
(have done this with mod_jk, but the configuration for mod_jk2
is wildly different)
 
J

Joshua

Juha Laiho said:
(e-mail address removed) (Joshua) said:

Two choices;
1.
- you could set up Apache so that requests to anything (except starting
with /<context path>/ are redirected either internally or externally
to resources within /<context path>/

This sounds like the easiest way forward. Any pointers on how please?
2.
- deploy your webapp so that it takes over the Tomcat root context
(might need manual creation of context XML file)

Thought about this one, but doing so would obviously lose the
functionality provided there at present e.g. manager. I tried taking
a copy of the root folder and creating a new deployment from the
copied folder. The index page comes up but if you click on manager
the link is broken.
 
J

Joshua

Juha Laiho said:
(e-mail address removed) (Joshua) said:

Two choices;
1.
- you could set up Apache so that requests to anything (except starting
with /<context path>/ are redirected either internally or externally
to resources within /<context path>/

I've done some more digging around to try get this option working.
I've read up about ProxyPass in Apache. I have entered something like
the following in my httpd.conf:

ProxyPass / http://<address>:8080/<context path>/

What this does now is requests are going through apache but under the
covers Tomcat is serving the content. Is this the method you had in
mind? An issues to be aware of with this?

Only concern I have with this is, and it might not be an issue because
I wont necessarily have other webapps on this server, it is no longer
possible to access a web app from tomcat through apache - e.g.
http://<address>/<context path>.


<snip>
 
J

Juha Laiho

(e-mail address removed) (Joshua) said:
I've done some more digging around to try get this option working.
I've read up about ProxyPass in Apache. I have entered something like
the following in my httpd.conf:

ProxyPass / http://<address>:8080/<context path>/

What this does now is requests are going through apache but under the
covers Tomcat is serving the content. Is this the method you had in
mind? An issues to be aware of with this?

It's some time since I played with redirections (and it was w/Apache 1.3),
and I recall there's another way, too - and so that you wouldn't be
dependent on the 8080 port of Tomcat, but would still be using the mod_jk2.
Hmm.. have you tried ProxyPass'ing to the Apache itself - i.e. to
http:// said:
Only concern I have with this is, and it might not be an issue because
I wont necessarily have other webapps on this server, it is no longer
possible to access a web app from tomcat through apache - e.g.
http://<address>/<context path>.

Even that shouldn't be an issue - as long as you ProxyPass the other
contexts before the root context.

But still I recall there were other ways -- perhaps even simple Alias
directives would do?
 
D

dundonald

Juha Laiho said:
(e-mail address removed) (Joshua) said:

It's some time since I played with redirections (and it was w/Apache 1.3),
and I recall there's another way, too - and so that you wouldn't be
dependent on the 8080 port of Tomcat, but would still be using the mod_jk2.
Hmm.. have you tried ProxyPass'ing to the Apache itself - i.e. to


Even that shouldn't be an issue - as long as you ProxyPass the other
contexts before the root context.

But still I recall there were other ways -- perhaps even simple Alias
directives would do?

There was a lot of farting around with the proxy pass. It worked well, but
the JSP's were still requesting servlets from the root context. So in the
end I deployed the application to the root context of tomcat. There's now
no need to use proxy pass at all. Instead apache running on port 80 uses
mod jk2 to call tomcat on port 8080.

All working ok now. Thanks.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top