JDK 1.6.0_17 で実行されている 2 つの Tomcat 7.0.35 インスタンスのリバース プロキシとして機能する Apache 2.2.24 があります。Tomcat は、コンテンツを Adobe AIR アプリに提供する BlazeDS Web アプリを実行します。
したがって、構成は次のようになります
Adobe AIR アプリ ---HTTPS----> Apache ---HTTPS---> Tomcat
私の会社のインフラストラクチャ標準により、Apache は SSL 経由で Tomcat に接続し、AJP の代わりに HTTP を使用します。これは変更できません。
Apache の設定は次のようになります。
<IfModule mod_ssl.c>
<VirtualHost xxx:461>
SSLEngine on
# Force to use explicit Ciphers first (see artf660612)
SSLHonorCipherOrder on
# Disable SSLv2
SSLProtocol -ALL -SSLv2 +SSLv3 +TLSv1
# Disable Weak Ciphers
SSLCipherSuite !aNULL:!eNULL:!EXPORT:!DSS:!DES:RC4-SHA:RC4-MD5:+HIGH:+MEDIUM:ALL
SSLCertificateKeyFile /vhosts/content/current/contentsys/ssl/ssl.key
SSLCertificateFile /vhosts/content/current/contentsys/ssl/ssl.cert
SSLCACertificateFile /apache22/conf/ssl.crt/ca-bundle.crt
<FilesMatch "\.(cgi|shtml|pl|phtml|php3?)$">
SSLOptions +StdEnvVars
</FilesMatch>
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
# Add per-virtual host throttling
<IfModule mod_qos.c>
# Defines the maximum number of concurrent TCP connections for this server (virtual host).
QS_SrvMaxConn 50
</IfModule>
<IfModule mod_cband.c>
CBandScoreboard /var/run/http/apache22/cbandscore/dw12869
# ridiculously high bandwidth and requests per second as we are only
# concerned with the last parameter - concurrent requests
CBandSpeed 100M 1000 50
</IfModule>
<LocationMatch "/(WEB|META)-INF/">
AllowOverride None
order allow,deny
deny from all
</LocationMatch>
# Import global URL Rewriting Engine properties
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteOptions inherit
</IfModule>
## Workaround for Apache "Range:" HTTP header bug (CVE-2011-3192)
# Drop the Range header when more than 5 ranges.
SetEnvIf Range (?:,.*?){5,5} bad-range=1
RequestHeader unset Range env=bad-range
# We always drop Request-Range; as this is a legacy
# dating back to MSIE3 and Netscape 2 and 3.
RequestHeader unset Request-Range
## END OF: Workaround for Apache "Range:" HTTP header bug (CVE-2011-3192)
## Workaround for PHP CGI remote code disclosure and execution bug (CVE-2012-1823)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]
RewriteRule ^(.*) $1? [L]
</IfModule>
## END OF: Workaround for PHP CGI remote code disclosure and execution bug (CVE-2012-1823)
# mod_jk configuration
<IfDefine JK>
<IfModule mod_jk.c>
</IfModule>
</IfDefine>
<IfModule ct_apache_mod.c>
RewriteEngine on
RewriteRule ^/(healthcheck|web-info) - [S=1]
# restriction: if the HOST header is not on the allowed list, serve a redirect to canonical URL
</IfModule>
#
# BalancerConfiguration 11
#
<Proxy balancer://balancer11>
BalancerMember https://myserver1.com:19802 route=0 timeout=300
BalancerMember https://myserver2.com:19802 route=1 timeout=300
ProxySet stickysession=JSESSIONID|jsessionid
ProxySet scolonpathdelim=On
ProxySet lbmethod=byrequests
</Proxy>
<Location /myapp>
ProxyPassReverse balancer://balancer11/myapp
ProxyPassReverseCookiePath /myapp /myapp
ProxyPass balancer://balancer11/myapp
</Location>
# BEGIN Extra configuration verbatim from config file
# Cache ADK CSS and Image Assets
<Location /adk>
ExpiresActive On
ExpiresDefault "access plus 1 year"
</Location>
LoadModule deflate_module /apache22/modules/mod_deflate.so
<IfModule mod_deflate.c>
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|bmp|icon|ico|tif|tiff)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
# END Extra configuration verbatim from config file
</VirtualHost>
</IfModule>
Tomcat Server.xml は次のようになります
<Connector protocol="org.apache.coyote.http11.Http11Protocol" port="19802"
maxThreads="200" connectionTimeout="20000" scheme="https" secure="true" SSLEnabled="true"
keystoreFile="/path/to/keystore" keystorePass="changeIt" keyAlias="web_ssl"
clientAuth="false" sslProtocol="TLS"/>
Tomcat サーバーは毎日午前 12 時 45 分に再起動します。午前 8 時から約 20 人のユーザーがログインしています。Flex アプリはポーリングを使用するため、1 秒ごとに HTTP 呼び出しを行ってデータをフェッチします。1 日の最初の数時間は、すべてが正常に機能します。その後、午後 3 時から 4 時ごろ、1 つの Tomcat ノードへの呼び出しで 502 Bad Gateway エラーが散発的に発生し始めます。
[Fri Aug 16 20:01:19 2013] [info] [client xx.xx.xx.xxx] (70007)The timeout specified has expired: SSL input filter read failed.
[Fri Aug 16 20:01:19 2013] [error] [client aa.aa.aa.aaa] (70007)The timeout specified has expired: proxy: error reading status line from remote server myserver1.com:19802, referer: app:/Main.swf
[Fri Aug 16 20:01:19 2013] [error] [client aa.aa.aa.aaa] proxy: Error reading from remote server returned by /myapp/messagebroker/amfsecure, referer: app:/Main.swf
時々それは次のとおりです
[Fri Aug 16 20:17:30 2013] [info] [client xx.xx.xx.xxx] (104)Connection reset by peer: SSL input filter read failed.
[Fri Aug 16 20:17:30 2013] [error] (104)Connection reset by peer: proxy: prefetch request body failed to yy.yy.yy.yy:19802 (myserver.com) from xx.xx.xx.xx ()
[Fri Aug 16 20:17:30 2013] [info] [client xx.xx.xx.xxx] (32)Broken pipe: core_output_filter: writing data to the network
[Fri Aug 16 20:17:30 2013] [info] [client xx.xx.xx.xxx] (104)Connection reset by peer: SSL input filter read failed.
[Fri Aug 16 20:17:30 2013] [info] [client xx.xx.xx.xxx] (32)Broken pipe: core_output_filter: writing data to the network
[Fri Aug 16 20:17:30 2013] [info] [client xx.xx.xx.xxx] Connection closed to child 26 with standard shutdown (server mysite:443)
スティッキー セッションが設定されているため、ログインを試みる新しいユーザーは、このエラーをスローする可能性のある 1 つのノードに繰り返しリダイレクトされ、再起動時にも 502 タイムアウトが発生し続けます。Tomcat ノードを再起動すると問題が解決し、数時間動作し始めます。しかし、それは再び現れます。Tomcat 自体は問題なく直接アクセスできます。注意すべきもう 1 つのことは、Apache サーバーは、私が管理/制御していない他の Tomcat のリバース プロキシとしても機能することです。
この問題に直面している他の人々を探していたところ、次のことがわかりました。
- SSL リバース プロキシでの GZIP によるチャンキングには問題があることが知られています - https://issues.apache.org/bugzilla/show_bug.cgi?id=52595
- force-proxy-request-1.0 と proxy-nokeepalive を設定すると役立つことが指摘されています - https://serverfault.com/questions/206738/intermittent-error-when-using-mod-proxy-to-do-reverse-プロキシから SOAP サービスへ
Apache ファイルは制御された環境であるため、直接編集することはできず、下部に構成オプションを追加することしかできません。だから私は以下を追加しました
SetEnvIf Request_URI "/myapp.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
UAT で JMeter を使用した負荷テストが有望に見えたので、役立つと思いました。以下のログは、上記のディレクティブが追加された後の 1 つのリクエストの出力を示しています。ただし、本番環境ではまだこの問題が発生しています
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_balancer.c(46): proxy: BALANCER: canonicalising URL //balancer11/myapp/messagebroker/amfsecure
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_http.c(1771): proxy: start body send
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_balancer.c(280): proxy: BALANCER: Found value B8620734D4F2D92E9B0C507C16A5EF8A.1 for stickysession JSESSIONID|jsessionid
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_balancer.c(290): proxy: BALANCER: Found route 1
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_balancer.c(594): proxy: BALANCER (balancer://balancer11) worker (https://myserver1.com:19802) rewritten to https://myserver1.com:19802/myapp/messagebroker/amfsecure
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy.c(1028): Running scheme balancer handler (attempt 0)
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_http.c(2001): proxy: HTTP: serving URL https://myserver1.com:19802/myapp/messagebroker/amfsecure
[Wed Aug 21 15:57:07 2013] [debug] proxy_util.c(2013): proxy: HTTPS: has acquired connection for (myserver1.com)
[Wed Aug 21 15:57:07 2013] [debug] ssl_engine_io.c(1918): OpenSSL: I/O error, 5 bytes expected to read on BIO#cfa3578 [mem: d1f4dd8]
[Wed Aug 21 15:57:07 2013] [debug] proxy_util.c(2069): proxy: connecting https://myserver1.com:19802/myapp/messagebroker/amfsecure to myserver1.com:19802
[Wed Aug 21 15:57:07 2013] [debug] proxy_util.c(2195): proxy: connected /myapp/messagebroker/amfsecure to myserver1.com:19802
[Wed Aug 21 15:57:07 2013] [debug] mod_deflate.c(615): [client xx.xx.xx.xxx] Zlib: Compressed 0 to 2 : URL /myapp/messagebroker/amfsecure, referer: app:/Main.swf
[Wed Aug 21 15:57:07 2013] [debug] mod_headers.c(756): headers: ap_headers_output_filter()
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_http.c(1875): proxy: end body send
[Wed Aug 21 15:57:07 2013] [debug] proxy_util.c(2031): proxy: HTTPS: has released connection for (myserver1.com)
[Wed Aug 21 15:57:07 2013] [debug] mod_proxy_balancer.c(637): proxy_balancer_post_request for (balancer://balancer11)
[Wed Aug 21 15:57:07 2013] [info] [client xx.xx.xx.xxx] Connection closed to child 15 with unclean shutdown (server myserver:443)
ユーザーから報告された同様の問題はすべて、以前のバージョンの Apache、Tomcat などで発生しているようで、バグは長い間修正されてきました。だから私は本当に何をしようとしているのか分かりません。任意のポインタをいただければ幸いです。ありがとう