Re: PROBLEM - APACHE HTTPD IS SERVING JSP SOURCE CODE

2012-11-16 Thread Pete Storey
Yup, your mount point aren't quite right:

- They need to be in a virtual host if they are for that (or turn on
inheritance)
- You have to mount _either_ a path or an extension - not both - i.e.
JkMount *.jsp or JkMount /myapp - not what you've got with JkMount /*.jsp

cheers
Pete


On 17 November 2012 08:12, André Warnier a...@ice-sa.com wrote:

 Casper Wandahl Schmidt wrote:

 Den 16-11-2012 21:26, Farid Haider skrev:

 Hi.

 I have Fedora 17 (Kernel Linux 3.6.6-1.fc17.i686) installed in an ASUS
 laptop (A6Jseries).

 I have Apache/2.2.22 installed that came with the Fedora 17.

 I have the following Java:
 java version 1.7.0_09-icedtea
 OpenJDK Runtime Environment (fedora-2.3.3.fc17.1-i386)
 OpenJDK Client VM (build 23.2-b09, mixed mode)
 and is installed in /usr/lib/jvm/java-1.7.0-**openjdk-1.7.0.9/

 I have downloaded Tomcat 7 and installed in /usr/local/tomcat7 (tar
 -zxvf apache-tomcat-7.0.27.tar.gz)

 After starting Tomcat (/usr/local/tomcat7/bin/**startup.sh) it works
 fine.
 When openning the browser http://localhost:8080 the “Apache
 Tomcat/7.0.32” page opens without problems.

 To integrate Apache with Tomcat I have installed Tomcat Connectors JK
 1.2 (mod_jk module) as follows:
 su -
 [root@asuslaptop ~]# cd /etc/httpd/modules
 [root@asuslaptop modules]#wget
 http://archive.apache.org/**dist/tomcat/tomcat-connectors/**
 jk/binaries/linux/jk-1.2.31/**i386/mod_jk-1.2.31-httpd-2.2.**x.sohttp://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/i386/mod_jk-1.2.31-httpd-2.2.x.so
 [root@asuslaptop modules]# mv mod_jk-1.2.31-httpd-2.2.x.so mod_jk.so
 [root@asuslaptop modules]# chmod 755 mod_jk.so

 I have created file workers.properties in /etc/httpd/conf.d/ (as
 follows)
 [root@asuslaptop modules]# cd /etc/httpd/conf.d/
 [root@asuslaptop conf.d]# cat  /etc/httpd/conf.d/workers.**properties
 workers.tomcat_home=/usr/**local/tomcat7/
 workers.java_home=/usr/lib/**jvm/java-1.7.0-openjdk-1.7.0.**9/
 ps=/
 worker.list=worker1
 worker.worker1.type=ajp13
 worker.worker1.host=localhost
 worker.worker1.port=8009
 worker.worker1.lbfactor=50

 I have created file mod_jk.conf in /etc/httpd/conf.d/ (as follows)
 [root@asuslaptop conf.d]#cat  /etc/httpd/conf.d/mod_jk.conf
 JkWorkersFile /etc/httpd/conf.d/workers.**properties
 JkLogFile logs/mod_jk.log
 JkLogLevel info
 JkMount /*.jsp worker1
 JkMount /servlet/* worker1
 JkMount /*.do worker1
 JkLogStampFormat [%a %b %d %H:%M:%S %Y] 

 I have edited httpd.conf as follows:
 [root@asuslaptop conf.d]# cd /etc/httpd/conf/
 [root@asuslaptop conf]# vi httpd.conf
 - added the line:
 LoadModule jk_module modules/mod_jk.so
 - Edited the following line to be:
 DirectoryIndex index.htm default.htm default.jsp
 - I have added the following virtual host:
 VirtualHost *:80
  ServerAdmin fhai...@odline.com
  DocumentRoot /var/www/html/lofttreasures
  ServerName www.lofttreasures.com
  ErrorLog logs/lofttreasures.com-error_**log
  CustomLog logs/lofttreasures.com-access_**log common
 /VirtualHost
 - At the end if the file I have inserted:
 Include conf.d/*.conf

 I have edited the file server.xml:
 [root@asuslaptop conf]# cd /usr/local/tomcat7/conf/
 [root@asuslaptop conf]# vi server.xml
 Before “/Engine” tag I have inserted the following:
 Host name=www.lofttreasures.com debug=0 appBase=/var/www/html
  unpackWARs=true autoDeploy=true xmlValidation=false
 xmlNamespaceAware=false
 /Host

 In Catalina directory I have created the following:
 [root@asuslaptop conf]# cd /usr/local/tomcat7/conf/**Catalina/
 [root@asuslaptop Catalina]# mkdir  www.lofttreasures.com
 [root@asuslaptop Catalina]# cd www.lofttreasures.com/
 Created the file context.xml and edit as follows:
 [root@asuslaptop www.lofttreasures.com]# vi context.xml
 Context path= docBase=lofttreasures debug=0 reloadable=false
 crossContext=false
 /Context

 I have restarted the Tomcat with:
 [root@asuslaptop ~]# /usr/local/tomcat7/bin/**shutdown.sh
 [root@asuslaptop ~]# /usr/local/tomcat7/bin/**startup.sh

 I have started Apache with:
 [root@asuslaptop ~]# service httpd start

 I have checked if the Tomcat and Apache started with:
 [root@asuslaptop ~]# ps -U root -u root u
 The result is:
 //bin/java
 -Djava.util.logging.config.**file=/usr/local/tomcat7/conf/**logging ...
 /usr/sbin/httpd -k start

 Tomcat seems to work fine when I test in a browser with
 http://localhost:8080/ it opens  the “Apache Tomcat/7.0.32” page.

 If I test the Apache only by trying in the browser
 www.lofttreasures.com it open the test HTML page without problems.

 The problem is when I try to open a JSP page with
 www.lofttreasures.com/index.**jsphttp://www.lofttreasures.com/index.jspI 
 get the page with the JSP source code.

 I would appreciate it very much if I could get help to solve this
 problem.

 Try reading this:
 http://tomcat.apache.org/**connectors-doc/webserver_**howto/apache.htmlhttp://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
 Especially the warning in the 

Re: [OT] mod_jk and mod_rewrite

2012-11-05 Thread Pete Storey
Hi

Thanks for the various timely emails - I am in Australia hence I am in
front of you time wise!

What I didn't see was any actual answer to the question though - just
queried the email list for this thread and this was the first reply I got!
 Could you resend your actual answer?

Cheers
Pete




On 05/11/2012 21:24, André Warnier a...@ice-sa.com wrote:

By the way, your message shows a time that sems out of whack, as compared
to my time, but 
also as compared to the other messages on the list.
This can create some problems for people who follow this list by date/time
(*).  You may 
want to check the date/time on your workstation.

(*) For example, it looks like I answered your question before you even
asked it.
This would be a useful gift to have, except that I don't believe that I
have Pid's 
crystall ball at the moment, so I think your workstation time is the
culprit.






-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



mod_jk and mod_rewrite

2012-11-04 Thread Pete Storey
Hi

I've got what I think is a pretty normal setup, where I have an Apache
server serving some content for a website, and using mod_jk to connect to
Tomcat running on another server.  My problem is that I'm also trying to
use mod_rewrite to ­ err, rewrite URLs.  In short, if I do this the
'normal' way and include rewrite directives in the .htaccess file for the
website, it doesn't work and they are ignored, however if I put them in
the main httpd.conf file, before the JkMount directive, then they do work.

This appears to be a case of a problem with the order in which
modules/filters hook into Apache and are run;  I have looked at the
documentation and searched about for answers on this but found nada.  I've
tried using the various JkOptions setups but it doesn't seem to achieve
much.

In my httpd.conf, mod_rewrite is loaded before mod_jk though I don't think
this matters especially.

Some potentially relevant config -

- in httpd.conf

Directory /
Options FollowSymLinks
AllowOverride None
/Directory

Directory /var/www/html

Options -Indexes +FollowSymLinks

  LimitExcept GET HEAD POST
 deny from all
  /LimitExcept

AllowOverride All

Order allow,deny
Allow from all

/Directory

AccessFileName .htaccess

JkWorkersFile /etc/httpd/conf/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
# Rotate weekly
JkLogFile |/usr/sbin/rotatelogs /var/log/httpd/mod_jk.log 604800
JkLogLevelwarn
JkLogStampFormat [%a %b %d %H:%M:%S %Y] 
#JkOptions +ForwardURIProxy

- Inside the (included into httpd.conf) virtual host.conf file



RewriteEngine on
Include vhosts/htaccess/mysite.htaccess

# Mount all to Tomcat
JkMount /* mysite
# Handle images locally
JkUnMount /*.gif mysite
JkUnMount /*.jpg mysite
JkUnMount /*.jpeg mysite
JkUnMount /*.png mysite

- Inside the my site.htaccess file (example line)



# McAfee secure image
RewriteRule ^/assets/cached/mcafee\.png /assets/php/mcafeeimage.php [L,NC]

Now this all works fine - except that I have to have a file which is
directly included into the httpd.conf, and which thus requires the server
to be restarted every time you want to make a change.  On top of that, if
there is a problem in the file, then the whole server will fail to start,
which is clearly far from ideal.

Is there a way to hook in the RewriteEngine in .htaccess rather than
having to include them like this?  I can't believe I am the first person
to discover this/have this setup?

Many thanks
Pete






-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Bug with 404 handling in mod_jk?

2012-10-11 Thread Pete Storey
Hi,

I think I've found a small bug in mod_jk relating to the way it handles 404
errors, though it's possible it's a configuration problem (but I don't think
so).  Wondering if anyone can help?

In essence, we have a Centos 5.8 box running Apache 2.2.3-65 (as they call
it ­ it's the latest version in the repositories), with mod_jk 1.2.37
(downloaded and built today, though had been running I think .32 before),
connecting to a Tomcat server on another machine running version 6.0.35.

The virtual server is setup with a JkMount /* mapping, so that everything is
by default passed to Tomcat, then several JkUnmount /*.extension mappings to
'unman' various static extensions I want Apache to handle directly (e.g.
*.png, *.php, *.pdf and so on).

The configuration is as follows:

#
# Generic Tomcat connector setup
#
JkWorkersFile /etc/httpd/conf/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile |/usr/sbin/rotatelogs /var/log/httpd/mod_jk.log 86400
JkLogLevelinfo
JkLogStampFormat [%a %b %d %H:%M:%S %Y] 

# Inside the virtual host setup


# Mount all to Tomcat

JkMount /* 1c

# Handle /blog locally

JkUnMount /blog/* 1c

# Handle images locally

JkUnMount /*.gif 1c

JkUnMount /*.jpg 1c

JkUnMount /*.jpeg 1c

JkUnMount /*.png 1c

JkUnMount /*.ico 1c

# Handle media locally

JkUnMount /*.txt 1c

JkUnMount /*.pdf 1c

JkUnMount /*.swf 1c

JkUnMount /*.flv 1c

# Handle JS/CSS locally

JkUnMount /*.js  1c

JkUnMount /*.css 1c

# Handle PHP locally

JkUnMount /*.php 1c


The problem can be seen on the actual website;  if you make a request which
should generate a 404 response to a URL handled by Tomcat, all is well,
however if you make one that should be handled by Apache, you do get the 404
content (served, it turns out, by Tomcat not Apache), but a 200 response
code.  This isn't ideal obviously.  I know that the content is being served
by Tomcat because I have tried putting different 404 page content on Apache
and Tomcat and I always get the Tomcat version.

http://www.1cover.com.au/thiswill404 - This is handled by Tomcat
http://www.1cover.com.au/thiswill404.css - This should be handled by Apache
(but isn't) and gives a 200 response code

If I turn off the JkUnmount for, say, the css extension, then it is handled
by Tomcat and I get the correct 404 response code ­ it seems that if you
JkUnmount an extension, and the file isn't found by Apache, it forwards to
Tomcat anyway but disregards the response from Tomcat?

Any help would be appreciated

Thanks
Pete




Re: Bug with 404 handling in mod_jk?

2012-10-11 Thread Pete Storey
Ah ha, well spotted, thanks!  Indeed the ErrorDocument pointed to 404.htm,
and htm hadn't been unmapped.  Now I have done, it works fine!

Cheers
Pete



On 11/10/2012 17:34, Christopher Schultz ch...@christopherschultz.net
wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Pete,

On 10/11/12 11:44 AM, Pete Storey wrote:
 I think I've found a small bug in mod_jk relating to the way it
 handles 404 errors, though it's possible it's a configuration
 problem (but I don't think so).  Wondering if anyone can help?

 [snip]

 JkMount /* 1c JkUnMount /blog/* 1c JkUnMount /*.gif 1c [...]
 
 The problem can be seen on the actual website;  if you make a
 request which should generate a 404 response to a URL handled by
 Tomcat, all is well, however if you make one that should be handled
 by Apache, you do get the 404 content (served, it turns out, by
 Tomcat not Apache), but a 200 response code.

So, you make a request to, say, /does-not-exist.gif and you get
Tomcat's 404 error page (content) with a 200 response code?

Do you have any ErrorDocument directives? If so, I suspect what is
happening is this:

HTTP request for /does-not-exist.gif
- - HTTP handles request, does not find file,
   triggers 404 event, sets response code=404
- - 404 event handled by ErrorDocument, specifies e.g. /404.html
- - /404.html configured to be handled by Tomcat (per JkMount above)
- - Tomcat receives request, completes correctly, sets response code=200

If you do have an ErrorDocument, you might have to UnMount that one, too.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlB29QoACgkQ9CaO5/Lv0PCD+ACdHSJkqEyRaiwN/UH6r0aYUCDC
ydYAmgPUiRKCxxEwTFQII+p+9rZ6wiPd
=9gOv
-END PGP SIGNATURE-




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org