LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 02-01-2012, 09:15 AM   #1
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Rep: Reputation: 0
Apache + Tomcat and virtualhosting


Hello everybody,

Am struggling with this issue for 2 days already and none of the documentation I found on the web helps me.

I am running Debian Squeeze, Apache 2, Tomcat 6

on http://10.0.0.1:8080 I get the Tomcat welcome page, on /manager I have succesfully deployed my .war application which now runs on http://10.0.0.1:8080/time - flawlessly

installation of tomcat6 was done by apt-get install tomcat6, have installed mod_jk into apache, apache still serves everything (including php pages)

ajp13 runs and listens on port 8009 (default)

what I now want is to have
http://time.domain.local get the data from http://10.0.0.1:8080/time

And I can't get it to run. My configs are following:

apache vhost file:
Code:
<VirtualHost time.domain.local:80>
     ServerName time.domain.local
     JkLogFile "/var/log/apache2/mod_jk-time.log"
     JkLogLevel debug
     JkMount /time default
     DocumentRoot /var/www/time.domain.local
</VirtualHost>
jk.conf (enabled)
Code:
<IfModule mod_jk.c>
  JkWorkersFile /etc/apache2/workers.properties
  JkShmFile /var/log/apache2/mod_jk.shm
  JkLogFile /var/log/apache2/mod_jk.log
  JkLogLevel info
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  JkRequestLogFormat "%w %V %T"
</IfModule>
tomcat host chunk in server.xml; ajp13 listener enabled aswell:
Code:
      <Host name="time.domain.local" debug="0" appBase="time"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Context path="/time" docBase="webapps/time"/>
      </Host>
application is located in
/var/lib/tomcat6/webapps/time/
- contains META-INF etc (well, it runs, so it should be working)

some .html pages and .php pages are in /var/www/time.domain.local

tomcat6/Catalina contains time/manager.xml which was auto-created probbably

in the apache vhost document root I have created also test.jsp, which is not being parsed for whatever reason
index.html or test.php are served flawleslly/parsed from apache vhost docroot

last lines of mod_jk-time.log:
Code:
[Wed Feb 01 15:23:23 2012] [21497:139895276738368] [debug] jk_translate::mod_jk.c (3542): no match for /README.html found
[Wed Feb 01 15:23:23 2012] [21497:139895276738368] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1036): Attempting to map URI '/README.html' from 1 maps
[Wed Feb 01 15:23:23 2012] [21497:139895276738368] [debug] find_match::jk_uri_worker_map.c (850): Attempting to map context URI '/time=default' source 'JkMount'
[Wed Feb 01 15:23:23 2012] [21497:139895276738368] [debug] jk_map_to_storage::mod_jk.c (3609): no match for /README.html found
[Wed Feb 01 15:24:03 2012] [21500:139895276738368] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1036): Attempting to map URI '/test.jsp' from 1 maps
[Wed Feb 01 15:24:03 2012] [21500:139895276738368] [debug] find_match::jk_uri_worker_map.c (850): Attempting to map context URI '/time=default' source 'JkMount'
[Wed Feb 01 15:24:03 2012] [21500:139895276738368] [debug] jk_translate::mod_jk.c (3542): no match for /test.jsp found
[Wed Feb 01 15:24:03 2012] [21500:139895276738368] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1036): Attempting to map URI '/test.jsp' from 1 maps
[Wed Feb 01 15:24:03 2012] [21500:139895276738368] [debug] find_match::jk_uri_worker_map.c (850): Attempting to map context URI '/time=default' source 'JkMount'
[Wed Feb 01 15:24:03 2012] [21500:139895276738368] [debug] jk_map_to_storage::mod_jk.c (3609): no match for /test.jsp found
Am clueless, drank a lot of koffee and on the edge of my sanity please help

PS: I am no jsp programmer and this is my first time of Tomcat deployment
 
Old 02-01-2012, 09:36 AM   #2
ukiuki
Member
 
Registered: May 2010
Location: Planet Earth
Distribution: Debian, Ubuntu, Tinycore
Posts: 464

Rep: Reputation: 81
All this in a virtual machine ? Is that right? And you want to access this from outside like from internet?
 
Old 02-01-2012, 10:17 AM   #3
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ukiuki View Post
All this in a virtual machine ? Is that right? And you want to access this from outside like from internet?
yes, it's a virtual machine and no, it should be accessible only in an intern network
domain name is correctly set-up and also the DNS Entry is correct. Aswell as /etc/hosts contains correct information (i.e. time.domain.local pointing to 10.0.0.1).
 
