Skip to content

Commit

Permalink
fix: override max_header_value_length using environment variable (#762
Browse files Browse the repository at this point in the history
)

Update runtime.exs to allow a `MAX_HEADER_LENGTH` env variable

Solves #761 by introducing an environment variable to override config -> http -> protocol_options -> max_header_value_length or leaves it at the default 4096 if no other value is specified


---------

Co-authored-by: Filipe Cabaço <[email protected]>
  • Loading branch information
Nicholas Barrow and filipecabaco authored Dec 26, 2023
1 parent 23bb692 commit 97b214e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ TAILSCALE_APP_NAME # {string} Name of the Tailscale app.
TAILSCALE_AUTHKEY # {string} Auth key for the Tailscape app.
DNS_NODES # {string} Node name used when running server in a cluster.
MAX_CONNECTIONS # {string} Set the soft maximum for WebSocket connections. Defaults to '16384'.
MAX_HEADER_LENGTH # {string} Set the maximum header length for connections (in bytes). Defaults to '4096'.
NUM_ACCEPTORS # {string} Set the number of server processes that will relay incoming WebSocket connection requests. Defaults to '100'.
DB_QUEUE_TARGET # {string} Maximum time to wait for a connection from the pool. Defaults to '5000' or 5 seconds. See for more info: https://hexdocs.pm/db_connection/DBConnection.html#start_link/2-queue-config.
DB_QUEUE_INTERVAL # {string} Interval to wait to check if all connections were checked out under DB_QUEUE_TARGET. If all connections surpassed the target during this interval than the target is doubled. Defaults to '5000' or 5 seconds. See for more info: https://hexdocs.pm/db_connection/DBConnection.html#start_link/2-queue-config.
Expand Down
3 changes: 3 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ if config_env() == :prod do
url: [host: "#{app_name}.fly.dev", port: 80],
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
protocol_options: [
max_header_value_length: String.to_integer(System.get_env("MAX_HEADER_LENGTH") || "4096")
],
transport_options: [
# max_connection is per connection supervisor
# num_conns_sups defaults to num_acceptors
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
version: "2.25.49",
version: "2.25.50",
elixir: "~> 1.14.0",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down

0 comments on commit 97b214e

Please sign in to comment.