apache tomcat connector - website configuration - apache

I have deployed website serving traffic from apache which get pages from tomcat. i have configured mod_jk connector and everything is working fine.
say for example my website url is http://<mywebsite.com>
my tomcat deployed application app name test app
Problem is im only able to browse the site when i browse http://<mywebsite.com>/testapp but i want apache to serve pages when i browse just my website http://<mywebsite.com> and it is not happening at the moment. below is my apache httpd.conf file and testapp is my deployed application name on tomcat.
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogStampFormat "[%b %d %Y - %H:%M:%S] "
JkRequestLogFormat "%w %V %T"
JkLogLevel info
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
Alias /testapp "C:/Items/Installation Directories/Tomcat7.0/webapps/awardio/"
<Directory "C:/Items/Installation Directories/Tomcat7.0/webapps/awardio/">
AllowOverride None
Allow from all
</Directory>
<Location /*/WEB-INF/*>
deny from all
</Location>
JkMount /testapp/* myworker
do i need to mod_rewrite or something or configure virtual host.
it is fairly urgent so appreciate your help?

my tomcat deployed application app name test app
You need to change the deployed app name to ROOT. So you can just rename the war file to ROOT.war

Related

error starting apache 2.4 with mod_jk

For reference I used this guide to setup integration between tomcat 7 and apache 2.4, with the mod_jk. https://www3.ntu.edu.sg/home/ehchua/programming/howto/ApachePlusTomcat_HowTo.html
When opening cmd in windows and doing a: c:\Apache24\bin> httpd -k start I get the follow error
httpd: Syntax error on line 526 of C:/Apache24/conf/httpd.conf: Syntax error on line 1 of C:/Apache24/conf/mod_jk.conf: Cannot load modules/mod_jk.so into server: access denied.
Below is the two files which has syntax errors.
mod_jk.config
LoadModule jk_module modules/mod_jk.so
JkWorkersFile C:/Program Files/Apache Software Foundation/Tomcat
7.0/conf/workers.properties
JkLogFile C:/Program Files/Apache Software Foundation/Tomcat 7.0/logs
JkLogLevel info
JkOptions +ForwardkeySize +ForwardURICompat +ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /rehavoc ajp13 jkMount /rehavoc/* ajp13
httpd.config
include C:/Apache24/conf/mod_jk.conf
Tomcat 7 is properly setup(I hope) Since I can in tomcat manager, deploy a war file with a test servlet running and see it work on the localhost/url.
Apache 2.4 should also be working seeing my web site is live and can be accessed on the web(just a simple hello world html).
Operating system is vista.
Also, have I understood correctly that with these three 'services' will I be able to deploy a war file into apache htdocs, including jsp/servlets and it will have no trouble running on my site?
Any help is appreciated.
Solved it by not using apache 2.4 and mod_jk. Were better to just use tomcat 7 alone from the start.

Tomcat load-balancing with mod_jk

Newbie to this technology hence pls be gentle. Aim is to setup Tomcat load-balancing with mod_jk.
My setup is below (all on one machine):
Win7 x64
Apache Httpd 2.2
Tomcat 6
mod_jk 1.2.37 (for httpd2.2.x)
2 Tomcat instances (same machine)
I've setup Tomcat correctly and can access the webapps via localhost:8080 and localhost:8081.
But when I try to access the webapps via Httpd (localhost/dept1 or localhost/dept2), I get "404 Not Found " The requested URL /dept1 was not found on this server.
Httpd works when accessed by URL, http: //localhost "It works!"
The only lines added to httpd.conf (Apache2.2) are:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile C:/ApacheHTTPD/conf/workers.properties
JkLogFile C:/ApacheHTTPD/logs/mod_jk.log
JkLogLevel emerg
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat +ForwardDirectories
JkRequestLogFormat "%w %V %T %p %q %r %v %U"
JkMount /%CATALINA_HOME%/webapps/dept1/* tomcatbase
JkMount /%CATALINA_HOME2%/webapps/dept2/* tomcat1
workers.properties file contains:
worker.list=tomcatbase,tomcat1
worker.tomcatbase.type=ajp13
worker.tomcatbase.host=localhost
worker.tomcatbase.port=8009
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8010
All other setup is (Apache and the 2 Tomcat instances) are default.
Now, http:// localhost:8080/dept1 works. So is it that the redirect from Apache to Tomcat isn't working?
Thanks in advance
Bharath
Try this:
JkMount /dept1/* tomcatbase
JkMount /dept2/* tomcat1
The first parameter of the JkMount directive is a URL prefix, not a local path.
JkMount [URL prefix] [Worker name]
Please see http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html for more details.

I want to integrate tomcat and apache using mod_jk for my grails application

I'd like to integrate tomcat and apache using mod_jk for my grails application. I want my static resources to be served from apache. The resources must be outside the application. I did the settings for apache like:
ProxyPass /appName ajp://localhost:8009/appName
ProxyPassReverse /appName ajp://localhost:8009/appName
Please let me know how to do this....
ProxyPass is a directive used by mod_proxy not mod_jk.
If you want to use mod_jk use:
JkMount /appName/* workerApp
For this to work you need to configure the module (/etc/apache2/mods-available/jk.load):
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
then add a worker (/etc/apache2/workers.properties):
workers.tomcat_home={PATH_TO_TOMCAT}
workers.java_home={PATH_TO_JVM}
ps=/
worker.list=workerApp
worker.workerApp.port=8009
worker.workerApp.host=localhost
worker.workerApp.type=ajp13
worker.workerApp.lbfactor=1
Be sure this line is not commented in Tomcat server.xml:
<Connector port="8009" address= "127.0.0.1" enableLookups= "false" redirectPort= "8443" protocol= "AJP/1.3" />
The Apache Tomcat Connector - Reference Guide is a good source of information for mod_jk configuration.

Spring Session Replication Problem

I've currently researching in load balancing my Spring project. I've used Apache web server as front-end to multiple Tomcat instances. I've used mod_jk for the load balancing. When I run it, if I shutdown one server, i had to login again to the system. Previously I also tried it in simpler example with the Tomcat's session example program and the session replication worked fine.
This is my configuration for the Apache's httpd.conf mod_jk part:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/jk.log
JkLogLevel debug
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /test balancer <-- this is the spring program
JkMount /test/* balancer <-- this is the spring program
JkMount /jk_status status`
And this is my workers.properties setting:
workers.tomcat_home=/worker1
workers.java_home=$JAVA_HOME
ps=/
worker.list=balancer,status
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker2.port=8109
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.balancer.type=lb
worker.balancer.balance_workers=worker1,worker2
worker.balancer.method=B
worker.balancer.sticky_session=1
worker.status.type=status
And I've put a sample of one of my tomcat's server.xml here: http://pastebin.com/0j0ta2WA
I've also added <distributable/> tag to my application's web.xml. Is there something I missed here that made the session replication not working?
Tomcat 5.5
Apache 2.2
mod_jk
Spring 2.5.6
JDK 1.6.0_01
Do you have a jvmRoute defined in your server.xml?
Here are the docs:
http://tomcat.apache.org/tomcat-5.5-doc/config/engine.html
I would have looked at your server.xml but the link is wrong.

Apache httpd 2.2.x + mod_jk 1.2.30 + tomcat 6 Error: Could not find worker with name 'XXXXX' in uri map post processing

I am getting the following error while setting up the load balancer with two Tomcat instances:
[info] mod_jk.c (3189): mod_jk/1.2.30 initialized
[error] jk_uri_worker_map.c (506): Could not find worker with name 'loadmanager' in uri map post processing.
Following are my configuration settings:
httpd.conf changes
# Include mod_jk configuration file
Include conf/mod_jk.conf
mod_jk.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /TestLB1/ loadmanager
JkMount /TestLB1/* loadmanager
JkShmFile logs/jk.shm
workers.properties
worker.list=loadmanager
worker.tomcat1.port=18081
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
worker.tomcat2.port=28081
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
worker.loadmanager.type=lb
worker.loadmanager.balance_workers=tomcat1,tomcat2
worker.loadmanager.sticky_session=True
In Tomcat's server.xml I have set the jvmRoute attribute to Engine also
<Engine defaultHost="localhost" name="Catalina" jvmRoute="tomcat1">
<Engine defaultHost="localhost" name="Catalina" jvmRoute="tomcat2">
Both the Tomcat instances are up and running fine with AJP ports 18081 & 28081 respectively.
But while starting the Apache httpd.exe the mod_jk log files always shows the above error, and when I try to access my web app through http://localhost/TestLB1 nothing comes up.
Any Solution?
Got the problem....
Issues is with the text editor in which i was editing my worker.properties file , it adds few special chars to files.
I found them when i opend the files in notepad only.
After removing all unwanted chars everythings works perfect.
Create your worker.properties file with a good text editor like notepad++. Not doing so may add some unseen special characters and workers.properties file wont parse by mod_jk.