Old 02-01-2012, 11:51 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Hi,
Quote:
JkMount /time default
Are you sure the worker name is default? You should use the name as it's defined in workers.properties (usually worker1, tomcat or ajp13). Search for the line "worket.list=..." to see what the actual worker name is.
Also try to add more JkMounts:
Code:
JkMount /time/* <worker name>
JkMount /*/time/* <worker name>
Regards
 
Old 02-02-2012, 02:04 AM   #5
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
Hi,


Are you sure the worker name is default? You should use the name as it's defined in workers.properties (usually worker1, tomcat or ajp13). Search for the line "worket.list=..." to see what the actual worker name is.
Also try to add more JkMounts:
Code:
JkMount /time/* <worker name>
JkMount /*/time/* <worker name>
Regards
my workers.properties file:
Code:
workers.tomcat_home=/var/lib/tomcat6
workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
Also, I have added your suggestion to the vhost apache definition file
when I go to time.domain.local I get only directory listing with test.jsp and test.php, no content from Tomcat
 
Old 02-02-2012, 02:55 AM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Quote:
when I go to time.domain.local I get only directory listing with test.jsp and test.php, no content from Tomcat
What happens if you click on test.jsp?
If you want to serve jsp pages also from your docroot, you can add:
Code:
JkMount /*.jsp default
Also since you have only one worker, you don't need "worker.default.lbfactor=1", so comment it out. Then better restart tomcat first and then apache.

Regards
 
Old 02-02-2012, 03:02 AM   #7
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
What happens if you click on test.jsp?
If you want to serve jsp pages also from your docroot, you can add:
Code:
JkMount /*.jsp default
Also since you have only one worker, you don't need "worker.default.lbfactor=1", so comment it out. Then better restart tomcat first and then apache.

Regards
after clicking now I get
Code:
<html>
<head>
<title>JSP Test Page</title>
</head>
<body>

<h1>JSP Test</h1>

<%
// for(int c = 1; c < 10; c++) {
//   out.println("<P>Iteration " + c + "</P>");
// }
%>

</body>
</html>
after adding your line *.jsp default into vhost I get only a blank page (probbably some kind of error, I go check the logs now)
 
Old 02-02-2012, 03:06 AM   #8
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
log from mod_jk-time
Code:
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1036): Attempting to map URI '/test.jsp' from 4 maps
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] find_match::jk_uri_worker_map.c (850): Attempting to map context URI '/*/time/*=default' source 'Jk
Mount'
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] find_match::jk_uri_worker_map.c (850): Attempting to map context URI '/time/*=default' source 'JkMo
unt'
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] find_match::jk_uri_worker_map.c (850): Attempting to map context URI '/*.jsp=default' source 'JkMou
nt'
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] find_match::jk_uri_worker_map.c (863): Found a wildchar match '/*.jsp=default'
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] jk_handler::mod_jk.c (2462): Into handler jakarta-servlet worker=default r->proxyreq=0
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] wc_get_worker_for_name::jk_worker.c (116): found a worker default
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] wc_maintain::jk_worker.c (339): Maintaining worker default
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] wc_get_name_for_type::jk_worker.c (293): Found worker type 'ajp13'
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] init_ws_service::mod_jk.c (978): Service protocol=HTTP/1.1 method=GET ssl=false host=(null) addr=19
2.168.0.163 name=time.domain.local port=80 auth=(null) user=(null) laddr=192.168.0.53 raddr=192.168.0.163 uri=/test.jsp
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_get_endpoint::jk_ajp_common.c (3093): acquired connection pool slot=0 after 0 retries
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_marshal_into_msgb::jk_ajp_common.c (605): ajp marshaling done
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_service::jk_ajp_common.c (2376): processing default with 2 retries
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): sending to ajp13 pos=4 len=472 max=8192
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): 0000    12 34 01 D4 02 02 00 08 48 54 54 5
0 2F 31 2E 31  - .4......HTTP/1.1
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): 0010    00 00 09 2F 74 65 73 74 2E 6A 73 7
0 00 00 0D 31  - .../test.jsp...1
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): 0020    39 32 2E 31 36 38 2E 30 2E 31 36 3
3 00 FF FF 00  - 92.168.0.163....
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): 0030    10 74 69 6D 65 2E 66 6F 6E 64 61 2
E 6C 6F 63 61  - .time.domain.loca
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): 0040    6C 00 00 50 00 00 0A A0 0B 00 10 7
4 69 6D 65 2E  - l..P.......time.
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): 0050    66 6F 6E 64 61 2E 6C 6F 63 61 6C 0
0 A0 06 00 0A  - domain.local.....
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1152): 0060    6B 65 65 70 2D 61 6C 69 76 65 00 0
0 0D 43 61 63  - keep-alive...Cac
.
.
.
.
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_send_request::jk_ajp_common.c (1628): (default) Statistics about invalid connections: connect check (0), cping (0), send (0)
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_send_request::jk_ajp_common.c (1639): (default) request body to send 0 - request body to resend 0
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1336): received from ajp13 pos=0 len=19 max=8192
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1336): 0000    04 01 90 00 0B 42 61 64 20 52 65 71 75 65 73 74  - .....Bad.Request
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1336): 0010    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  - ................
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_unmarshal_response::jk_ajp_common.c (660): status = 400
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_unmarshal_response::jk_ajp_common.c (667): Number of headers is = 0
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1336): received from ajp13 pos=0 len=2 max=8192
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1336): 0000    05 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00  - ................
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_process_callback::jk_ajp_common.c (1940): AJP13 protocol: Reuse is OK
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_reset_endpoint::jk_ajp_common.c (757): (default) resetting endpoint with sd = 16
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] ajp_done::jk_ajp_common.c (3010): recycling connection pool slot=0 for worker default
[Thu Feb 02 10:03:17 2012] default time.domain.local 0.000644
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] jk_handler::mod_jk.c (2602): Service finished with status=400 for worker=default
 
Old 02-02-2012, 06:00 AM   #9
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Quote:
<snip>
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] find_match::jk_uri_worker_map.c (863): Found a wildchar match '/*.jsp=default'
<snip>
[Thu Feb 02 10:03:17 2012] [2284:139895276738368] [debug] jk_handler::mod_jk.c (2602): Service finished with status=400 for worker=default
So apache matches /*.jsp and sends the request to the mod_jk default worker, but it gets an error 400 (Bad Request).
Move test.jsp in tomcat's webapps/ROOT directory and see if it works. Better clear your browser cache before visiting again test.jsp

Regards
 
Old 02-02-2012, 06:54 AM   #10
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
did that, same result - blank page
but when I went to http://10.0.0.1:8080/test.jsp

the test page got rendered and served properly by Tomcat
 
Old 02-02-2012, 12:33 PM   #11
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Could you try proxy_ajp and see if it works. For this to work, you have to enable mod_proxy and mod_proxy_ajp in your apache configuration.

Then you need to comment out (or remove) any reference to mod_jk and inside your vhost use:
Code:
ProxyRequests Off
ProxyPass /time ajp://localhost:8009/time
ProxyPassReverse /time ajp://localhost:8009/time
 
Old 02-03-2012, 02:32 AM   #12
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
Could you try proxy_ajp and see if it works. For this to work, you have to enable mod_proxy and mod_proxy_ajp in your apache configuration.

Then you need to comment out (or remove) any reference to mod_jk and inside your vhost use:
Code:
ProxyRequests Off
ProxyPass /time ajp://localhost:8009/time
ProxyPassReverse /time ajp://localhost:8009/time
tried it:

Code:
debtime apache2 $ apachectl -t -D DUMP_MODULES
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 jk_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 perl_module (shared)
 php5_module (shared)
 proxy_module (shared)
 proxy_ajp_module (shared)
 python_module (shared)
 reqtimeout_module (shared)
 setenvif_module (shared)
 status_module (shared)
Syntax OK
Code:
<VirtualHost *:80>
     ServerName time.domain.local
     ErrorLog /var/log/apache2/time.domain.local-error.log
     CustomLog /var/log/apache2/time.domain.local-access.log combined
     ProxyRequests Off
     ProxyPass /time ajp://localhost:8009/
     ProxyPassReverse /time ajp://localhost:8009/
     DocumentRoot /var/www/time.domain.local
</VirtualHost>
getting directory listing from documentroot at time.domain.local ; time.domain.local/time gives a blank page
 
Old 02-03-2012, 02:40 AM   #13
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
Curiously enough apache logs do not report anything, is there some option how to see the logs from proxy_ajp and proxy ?
do I need some rewrite rules aswell in some htaccess in DocumentRoot?

the more I spend time on this the more I get disgusted with Java
 
Old 02-03-2012, 03:15 AM   #14
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Hi,

Quote:
<VirtualHost *:80>
ServerName time.domain.local
ErrorLog /var/log/apache2/time.domain.local-error.log
CustomLog /var/log/apache2/time.domain.local-access.log combined
ProxyRequests Off
ProxyPass /time ajp://localhost:8009/
ProxyPassReverse /time ajp://localhost:8009/
DocumentRoot /var/www/time.domain.local
</VirtualHost>
In the Proxy Pass directives above, you have to use the same URI where you have deployed your app. So change them both as in my previous post.
Regarding the logs, everything should be logged in the log files defined in your vhost (time.domain.local-access.log, time.domain.local-error.log)
 
Old 02-03-2012, 07:27 AM   #15
neosk_
LQ Newbie
 
Registered: Dec 2011
Posts: 19

Original Poster
Rep: Reputation: 0
Nope, does not work:

Code:
     ProxyRequests Off
     ProxyPass /time ajp://10.0.0.1:8009/
     ProxyPassReverse /time ajp://10.0.0.1:8009/
getting suicidal Was also thinking already to do some with some rewrite engine, but aaaah
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session replication using apache+mod_jk+tomcat(5.5.28-veriosn of tomcat) sreejithp Linux - Server 1 12-24-2010 06:46 AM
When enabling Virtualhosting in Apache on Slackware Sargalus Linux - Software 6 03-04-2010 05:49 PM
apache-tomcat and jakarta-tomcat shifter Programming 1 07-28-2007 10:36 PM
Why use Apache with Tomcat rather than just Tomcat itself? davee Linux - Software 1 08-21-2003 09:47 PM


All times are GMT -5. The time now is 05:36 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration