開発(デバッグ)中のローカルサーバーを https で動かしたいだけなので、Apache や Nginx 面倒な人用。
gem install rack-reverse-proxy
config.ru
require 'rack'
require 'rack/reverse_proxy'
use Rack::ReverseProxy do
reverse_proxy '/', ENV['TO']
end
run Proc.new{}
まずは SSL なしでテスト。 localhost:8082 -> localhost:8081
sh
TO=http://localhost:8081 thin -p 8082 start
OK だったら、 https://devcenter.heroku.com/articles/ssl-certificate-self などを参考にオレオレ証明書を config.ru と同じディレクトリに生成。
この場合は https の標準ポート 443
は特権ポートなので rvmsudo
で実行。
sh
rvmsudo env TO=http://localhost:8081 thin --ssl -p 443 start