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

发布于 2024-07-10 08:47:34 字数 362 浏览 5 评论 0原文

我已将 Tomcat 6 配置为提供 Perl CGI 脚本。 这部分是详细记录并且对我来说工作正常。

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

寻找一个思念的角度 2024-07-17 08:47:35

为什么要将图像放入 CGI 目录中? 它们不应该在正常的文档根目录下吗?

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

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.

姜生凉生 2024-07-17 08:47:35

由于Bugzilla 指南包含仅适用于 Apache 和 MS IIS 的配置指南,并且 google 没有出现任何讨论成功部署的帖子,你最好赌注可能是坚持使用已记录且受支持的配置,Apache 或 IIS。

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.

治碍 2024-07-17 08:47:35

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

我的结论是:

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

  2. Bugzilla 开发人员似乎并不认为将图像文件目录与应用程序脚本放在一起有什么不好。

  3. Tomcat 对 cgi-bin 的支持不如 Apache 丰富/广泛。

  4. 我原来的问题的答案是:在 Tomcat 6 中无法完成。

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.

猥︴琐丶欲为 2024-07-17 08:47:35

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

我正在尝试 BZ 实例,它似乎运行正常。

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

祝你好运!

petr@inmite[点]eu

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文