tags:

views:

650

answers:

5

I have configured Tomcat 6 to serve Perl CGI scripts. That part is well documented and works ok for me.

But, when a browser requests an image from this CGI dir, Tomcat's CGI servlet refuses to serve the image, displaying instead merely the url of the image. I believe this is a security feature to prevent users from seeing the contents of such files in general.

How do I configure tomcat, the tomcat CGI servlet, and/or the tomcat default servlet, to actually serve up an image file which happens to be located in my CGI dir? Is that possible?

+2  A: 

Why do you want to put images inside your CGI directory? Shouldn't they be under the normal document root?

If you are constructing relative paths in the output of your script, add a BASE tag to the HTML head, or make the links absolute URLs.

brian d foy
A: 

Thanks for your response, Brian.

By way of additional background to my question: I'm trying to run the CGI web application Bugzilla. It keeps its images in a folder called 'images' located in the same dir as the .cgi scripts. That arrangement works under the apache webserver, and I'd like to make it work under tomcat too.

Or at least, I'd like to avoid hacking the .cgi scripts which belong to bugzilla web app.

Chinnery
You would have to configure the server such that the path to "CGI-BIN"/images is a "normal" content directory. Then again, you shouldn't mix binaries and contents ... imho converter42 is right => install on a supported platform.
lexu
yeah, i wish bugzilla was not built that way.
Chinnery
that's just one of bugzilla's problems :) Also, you should edit your question instead of providing more details as answers.
brian d foy
+1  A: 

Since the Bugzilla Guide includes configuration guidelines for only Apache and MS IIS and google doesn't turn up any posts discussing successful deployment, your best bet would probably be to stick with a documented and supported configuration, Apache or IIS.

converter42
A: 

Resolution: I gave up on my "single server" (i.e. the existing Tomcat server) approach and installed Apache as well. Naturally, Bugzilla works much more readily under Apache. No real surprise there.

I conclude that:

  1. Apache has no problem serving image files from under a cgi-bin dir.

  2. Bugzilla developers don't seem to think it's bad to put the image file dir in with the application scripts.

  3. Tomcat's support for cgi-bin is not as rich/extensive as Apache's.

  4. The answer to my original question is: it cannot be done in Tomcat 6.

Chinnery
Just because a Bugzilla programmer does something doesn't make it good. You're stuck with what they did for Bugzilla, but don't make the same mistakes in your other work.
brian d foy
um ... i'm not doing that in my other work. i was just trying to get bugzilla to run under tomcat. i already explained that.
Chinnery
A: 

OK, I have written a short how-to on installing Bugzilla on Apache Tomcat 6 (on Ubuntu 10.04 + MysSQL).

I was playing around with the BZ instance and it seems to be functioning normally.

http://blog.inmite.eu/2010/08/installing-bugzilla-on-the-apache-tomcat-6/

Good luck!

petr@inmite[dot]eu

joshis