Skip to content

Commit

Permalink
make configurable in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Jan 1, 2025
1 parent 7e11e3d commit 442527c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
28 changes: 0 additions & 28 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,6 @@ end

config :mindwendel, :s3_storage_provider, Mindwendel.Services.S3ObjectStorageService

force_ssl = System.get_env("FORCE_SSL", "true") == "true"

config :mindwendel, MindwendelWeb.Endpoint,
# This configuration ensures / enforces ssl requests sent to this mindwendel instance.
# See https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-compile-time-configuration
#
# Note:
# This configuration also supports deploying mindwendel behind a reverse proxy (load balancer).
# For this to work, we tell the Phoenix endpoint Configuration (Plug.SSL) to parse the proper protocol from the x-forwarded-* header.
# See https://hexdocs.pm/plug/Plug.SSL.html#module-x-forwarded
# See https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-compile-time-configuration
force_ssl: [
hsts: force_ssl,
rewrite_on: [
:x_forwarded_host,
:x_forwarded_port,
:x_forwarded_proto
]
],
http: [
transport_options: [
socket_opts: [
:inet6
]
]
],
secret_key_base: secret_key_base

# Do not print debug messages in production
config :logger, level: :info

Expand Down
30 changes: 30 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,33 @@ if feature_file_upload and (config_env() == :prod || config_env() == :dev) do
secret_access_key: System.fetch_env!("OBJECT_STORAGE_PASSWORD")
)
end

if config_env() == :prod do
force_ssl = System.get_env("FORCE_SSL", "true") == "true"

config :mindwendel, MindwendelWeb.Endpoint,
# This configuration ensures / enforces ssl requests sent to this mindwendel instance.
# See https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-compile-time-configuration
#
# Note:
# This configuration also supports deploying mindwendel behind a reverse proxy (load balancer).
# For this to work, we tell the Phoenix endpoint Configuration (Plug.SSL) to parse the proper protocol from the x-forwarded-* header.
# See https://hexdocs.pm/plug/Plug.SSL.html#module-x-forwarded
# See https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-compile-time-configuration
force_ssl: [
hsts: force_ssl,
rewrite_on: [
:x_forwarded_host,
:x_forwarded_port,
:x_forwarded_proto
]
],
http: [
transport_options: [
socket_opts: [
:inet6
]
]
],
secret_key_base: secret_key_base
end

0 comments on commit 442527c

Please sign in to comment.