1
3

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でリバースプロキシ

Last updated at Posted at 2019-03-23

Github

下記のようなdocker-compose.ymlを組む。

docker-compose.yml
version: "3"
services:
  apache:
    image: httpd:alpine
    ports:
      - 8000:80
  nginx:
    image: nginx:alpine
docker-compose up -d

で環境を立ち上げる。

  apache:
    image: httpd:alpine
    ports:
      - 8000:80

としているのでブラウザで localhost:8000 を見ると It works! が表示されている。
これをリバースプロキシしてnginxのwelcomeページを出すようにしたい。

Apache 2.4 で リバースプロキシの設定

こちらを参考に httpd.conf に以下の変更を加える。

httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

上記のコメントアウトを外す。
ファイルの末尾に下記を追加。

httpd.conf
ProxyRequests Off
ProxyPass / http://nginx/
ProxyPassReverse / http://nginx/

この状態でapachemを再起動する。

docker-compose exec apache bin/apache restart

localhost:8000 を見るとnginxのwelcomeページが表示されることが確認でき、リバースプロキシが成功していることが分かる。

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?