私は、SSL接続を終了するApache Forward Proxyを設定しようとしています。私がこれをやろうとしているのは、返されたコードに対してApacheフィルター(特にmod_pagespeed)を実行するためです。 mod_pagespeedを処理する前に、レスポンスにヘッダーを挿入することでこのPOCをテストしていますが、レスポンスを編集できることがわかりますが、SSLプロキシで問題が発生しています(非SSLプロキシはうまく動作します) 。Apache Forward Proxy with SSL Termination
私は証明書の誤りなどについて心配していないことに注意してください。これは純粋に内部テストです。
私は、サーバーをセットアップし、非SSLのページにX-MSCProxyヘッダを参照してください持っている:
jshannon-macbookpro:pagespeed_proxy jshannon$ curl -vv --proxy pagespeed_proxy:[email protected]:8080 -D - -o /dev/null http://www.slate.com
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
* Proxy auth using Basic with user 'pagespeed_proxy'
> GET http://www.slate.com/ HTTP/1.1
> Host: www.slate.com
...
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Mon, 30 Oct 2017 18:10:40 GMT
Date: Mon, 30 Oct 2017 18:10:40 GMT
< Server: Apache/2.2.29 (Amazon)
Server: Apache/2.2.29 (Amazon)
...
< Content-Length: 187051
Content-Length: 187051
...
< X-Instart-Request-ID: 8286987369135064135:FWP01-NPPRY22:1509387040:0
X-Instart-Request-ID: 8286987369135064135:FWP01-NPPRY22:1509387040:0
< Via: 1.1 172.17.0.2:8080
Via: 1.1 172.17.0.2:8080
< X-MSCProxy: SansPS
X-MSCProxy: SansPS
しかし、私はスレートのSSLページに同じ要求を行うとき、私は私が表示されませんプロキシ:
jshannon-macbookpro:pagespeed_proxy jshannon$ curl -vv --proxy pagespeed_proxy:[email protected]:8080 -D - -o /dev/null https://www.slate.com
* Connected to localhost (::1) port 8080 (#0)
* Establish HTTP proxy tunnel to www.slate.com:443
* Proxy auth using Basic with user 'pagespeed_proxy'
> CONNECT www.slate.com:443 HTTP/1.1
> Host: www.slate.com:443
< HTTP/1.0 200 Connection Established
HTTP/1.0 200 Connection Established
< Proxy-agent: Apache/2.4.25 (Debian)
Proxy-agent: Apache/2.4.25 (Debian)
<
* Proxy replied OK to CONNECT request
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: ssl004.insnw.net
* Server certificate: GlobalSign CloudSSL CA - SHA256 - G3
* Server certificate: GlobalSign Root CA
> GET/HTTP/1.1
> Host: www.slate.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< Content-Length: 187044
Content-Length: 187044
< Connection: keep-alive
Connection: keep-alive
< Server: Apache/2.2.29 (Amazon)
Server: Apache/2.2.29 (Amazon)
< X-Instart-Request-ID: 762420041708891440:FWP01-NPPRY21:1509387251:0
X-Instart-Request-ID: 762420041708891440:FWP01-NPPRY21:1509387251:0
私は様々なのhttpd.confの提案でこれが可能である(そして、技術的には、それがあるべき)と言う記事をたくさん見つけたが、私が試したものは何も働いていません。
<VirtualHost *:8080>
ProxyRequests On
ProxyVia On
Header set X-MSCProxy SansPS
#SSLEngine On
# suggestion that this allows termination
ProxyPreserveHost On
SSLProxyEngine on
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerExpire Off
SSLProxyCheckPeerName Off
SSLCertificateFile /etc/apache2/ssl/localhost.crt
SSLCertificateKeyFile /etc/apache2/ssl/localhost.key
ModPagespeed Off
</VirtualHost>
FWIW、私はこのプロキシにSSLEngineのを有効にする(推奨されているように)その要求は単純にApacheからこのエラーでは動作しません:
[Mon Oct 30 18:20:20.705047 2017] [ssl:info] [pid 372:tid 140147985901312] [client 172.17.0.1:34012] AH01996: SSL handshake failed: HTTP spoken on HTTPS port; trying to send HTML error page
[Mon Oct 30 18:20:20.705107 2017] [ssl:info] [pid 372:tid 140147985901312] SSL Library Error: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request -- speaking HTTP to HTTPS port!?
今、私のhttpd.confは次のようになります
プロキシプロトコルがHTTPS接続をプロキシに直接期待していないので、私は推測します。
それは理由のペアのいずれかの一般的なクライアントとはできません。 1)httpsクライアントは、あなたが見たように、SSL経由でプロキシに話をしません。 2)クライアントがhttpsをプロキシに使用したとしても、確立されたCONNECTトンネルを介してhttps を使用するため、プロキシはそれを介してHTTP要求/応答を操作することができません。 私には行き止まりのようです。 – covener
確認していただきありがとうございます。 –
これをプロキシとして使用しないで、ホストファイルを使用してドメインをApacheサーバーに指定し、次にプロキシが元のサーバーに要求を渡すのはどうですか?これは、 'https(ホストファイルを使って変更されたドメインIP) - > Apache - >元のサイト上のhttps' –