0
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 1 year has passed since last update.

Apache 2.4でのプロキシ設定 (Mac)

Last updated at Posted at 2022-01-12

はじめに

アプリケーション開発時などにローカル環境に接続するためのApacheのプロキシ設定方法について説明します
この設定はApache 2.4で動作を確認しています

使用しているApacheのバージョン

bash
# apachectl -v
Server version: Apache/2.4.46 (Unix)
Server built:   May  8 2021 03:38:34

モジュールの有効化

Apacheの設定ファイル (/etc/apache2/httpd.conf) を編集して、
プロキシに必要なモジュールを有効化します

具体的には、以下の行のコメントアウトを解除します

/etc/apache2/httpd.conf
LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_connect_module libexec/apache2/mod_proxy_connect.so
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so

プロキシ設定ファイルの作成

具体的なプロキシ設定を記述した設定ファイルを作成します

ここでは/etc/apache2/other/proxy.confというファイルを作成し、
その中に以下の内容を書きます

/etc/apache2/other/proxy.conf
<IfModule mod_proxy.c>
        ProxyRequests   On
        ProxyVia        On
        AllowCONNECT    443
        Listen          44444
        CustomLog       /var/log/apache2/proxy_access_log       combined
        ErrorLog        /var/log/apache2/proxy_error_log
        <Proxy *>
                Order   deny,allow
                Deny    from    all
                Allow   from    all
        </Proxy>
        <VirtualHost *:80>
                ServerName              <%ServerName%>
                RewriteEngine           On
                ProxyPass               /       http://<%IP_ADDRESS%>/
                ProxyPassReverse        /       http://<%IP_ADDRESS%>/
                ProxyPreserveHost       On
        </VirtualHost>
</IfModule>

ここでの<%ServerName%><%IP_ADDRESS%>は、
それぞれ実際のサーバー名とあなたのサーバーのIPアドレスに置き換えてください

設定が正しく行われたかを確認するために、
Apacheを再起動し、設定したプロキシを通じての接続テストを行ってください

さいごに

プロキシを介した接続が必要な開発環境であれば、この設定を行うことで、
適切にローカル環境に接続することが可能となります

0
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
0
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?