From fdc7d9f1e15147881c7a6007dd9794f725b71bb6 Mon Sep 17 00:00:00 2001 From: Maygician Date: Mon, 5 Oct 2020 17:44:12 +0700 Subject: [PATCH] self certs --- deploy/rel.sh | 7 +++++++ lp/config/prod.exs | 12 ++++++++++-- lp/config/prod.secret.exs | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/deploy/rel.sh b/deploy/rel.sh index e28da21..866d94b 100644 --- a/deploy/rel.sh +++ b/deploy/rel.sh @@ -9,4 +9,11 @@ echo 'export SECRET_KEY_BASE='$key >> ~/.bashrc fi if [ -z "$PORT"]; then echo 'export PORT=443' >> ~/.bashrc +fi +# and cert paths +if [ -z "$GCLP_SSL_KEY_PATH"]; then +echo 'export GCLP_SSL_KEY_PATH=GCLP/lp/priv/cert/selfsigned_key.pem' >> ~/.bashrc +fi +if [ -z "$GCLP_APP_SSL_CERT_PATH"]; then +echo 'export GCLP_APP_SSL_CERT_PATH=GCLP/lp/priv/cert/selfsigned.pem' >> ~/.bashrc fi \ No newline at end of file diff --git a/lp/config/prod.exs b/lp/config/prod.exs index 5a69f20..3223a0a 100644 --- a/lp/config/prod.exs +++ b/lp/config/prod.exs @@ -12,6 +12,14 @@ use Mix.Config config :lp, LpWeb.Endpoint, # url: [host: "example.com", port: 80], url: [host: "35.193.215.48", port: 443], + https: [ + port: 443, + cipher_suite: :strong, + keyfile: System.get_env("GCLP_SSL_KEY_PATH"), + certfile: System.get_env("GCLP_APP_SSL_CERT_PATH"), + transport_options: [socket_opts: [:inet6]] + ] +# #usually you would not want to do that, but i'm lazy. adjust to your machine cache_static_manifest: "priv/static/cache_manifest.json" @@ -47,8 +55,8 @@ config :logger, level: :info # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # -# config :lp, LpWeb.Endpoint, -# force_ssl: [hsts: true] + config :lp, LpWeb.Endpoint, + force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. diff --git a/lp/config/prod.secret.exs b/lp/config/prod.secret.exs index 35db3f1..169e897 100644 --- a/lp/config/prod.secret.exs +++ b/lp/config/prod.secret.exs @@ -12,7 +12,7 @@ database_url = """ config :lp, Lp.Repo, - # ssl: true, + ssl: true, url: database_url, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")