LoginSignup
14
10

More than 5 years have passed since last update.

Elixir on Phoenix アプリへのSSL接続を可能にするためのconfig.exs設定

Last updated at Posted at 2016-04-21

PhoenixアプリにSSLでアクセスするための設定メモです。

ssl証明書を配置

どこに置いても特に問題ないですが、公式に乗っかってprivの下においてみます。
いちおうsslディレクトリ切って。

~/tutorial/priv/ssl/ --- server.key
                      |- server.crt

configを修正

環境に合わせてconfig.exsなりを修正。
今回は一旦dev.exsでやります

dev.exs
config :tutorial, Tutorial.Endpoint,
  http: [port: 4000],
  https: [port: 4433,  # ←追加(443使ってたので4433で)
          keyfile: Path.expand("priv/ssl/server.key"),  # ←追加(相対パスで書く)
          certfile: Path.expand("priv/ssl/server.crt")], # ←追加
# 省略

起動

サーバーを起動してみます。

$ mix phoenix.server
[info] Running ChildRearingQuestion.Endpoint with Cowboy using https on port 4433
[info] Running ChildRearingQuestion.Endpoint with Cowboy using http on port 4000

正常に起動した様子。

これでhttpsを4433で待つようになりました!

14
10
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
10