-
Notifications
You must be signed in to change notification settings - Fork 4
Apacheで他のサイトを自分のサイトのように表示してみる
mechamogera edited this page Nov 19, 2012
·
4 revisions
Apacheで他のHTTPサイトを自分のサイトのように表示してみた
- AWS EC2インスタンス(Amazon Linux 64bit)
- httpd.x86_64 2.2.23-1.25.amzn1
- Apacheインストール
$ sudo yum -y install httpd
- /etc/httpd/conf.d/test.confを以下のように設定
- リバースプロキシでec2へのアクセスをexample.comに
- mod_ext_filterでレスポンスボディをフィルタリング
ExtFilterDefine fixtext mode=output \
cmd="/bin/sed s/example\.org/ec2-XXX.XXX.XXX.XXX\.ap-northeast-1\.compute\.amazonaws\.com/g"
<VirtualHost *:80>
RewriteEngine on
RewriteRule ^(.*) http://example.com$1 [P,L]
ProxyPassReverse / http://example.com/
SetOutputFilter fixtext
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>
- Apache起動
- example.com部分を実際に存在するサーバーに置き換えてEC2にアクセス
- 実際に存在するサーバーが返すレスポンスが表示される
- レスポンスの中身のホスト名が書き換えられている
- Apacheとmod_proxy_htmlインストール
$ sudo yum install -y httpd mod_proxy_html
- /etc/httpd/conf.d/test.confを以下のように設定
<VirtualHost *:80>
RewriteEngine On
ProxyHTMLEnable On
RewriteRule ^(.*) http://example.com$1 [P,L]
ProxyPassReverse / http://example.com/
ProxyHTMLURLMap http://example¥.com/ / [R,x,l,e,c]
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>
- その後の手順は実行手順(mod_ext_filter利用)と同じ
- javascriptの中は書き換えられない?(未確認)
- mod_sslをインストールしておいて、以下のような設定
<VirtualHost *:80>
RewriteEngine On
SSLProxyEngine on
RewriteRule ^(.*)$ https://example.com$1 [P,L]
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>