web-dev-qa-db-ja.com

JSPのみを処理するTomcat-Apacheプロキシが期待どおりに機能しない

.jspファイルを含むPHPプロジェクトのソースコードをいくつか提供されました。職場のMacにセットアップされたXAMPPでそのまま実行できますが、私は ' m自宅の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のデフォルトの「Itworks!」ランディングページが表示されますが、これは私が望んでいたものではありません。

プロキシが設定されている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

どうすれば望ましい結果を達成できますか?

ProxyPassはそのように使用することはできません。これはLocationに似ており、特定のパス(およびその下のすべて)をリモートサーバーに転送する必要があります。拡張子はProxyPassMatchと一致する必要があります。

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

また、proxy_http_moduleは必要ありませんが、代わりにproxy_ajp_moduleが必要です。

[〜#〜] edit [〜#〜]、「ルートディレクトリ(Apacheルートディレクトリと同じ場合もあります)にjspがあり、ポート8009でリッスンしているTomcatが必要です。 jspを解析します。Apacheがアプリケーションサーバーのエンジンを独自に使用する方法も、Tomcatがその下にないページを提供する方法もありません。

2
NuTTyX