Andre Warnier wrote: > Lentes, Bernd wrote: > > Hi, > > > > first, i'm new to tomcat and i'm not a java developer. > > You have all my sympathy. > > > My collegues developed a web application i have to deploy > now. I'm using tomcat6 on a sles 11 sp1 box. > > I configured a httpd (apache 2.2.10) in front of the > tomcat, which communicates with tomcat using AJP. > > When i open one link, i don't see the desired web page, but > the source code of it. Using tcpdump shows me that the > content type in the http-header is text/plain. > > That is typical of a bad/dangerous configuration of Apache, > mod_jk and Tomcat. > You are probably > a) allowing Apache to "see" the contents of the Tomcat > webapps directory directly (e.g. by setting the Apache > DocumentRoot = the Tomcat webapps dir.)
No. webapps=/srv/tomcat6/webapps DocumentRoot=/srv/www/htdocs > b) not properly indicating to Apache/mod_jk that these URLs > must be proxied to Tomcat via mod_jk (JkMount instructions). > mod_jk.conf: ... JkMount /mouseidgenes/* appl01 ... > As a consequence, when you request from Apache a URL like > (for example) "/myapp/something.jsp", Apache goes directly to > that file and serves it back to the browser. Of course since > Apache does not know what a .jsp file is, it treats it as > plaint text and that is what it says in the Content-type header. > > > Do the following test to confirm the above : > request the URL "/myapp/WEB-INF/web.xml" > (where "myapp" is the first part of the URL for a Tomcat application). HTTP Error 404. > > > Can i configure the content-type which is delivered by tomcat ? > > You can, but you should not have to, because it is not the > problem here. > Tomcat never receives the request for that file; It does receive the request. I log all the AJP stuff, and you see there, among others: This is the request from the client: ... [Tue May 31 20:51:46 2011] [24717:4165998336] [debug] init_ws_service::mod_jk.c (888): Service protocol=HTTP/1.1 method=GET host=(null) addr=146.107.135.80 n ame=vm53200-12 port=80 auth=(null) user=(null) laddr=146.107.35.101 raddr=146.107.135.80 uri=/mouseidgenes/InputData ... The reponse: ... [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_unmarshal_response::jk_ajp_common.c (608): status = 200 [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_unmarshal_response::jk_ajp_common.c (615): Number of headers is = 0 [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1117): received from ajp13 pos=0 len=8188 max=8192 [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1117): 0000 03 1F F8 3C 48 65 61 64 3E 3C 74 69 74 6C 65 3E - ...<Head><title> [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1117): 0010 4D 6F 75 73 65 49 44 47 65 6E 65 73 3C 2F 74 69 - MouseIDGenes</ti [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1117): 0020 74 6C 65 3E 3C 2F 68 65 61 64 3E 0A 0D 0A 3C 73 - tle></head>...<s [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1117): 0030 63 72 69 70 74 20 74 79 70 65 3D 27 74 65 78 74 - cript.type='text [Tue May 31 20:51:48 2011] [24717:4165998336] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1117): 0040 2F 6A 61 76 61 73 63 72 69 70 74 27 20 73 72 63 - /javascript'.src ... > If you want further help, give us an idea of the layout on > disk of your Apache and Tomcat directories, and of the URLs > that should be processed by Tomcat. > OK: vm53200-12:/etc/apache2 # l /usr/share/tomcat6/ total 12 drwxr-xr-x 3 root root 4096 Apr 18 16:33 ./ drwxr-xr-x 200 root root 4096 May 30 08:00 ../ drwxr-xr-x 2 root root 4096 Apr 18 16:33 bin/ lrwxrwxrwx 1 root root 12 Apr 18 16:33 conf -> /etc/tomcat6/ lrwxrwxrwx 1 root root 15 Apr 18 16:33 lib -> ../java/tomcat6/ lrwxrwxrwx 1 root root 16 Apr 18 16:33 logs -> /var/log/tomcat6/ lrwxrwxrwx 1 root root 23 Apr 18 16:33 temp -> /var/cache/tomcat6/temp/ lrwxrwxrwx 1 root root 20 Apr 18 16:33 webapps -> /srv/tomcat6/webapps/ lrwxrwxrwx 1 root root 18 Apr 18 16:33 work -> /var/cache/tomcat6/ vm53200-12:/etc/apache2 # l /srv/www/ total 16 drwxr-xr-x 4 root root 4096 Apr 17 17:46 ./ drwxr-xr-x 5 root root 4096 Apr 18 16:33 ../ drwxr-xr-x 2 root root 4096 Apr 17 17:49 cgi-bin/ drwxr-xr-x 3 root root 4096 May 23 18:08 htdocs/ URL that should be processed: http://vm53200-12/mouseidgenes/InputData (talking to httpd in front of tomcat, result is source code in the browser) http://vm53200-12:8080/mouseidgenes/InputData (talking directly to tomcat coyote, result is a correctly displayed web page). Bernd Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671