LoginSignup
14
14

More than 5 years have passed since last update.

thin と rack-reverse-proxy でサクっと https リバースプロキシ

Posted at

開発(デバッグ)中のローカルサーバーを 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
14
14
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
14
14