2
5

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.

Mac機をSSLアクセラレータのようなもの(リバースプロキシ)にした

Posted at

やること

諸事情によりWEBサーバはHTTPS接続できないけどクライアントからはhttpsにしたい時とかにはリバースプロキシをかませるといいよ!
超シンプルに作るよ!

やり方

  • /private/etc/apache2/httpd.conf 以下の3行をアンコメント
httpd.conf
#LoadModule socache_shmcb_module libexec/apache2/mod_socache_shmcb.so

#LoadModule ssl_module libexec/apache2/mod_ssl.so

#Include /private/etc/apache2/extra/httpd-ssl.conf
  • いわゆるオレオレ証明書を作成

$ cd /private/etc/apache2
$ sudo openssl genrsa -aes128 -out server.key 2048
$ sudo openssl req -new -key server.key -sha256 -out server.csr
$ sudo openssl x509 -in server.csr -days 365 -req -signkey server.key -sha256 -out server.crt

  • /private/etc/apache2/other/reverse_proxy.conf を作成

自機のドメインがhoge.huga.jp, WEBサーバが12.23.24.25とします

reverse_proxy.conf
# reverse proxy
<IfModule mod_proxy.c>
    ProxyRequests on
    <Proxy *>
        Order deny,allow
        Allow from All
    </Proxy>
    <VirtualHost *:443>
        ServerName hoge.huga.jp
        SSLEngine on
        SSLCertificateFile /private/etc/apache2/server.crt
        SSLCertificateKeyFile /private/etc/apache2/server.key
        SSLProxyEngine on
        ProxyPass / http://12.23.24.25/
        ProxyPassReverse / http://12.23.24.25/
    </VirtualHost>
</IFModule>
  • apache再起動

$ sudo apachectl -k restart
server.keyのパスフレーズを聞かれたら入力しよう!

2
5
1

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
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?