LoginSignup
6
10

More than 5 years have passed since last update.

AWS EC2 で Apacheリバースプロキシ設定(http→https)

Last updated at Posted at 2017-04-13

やること

http://hogehoge.jp でアクセスした時に https://foobar.com の内容を表示させます。

まずはwebサーバを用意

EC2のインスタンスは用意済み・接続済みの前提です。

Apacheインストール

sudo yum install httpd -y

とりあえず起動

sudo /etc/init.d/httpd start

Apacheを起動したらブラウザから確認してみます。 http://hogehoge.jp
Apacheのデフォルトページが表示されれば成功です。

リバースプロキシ設定(http→https)

mod_sslをインストール

Amazon Linuxではmod_sslがインストールされていないため必要な作業です。
http→httpのプロキシ設定ならこの手順は不要です。

sudo yum install mod_ssl -y

confファイルを作成する

sudo vi /etc/httpd/conf.d/hogehoge.jp.conf
# リバースプロキシ設定
ProxyRequests Off
ProxyPass / https://foobar.com/
ProxyPassReverse / https://foobar.com/

# http→httpsに必要な設定
# http→httpのプロキシならこの設定は不要
RewriteEngine on
SSLProxyEngine on
RewriteRule ^(.*)$ https://foobar.com$1 [P]

Apacheを再起動

sudo /etc/init.d/httpd restart

再起動後にプロキシされているかブラウザから確認してみます。 http://hogehoge.jp
同じURLですが、さっきとは違うページが表示されるはずです。

6
10
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
6
10