2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Apache mod_proxy で HTTPS を含めたフォワードプロキシ

Posted at

ちと、某所で mod_proxy による HTTPS の終了処理が意図通りにいかないという話があり、家で試してみたくてやってみました。

事象の再現にはいたりませんでしたが、色々と残しておこうと思います。

環境

プロキシサーバ

  • CentOS 6
  • Apache 2.2.15
  • mod_proxy, mod_proxy_connect

クライアント

  • CentOS 6
  • wget 1.12

フォワードプロキシの構築

HTTP プロキシのための mod_proxy と、HTTPS プロキシのための mod_proxy_connect をそれぞれ利用しました。

httpd.conf の設定は、主に下記の部分を変更。

httpd.conf
Listen 80
Listen 443
・・・
<IfModule mod_proxy.c>
ProxyRequests On
ProxyVia On
AllowCONNECT 443 # 443 ポートで CONNECT メソッドを許可

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

参考:https://httpd.apache.org/docs/2.2/ja/mod/mod_proxy.html

wget での設定

~/.wgetrc に、プロキシサーバを指定してやるだけです。

.wgetrc
http_proxy=http://xxx.xxx.xxx.xxx/
https_proxy=https://xxx.xxx.xxx.xxx/

試す

$ wget http://www.google.com
$ wget https://www.google.com

KeepAlive を無効にしてみたい

また、今回は Keepalive を無効にしたかったので、wget の man を見つつ、下記のコマンドも実行。

$ wget --no-http-keep-alive http://www.google.com

しかし、パケットを見る限り、クライアントからのリクエストヘッダには Connection 属性は指定が無いものの、プロキシサーバからのリクエストヘッダに Connection: Keep-Alive と付いていました…

とりあえずプロキシサーバ側で何とかならないかな? と思い、調べるとオプションがあるそうなので、設定。

httpd.conf
<Proxy *>
    Order allow,deny
    Allow from all
    SetEnv proxy-nokeepalive 1
</Proxy>

パケットで確認したところ、プロキシサーバからのリクエストヘッダには Connection: close と付いていました。成功。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?