LoginSignup
18
21

More than 3 years have passed since last update.

Apache 2.4 から https サーバへリバースプロキシする

Posted at

概要

  • Apache HTTP Server 2.4 から https サーバへリバースプロキシする
  • リバースプロキシの設定には ProxyPass と ProxyPassReverse を使用する
  • http サーバへリバースプロキシする場合と比べて SSLProxyEngine を追加する必要がある

https サーバへリバースプロキシするための設定

https サーバへリバースプロキシするためには、

SSLProxyEngine を使えるようにするために mod_ssl をロードする設定を追加。

LoadModule ssl_module modules/mod_ssl.so

また、SSLProxyEngine を有効にする設定が必要。

SSLProxyEngine On

SSLProxyEngine はプロキシの SSL/TLS プロトコルエンジンを ON/OFF するためのディレクティブ。

設定例

httpd.conf 等に以下のように設定する。

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module modules/mod_ssl.so

ProxyRequests Off
SSLProxyEngine On

ProxyPass /foo https://example.com/bar
ProxyPassReverse /foo https://example.com/bar

mod_ssl をロードしていない場合

以下のようなエラーメッセージが出力される。

AH01144: No protocol handler was valid for the URL /foo (scheme 'https'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

SSLProxyEngine を導入していない場合

以下のようなエラーメッセージが出力される。

AH01961: SSL Proxy requested for hoge.example.com:80 but not enabled [Hint: SSLProxyEngine]
AH00961: HTTPS: failed to enable ssl support for XXX.XXX.XX.XX:443 (example.com)

参考資料

mod_proxy - Apache HTTP サーバ バージョン 2.4

SSL/TLS で遠隔サーバに接続する機能は mod_ssl の SSLProxy* ディレクティブで 提供されています。これらの機能を利用するためには、該当するモジュールを 組み込んで設定しなければなりません。

mod_ssl - Apache HTTP Server Version 2.4

SSLProxyEngine Directive
Description:   SSL Proxy Engine Operation Switch
Syntax:        SSLProxyEngine on|off
Default:       SSLProxyEngine off
Context:       server config, virtual host, proxy section
Status:        Extension
Module:        mod_ssl
Compatibility: The proxy section context is allowed in httpd 2.4.30 and later

This directive toggles the usage of the SSL/TLS Protocol Engine for proxy. This is usually used inside a section to enable SSL/TLS for proxy usage in a particular virtual host. By default the SSL/TLS Protocol Engine is disabled for proxy both for the main server and all configured virtual hosts.

Note that the SSLProxyEngine directive should not, in general, be included in a virtual host that will be acting as a forward proxy (using or ProxyRequests directives). SSLProxyEngine is not required to enable a forward proxy server to proxy SSL/TLS requests.

18
21
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
18
21