あ、このテストhttps対応してないとできないテストやん!って時に使えるものを作りました
コードをいじりたくない時に使ってください
このレポジトリで見てください
https://github.com/takashiAg/https_easiest_proxy
経緯
streamingAPIとか使用する場合、その他テストをするときにhttps対応してないとできなかったりする。
選択肢としては、
- テスト用にhttps対応コードをかく
- 本番環境へのケースの切り分けが面倒
- 詳しくやり方がわからない
- Apacheやnginxでリバースプロキシを設定する
- 証明書の発行
- httpsに対応するようapacheインストール
- 設定ファイルの作成
が必要になるますが、面倒ですよね。
WAN=80 LAN=3000 node proxy.jsと書けば、プロキシとして動作するものを作りました。(bash)
installation
git clone https://github.com/takashiAg/https_easiest_proxy
cd https_easiest_proxy
npm install
openssl genrsa 2048 > mysslserver.key
openssl req -new -key mysslserver.key -subj "/C=JP/ST=Tokyo-to/L=Shibuya/O=Company Name/OU=IT dept./CN=Company Dept CA" > mysslserver.csr
openssl x509 -days 3650 -req -signkey mysslserver.key < mysslserver.csr > mysslserver.crt
openssl pkcs12 -export -inkey mysslserver.key -in mysslserver.crt > mysslserver.pfx
start
node proxy.js
change port
WAN=80 LAN=3000 node proxy.js