You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Blackwell <ch...@team193.com> on 2009/10/30 15:47:57 UTC

tomact, apache & adobe coldfusion 9

Hi all,


I've setup tomcat and apache on my workstation, and unpacked the contents of
the coldfusion 9 war file to my application root.
I have added Host in server.xml and can browse to http://mysite.dev:8080 and
everything runs fine.

looks like this

<Host name="mysite.dev" appBase="webapps"
unpackWARs="true" autoDeploy="true"
 xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="C:\Users\Chris\Documents\Eclipse Workspace\mysite"
/>
</Host>

So i then wanted to connect apache to tomcat, so i've setup apache with a
virtualhost

<VirtualHost *:80>
DocumentRoot "C:\Users\Chris\Documents\Eclipse Workspace\mysite"
 ServerName mysite.dev

ProxyPreserveHost On
ProxyPassReverse / ajp://localhost:8009/

RewriteEngine On
# If it's a CFML (*.cfc or *.cfm) request, just proxy it to Tomcat:
 RewriteRule ^(.+\.cf[cm])$ ajp://localhost:8009$1 [P]
</VirtualHost>

Ok so this seems to work, apart from one really annoying snag.  in the
coldfusion war theres a directory call CFIDE which contains amongst other
things the administrator.  I can browse to
http://mysite.dev:8080/CFIDE/administrator/index.cfm and it happily shows me
the login screen, however if it try to access that directory through apache
it sends me the source code for the file. This only happens with that
directory, content from other directories including others under /CFIDE are
served correctly.  And to make it even more confusing, replace
/CFIDE/administrator with an empty directory, restart tomcat & apache it
still serves up the same source file.

I have mod_rewrite logging turned on and when i hit /CFIDE/administrator/
via apache nothing appears in the access or rewrite log, its like the
request completely bypasses apache and tomcat...

Hope this is the right place to ask, as i'm not sure what the real source of
this problem is.

Cheers, Chris

Re: tomact, apache & adobe coldfusion 9

Posted by Peter Crowther <pe...@melandra.com>.
2009/10/30 Chris Blackwell <ch...@team193.com>:
> I'm trying to get this setup with httpd, because eventually i'd like to
> deploy it to my webserver that will host sites with a mixture of coldfusion
> and php apps across multiple virtual hosts.

Yep, that's a great reason to go with the architecture you have.

So, for this app, what happens if you change its DocumentRoot to be
something other than the same place that holds your Tomcat files?
Having them the same is not a recommended configuration anyway, as
it's entirely possible for a cracker to read your webapp's
configuration files via httpd the way it's set up now.

- Peter

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


Re: tomact, apache & adobe coldfusion 9

Posted by Chris Blackwell <ch...@team193.com>.
Hi Peter,

I'm trying to get this setup with httpd, because eventually i'd like to
deploy it to my webserver that will host sites with a mixture of coldfusion
and php apps across multiple virtual hosts.

I wouldn't go to the bother if it were just for my development environment.
 This is my first venture into tomcat territory so i'm testing the waters on
my workstation so to speak before installing anything on the server.

Cheers, Chris

2009/10/30 Peter Crowther <pe...@melandra.com>

> 2009/10/30 Chris Blackwell <ch...@team193.com>:
> > <VirtualHost *:80>
> > DocumentRoot "C:\Users\Chris\Documents\Eclipse Workspace\mysite"
>
> If I recall correctly, you don't want this.  Serve a blank directory
> out of httpd, and proxy everything to Tomcat.  Or take httpd out of
> the equation completely if you don't need it for other purposes.
> "It's faster to serve static content out of httpd" is no longer an
> appropriate "other purpose" in 5.5+ :-).
>
> - Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: tomact, apache & adobe coldfusion 9

Posted by Peter Crowther <pe...@melandra.com>.
2009/10/30 Chris Blackwell <ch...@team193.com>:
> <VirtualHost *:80>
> DocumentRoot "C:\Users\Chris\Documents\Eclipse Workspace\mysite"

If I recall correctly, you don't want this.  Serve a blank directory
out of httpd, and proxy everything to Tomcat.  Or take httpd out of
the equation completely if you don't need it for other purposes.
"It's faster to serve static content out of httpd" is no longer an
appropriate "other purpose" in 5.5+ :-).

- Peter

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


Re: tomact, apache & adobe coldfusion 9

Posted by Peter Crowther <pe...@melandra.com>.
2009/10/30 Chris Blackwell <ch...@team193.com>:
> Ok, that was it.  chrome was hanging on to the source in its cache and
> really didn't want to give it up.

Glad you found it.

> I do take on board your points about the single docroot approach.  testing
> here on windows requesting indeX.cfM will serve up the source, which isn't
> good!  but the hosting environment is linux, so that shouldn't be an issue.

Yes, you should be fine on Linux.

>  I'll give some thought to how i could create a seperate /public_html and
> /java_apps directory to keep things seperate.

If you *can* get a set of filters together to separate the traffic
cleanly, I'm very interested (though I suspect it'd be commercially
sensitive information if you're using this setup to host PHP and
ColdFusion together).  You have a far more constrained environment
than most of the folks we see on this list: you want Tomcat to serve
all and only .cfm files, and I assume you're willing to spend the time
to define what is and is not served pretty thoroughly.  I suspect your
single-docroot approach can be made to work in the specific
environment you require, with at worst some careful documentation to
the user as to where they should put files that they don't want
served.

Good luck with it, anyway!

- Peter

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


Re: tomact, apache & adobe coldfusion 9

Posted by Chris Blackwell <ch...@team193.com>.
Ok, that was it.  chrome was hanging on to the source in its cache and
really didn't want to give it up.

