如何从Tomcat下的cgi目录中提供图像?

时间:2022-08-02 16:55:54

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

我已经配置Tomcat 6来提供Perl CGI脚本。该部分有详细记录,对我来说也没问题。

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.

但是,当浏览器从这个CGI目录请求图像时,T​​omcat的CGI servlet拒绝提供图像,而只显示图像的url。我相信这是一个安全功能,可以防止用户查看此类文件的内容。

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?

如何配置tomcat,tomcat CGI servlet和/或tomcat默认servlet,以实际提供恰好位于我的CGI目录中的图像文件?那可能吗?

4 个解决方案

#1


1  

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

为什么要将图像放在CGI目录中?它们不应该在普通文件根目录下吗?

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.

如果要在脚本的输出中构建相对路径,请将BASE标记添加到HTML头部,或者使链接成为绝对URL。

#2


1  

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.

由于Bugzilla指南仅包含Apache和MS IIS的配置指南,谷歌没有发现任何讨论成功部署的帖子,因此最好的办法是坚持使用文档化和支持的配置,Apache或IIS。

#3


0  

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.

解决方案:我放弃了我的“单一服务器”(即现有的Tomcat服务器)方法并安装了Apache。当然,Bugzilla在Apache下更容易工作。那里没有真正的惊喜。

I conclude that:

我的结论是:

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

    Apache在cgi-bin目录下提供图像文件没有问题。

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

    Bugzilla开发人员似乎认为将图像文件dir放入应用程序脚本并不好。

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

    Tomcat对cgi-bin的支持并不像Apache那样丰富/广泛。

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

    我原来的问题的答案是:它不能在Tomcat 6中完成。

#4


0  

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

好的,我已经写了一篇关于在Apache Tomcat 6上安装Bugzilla的简短操作方法(在Ubuntu 10.04 + MysSQL上)。

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

我正在玩BZ实例,它似乎正常运作。

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

Good luck!

petr@inmite[dot]eu

#1


1  

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

为什么要将图像放在CGI目录中?它们不应该在普通文件根目录下吗?

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.

如果要在脚本的输出中构建相对路径,请将BASE标记添加到HTML头部,或者使链接成为绝对URL。

#2


1  

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.

由于Bugzilla指南仅包含Apache和MS IIS的配置指南,谷歌没有发现任何讨论成功部署的帖子,因此最好的办法是坚持使用文档化和支持的配置,Apache或IIS。

#3


0  

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.

解决方案:我放弃了我的“单一服务器”(即现有的Tomcat服务器)方法并安装了Apache。当然,Bugzilla在Apache下更容易工作。那里没有真正的惊喜。

I conclude that:

我的结论是:

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

    Apache在cgi-bin目录下提供图像文件没有问题。

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

    Bugzilla开发人员似乎认为将图像文件dir放入应用程序脚本并不好。

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

    Tomcat对cgi-bin的支持并不像Apache那样丰富/广泛。

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

    我原来的问题的答案是:它不能在Tomcat 6中完成。

#4


0  

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

好的,我已经写了一篇关于在Apache Tomcat 6上安装Bugzilla的简短操作方法(在Ubuntu 10.04 + MysSQL上)。

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

我正在玩BZ实例,它似乎正常运作。

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

Good luck!

petr@inmite[dot]eu