Override Apache tomcat behaviour
I have a Tomcat application installed in a Redhat server and it performs services for a set of users.
I have another html/cgi script that obtains informations from an SQL database resident on that server which works on another test server (without Tomcat)
How can I use the Apache server to also serve my html file alongside the installed Tomcat application. I see this being done on another port than the usual port 80.
I tried adding a directive listening on port 8081 and defining a DocumentRoot. A browser responds "Unable to connect"
I can run an independent web server such as python twisted (and others i have tried) and independently serve a static web page on port 8081.
That works for static pages but its too difficult to get the CGIs workin. It would be best to use Apache since I know it works with Apache and I don't have to reinvent a web server.
I can perhaps run an independent Apache process but before going to all that trouble I would be happier configuring the existing Apache instance to access normal web pages as well as being intercepted by Tomcat.
I'm not sure I smell what you're cooking. Basically what you want to do is to serve a servlet from Tomcat while still executing normal html+cgi using Apache (outside of Tomcat). That can totally be done and they both can be served on the same port. Apache would proxy Tomcat.
This is what the Apache JServ Protocol was invented for (among other things). You can use mod_proxy, mod_cluster, or mod_jk to accomplish connecting Apache and Tomcat together. Since you're using AJP you could remove the HTTP (port 8080) and HTTPS (port 8443) connectors from Tomcat. mod_proxy is most recommended if you're going to use AJP (mod_cluster is still relatively new and I don't have much experience with it).
*Edit* After reading more docs there appears to be a mod_proxy_ajp module.
I found that while reading http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html
Either way I still recommend that method. You'll get better performance out of it.
Thanks but not what I'm after
Apache and Tomcat are already set up and serving an application called DSpace.
DSpace has a postgres database and I'm extracting information with another program.
I don't want to use Tomcat. I want a normal web page and and associated cgi script to run in the usual way and on a different port.
Suppose my server is called clinical.com.au
and I have a "hello World" web page.
If a browser points to httpd://clincal.com.au then it presents the Tomcat application.
If the browser points to httpd://clincal.com.au:8081 then the broser gets the "Hello World" page.
If I run a Python web server on port 8081 then I get the desired behaviour but I can't do any cgi stuff.
I I can get Apache to do this then that would be excelent.
What you ask is still possible.
You would have to modify httpd.conf and change the port.
Depends on your OS as to where it is located but you basically need to change the following value.
Thanks but not going to work
You can't just change the port because that will disable the Tomcat application listening on port 80. The idea is that a browser going to port 80 gets the Tomcat app and a browser going to 8081 get my fabulous web pages.
I think I solved it by installing a complete separate instance of Apache.
Very clear istruction on how to do this are at
This allows a completely different set of configurations and web page directories. You can also run the second sever as a different user than apache and keep everthing nice and separate from the other server. I installed and it serves the web page on port 8081 will Tomcat is seen on 80.
I am held up getting the cgi to work as is sometimes the way with initial Apache configs. I suddenly got all these other jobs to get done so this project is parked for a few days. However I am sure it will work.
Anyway thanks for your suggestions.
You can have Apache httpd listen on multiple ports for different purposes using VirtualHosts. You don't need a second installation of Apache httpd, that would not be smart and resource intensive. The peg can fit in the hole with tweaking, no need to force it with several httpd instances (analogy).
I had recently specified VirtualHosts for someone so you can check out the sample configs or look it up in Apache docs. Change the port numbers respectively.
I tried a virtual host running on a different port and got a
"browser could not connect error". I mentioned this in my first post. Sorry if it wasn't clearer.
I was unaware that Tomcat could run without Apache which ay be the source of confusion.
There may be some configuration that allows both TOmcat and Apache (normal operation to work but after a lot of effort nothing has worked for me and that is why I posted.
A separate apache installation was a bit of work doing the install but less than figuring out a virtual host/whatever combination.....and hey! It works!
In my instance I don't think the extraa httpd processes will impact our performance.
The only draw back to doing that is you don't have any load balancing and redundancy (i.e. single httpd with multiple Tomcat instances to share the workload). If you're not using Apache like that then there's no reason to worry because Tomcat fully supports HTTP/1.1.
|All times are GMT -5. The time now is 07:55 PM.|