I do take on board your points about the single docroot approach.  testing
here on windows requesting indeX.cfM will serve up the source, which isn't
good!  but the hosting environment is linux, so that shouldn't be an issue.
 I'll give some thought to how i could create a seperate /public_html and
/java_apps directory to keep things seperate.

Cheers, Chris

2009/10/30 Peter Crowther <pe...@melandra.com>

> That's really odd.  Could you use LiveHttpHeaders or similar to
> monitor what's going over the wire between browser and server?  I'm
> wondering whether something's returning an "unchanged" response and
> the browser's returning the file from cache.
>
> - Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: tomact, apache & adobe coldfusion 9

Posted by Peter Crowther <pe...@melandra.com>.
2009/10/30 Chris Blackwell <ch...@team193.com>:
> I'm setting httpd & tomcat's doc roots to the same location because in my
> hosting setup users will be presented with /public_html directory in their
> home directory.  They should be able to place cfml, php and static resources
> in the same location and have them served.

... wow!  That's going to be interesting.

> I realize this might not be ideal, but i can block requests to WEB-INF in my
> httpd.conf using a DirectoryMatch directive

You'll probably also want to block META-INF (and check capitalisation,
that's from memory).

You will also have a more subtle problem that *may* prevent you
implementing this on Windows, though you won't have a problem on any
OS with case-sensitive filenames.  As I recall, httpd will serve a
file even if case doesn't match.  Tomcat is rather more careful.  So
you'll at least need to think about how you handle requests for
WeB-iNf, .CfM files and the like.  If you forward them to Tomcat, it
won't find the file; if you leave them with httpd, it'll serve the
file source.

> I changed the DocumentRoot of my vhost to "C:\temp" and restarted httpd.
> browsing to /CFIDE/administrator/index.cfm still serves up the files source,
> while all other urls are functioning correctly

That's really odd.  Could you use LiveHttpHeaders or similar to
monitor what's going over the wire between browser and server?  I'm
wondering whether something's returning an "unchanged" response and
the browser's returning the file from cache.

- Peter

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


Re: tomact, apache & adobe coldfusion 9

Posted by Chris Blackwell <ch...@team193.com>.
I'm setting httpd & tomcat's doc roots to the same location because in my
hosting setup users will be presented with /public_html directory in their
home directory.  They should be able to place cfml, php and static resources
in the same location and have them served.

I realize this might not be ideal, but i can block requests to WEB-INF in my
httpd.conf using a DirectoryMatch directive

I changed the DocumentRoot of my vhost to "C:\temp" and restarted httpd.
browsing to /CFIDE/administrator/index.cfm still serves up the files source,
while all other urls are functioning correctly

Chris

2009/10/30 André Warnier <aw...@ice-sa.com>

> Chris Blackwell wrote:
> ...
>
>
>
>> <VirtualHost *:80>
>> DocumentRoot "C:\Users\Chris\Documents\Eclipse Workspace\mysite"
>>
>
> Bad idea, almost always...
>
>
>   ServerName mysite.dev
>>
>> ProxyPreserveHost On
>> ProxyPassReverse / ajp://localhost:8009/
>>
>> RewriteEngine On
>> # If it's a CFML (*.cfc or *.cfm) request, just proxy it to Tomcat:
>>  RewriteRule ^(.+\.cf[cm])$ ajp://localhost:8009$1 [P]
>> </VirtualHost>
>>
>> Ok so this seems to work, apart from one really annoying snag.  in the
>> coldfusion war theres a directory call CFIDE which contains amongst other
>> things the administrator.  I can browse to
>> http://mysite.dev:8080/CFIDE/administrator/index.cfm and it happily shows
>> me
>> the login screen, however if it try to access that directory through
>> apache
>> it sends me the source code for the file.
>>
>
> .. and that's why.
>
>
> With your above RewriteRule, you are intercepting and proxying to Tomcat
> /some/ URLs.  The ones you are not intercepting and proxying with the rule,
> go through to Apache, which serves them normally as files, using its
> DocumentRoot as the base.
> So, probably, if you request "http://yourhost/ROOT/WEB-INF/web.xml",
> you'll also see the contents of the file
> (tomcat_dir)/webapps/ROOT/WEB-INF/web.xml, including anything in it that you
> would not want users to see (passwords etc..).
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: tomact, apache & adobe coldfusion 9

Posted by André Warnier <aw...@ice-sa.com>.
Chris Blackwell wrote:
...

> 
> <VirtualHost *:80>
> DocumentRoot "C:\Users\Chris\Documents\Eclipse Workspace\mysite"

Bad idea, almost always...

>  ServerName mysite.dev
> 
> ProxyPreserveHost On
> ProxyPassReverse / ajp://localhost:8009/
> 
> RewriteEngine On
> # If it's a CFML (*.cfc or *.cfm) request, just proxy it to Tomcat:
>  RewriteRule ^(.+\.cf[cm])$ ajp://localhost:8009$1 [P]
> </VirtualHost>
> 
> Ok so this seems to work, apart from one really annoying snag.  in the
> coldfusion war theres a directory call CFIDE which contains amongst other
> things the administrator.  I can browse to
> http://mysite.dev:8080/CFIDE/administrator/index.cfm and it happily shows me
> the login screen, however if it try to access that directory through apache
> it sends me the source code for the file. 

.. and that's why.


With your above RewriteRule, you are intercepting and proxying to Tomcat 
/some/ URLs.  The ones you are not intercepting and proxying with the 
rule, go through to Apache, which serves them normally as files, using 
its DocumentRoot as the base.
So, probably, if you request "http://yourhost/ROOT/WEB-INF/web.xml", 
you'll also see the contents of the file 
(tomcat_dir)/webapps/ROOT/WEB-INF/web.xml, including anything in it that 
you would not want users to see (passwords etc..).

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