Skip to content

Commit 4252878

Browse files
authored
Enable :force_ssl in :prod environment by default (#6435)
* Enable `:force_ssl` in `:prod` environment by default * Remove `host: nil` to avoid spoofing attacks
1 parent 9572cc1 commit 4252878

File tree

2 files changed

+9
-1
lines changed
  • installer/templates

2 files changed

+9
-1
lines changed

installer/templates/phx_single/config/prod.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import Config
66
# manifest is generated by the `mix assets.deploy` task,
77
# which you should run after static files are built and
88
# before starting your production server.
9-
config :<%= @web_app_name %>, <%= @endpoint_module %>, cache_static_manifest: "priv/static/cache_manifest.json"<% end %><%= if @mailer do %>
9+
config :<%= @web_app_name %>, <%= @endpoint_module %>, cache_static_manifest: "priv/static/cache_manifest.json"
10+
11+
<% end %># Force using SSL in production. This also sets the "strict-security-transport" header,
12+
# also known as HSTS. `:force_ssl` is required to be set at compile-time.
13+
config :<%= @web_app_name %>, <%= @endpoint_module %>, force_ssl: [rewrite_on: [:x_forwarded_proto]]<%= if @mailer do %>
1014

1115
# Configure Swoosh API Client
1216
config :swoosh, api_client: Swoosh.ApiClient.Req

installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ import Config
88
config :<%= @web_app_name %>, <%= @endpoint_module %>,
99
url: [host: "example.com", port: 80],
1010
cache_static_manifest: "priv/static/cache_manifest.json"
11+
12+
# Force using SSL in production. This also sets the "strict-security-transport" header,
13+
# also known as HSTS. `:force_ssl` is required to be set at compile-time.
14+
config :<%= @web_app_name %>, <%= @endpoint_module %>, force_ssl: [rewrite_on: [:x_forwarded_proto]]

0 commit comments

Comments
 (0)