ページではなく、画像のためにはProxyPassを使用します
質問
href="https://stackoverflow.com/questions/246540/apache-tomcat-error-wrong-pages-being-delivered">恐ろしい、恐ろしいエラーのmod_jkを使用していた。
JkMount /path ajp13
今、私たちはmod_proxy_ajp
を使用している:
ProxyPass /path ajp://localhost:8009/path
ProxyPassReverse /path ajp://localhost:8009/path
ファイルの種類に選択する機能:ただし、提供されたがJkMount
にはないProxyPass
機能があります。これは、プロキシのhtmlファイルではなく、画像にそれが可能になった - 言い換えれば、素敵な高速なApacheが静的なものを提供し、唯一の動的なもののために遅いTomcatに頼るようにする
JkMount /*.html ajp13
ProxyPass
でこれを達成する方法はありますか?おそらくそのように周囲の<Location>
ディレクティブか何かを使用していますか?
解決
を使用 ProxyPassMatchするます:
ProxyPassMatch ^/(path/.*\.html)$ ajp://localhost:8009/$1
<サブ>編集:マーカス・ダウニングの補正サブ>
他のヒント
はなく、あなたの問題が、この設定を使用するために注意するもの。 Tomcatに接続するようにApacheのmod_proxyを使用している間、私のエラー・ログには、適度な負荷の下で切断された接続を示しました。 httpd.confのにこれを追加すると、私の問題を解決します。
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
kmkaplanの投稿は、正しい答えですが、それは私にエラーを与えます:
Syntax error on line 32 of .../httpd-vhosts.conf:
ProxyPass Unable to parse URL
:私は読むためにディレクティブを変更したときにこれは、働いていました
ProxyPathMatch ^/(path/.*\.html)$ ajp://localhost:8009/$1
私は唯一の右隣のポート番号$1
に8009
を置くことは、それを混乱されたと仮定することができます。
私たちは、Apacheがヘッダを満了したイメージを提供し、合理的に設定できるように、次を使用します
<Virtualhost *:80>
ServerName domain.com
ServerAlias *.domain.com
Alias /img/ /var/www/domain/img/
<Directory /var/www/domain/img/>
ExpiresActive On
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpg "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType image/x-icon "access plus 1 months"
ExpiresByType image/ico "access plus 1 months"
# This will prevent apache from having to check for a .htaccess file on each request.
AllowOverride None
# Allow symlinks. Otherwise, apache will make a separate call on each filename to ensure it is not a symlink.
Options +FollowSymLinks -SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Prevent domain.com/img from being served by Tomcat
ProxyPass /img !
# Pass all other requests to Tomcat
ProxyPass / ajp://localhost:8009/
# 1. Note that usually no ProxyPassReverse directive is necessary. The AJP request includes
# the original host header given to the proxy, and the application server can be expected to
# generate self-referential headers relative to this host, so no rewriting is necessary.
# 2. If you still want to use it, read this first:
# http://www.humboldt.co.uk/2009/02/the-mystery-of-proxypassreverse.html
# ProxyPassReverse / http://domain.com/
</Virtualhost>
あなたが見ることができるようにしかし、私たちはTomcatアプリケーションの外部で画像を保存します。それはまた、アプリケーション内の画像のために機能するかどうか私は知りません。