AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 810721
Accepted
I wrestled a bear once.
I wrestled a bear once.
Asked: 2016-10-23 19:55:08 +0800 CST2016-10-23 19:55:08 +0800 CST 2016-10-23 19:55:08 +0800 CST

Tomcat 仅处理 JSP - Apache 代理未按预期工作

  • 772

我已经获得了一些包含 .jsp 文件的 PHP 项目的源代码。我可以在工作时在我的 Mac 上设置的 XAMPP 上按原样运行它,但我正在努力在家里的 Ubuntu 设置上实现同样的效果。

我需要的是能够在我的 Apache 服务器根目录 (/var/www/html/) 中删除 .jsp 文件,并让 Apache 与 Tomcat 建立任何必要的连接来解析 .jsp 文件并让 Apache 处理其他所有事情。

我不想将我的 .jsp 文件或任何其他文件放在 Tomcat 服务器根目录中,我只是希望 Tomcat 解析我的 Apache 服务器根目录中的 .jsp 文件。

我已经阅读了有关 Stack Exchange 的几篇文章和问题,并取得了以下成果:(localhost/something/something.jsp位于 中/var/www/html/something/something.jsp)由 Apache 提供服务,Java 代码未解析地提供给客户端,同时导航到localhost/something/something.php(位于 something.jsp 旁边)显示默认的“它有效!” Tomcat 的登陆页面。这不是我想要的。

这是我设置了代理的 000-default.conf 文件:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ProxyRequests off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass *.jsp ajp://127.0.0.1:8009/
    ProxyPassReverse *.jsp ajp://127.0.0.1:8009/

    <Directory "/var/www/html">
        AllowOverride All
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我怎样才能达到预期的效果?

ubuntu mod-proxy-ajp apache2 tomcat7 jsp
  • 1 1 个回答
  • 839 Views

1 个回答

  • Voted
  1. Best Answer
    NuTTyX
    2016-10-24T02:19:39+08:002016-10-24T02:19:39+08:00

    ProxyPass不能这样使用。它更像是一个Location,强制必须将某个路径(及其下的所有内容)定向到远程服务器。扩展名应与ProxyPassMatch:

    ProxyPassMatch "^/(.*\.jsp)$" "ajp://127.0.0.1:8009/$1"

    此外,您不需要proxy_http_module, proxy_ajp_module而是

    编辑,您需要一个tomcat在端口8009上侦听其根目录中的jsp(可能与您的apache根目录相同)以“解析”jsp,apache无法使用应用程序服务器的它自己的引擎既不是 tomcat 也不是为不在它下面的页面提供服务。

    • 2

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve