From 94c889719578e4e3a272e1351aad3f68c07b3189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Knuchel?= Date: Sat, 25 Nov 2023 10:06:14 +0100 Subject: [PATCH] Allow IPv4 addresses --- .env.example | 1 + INSTALL.md | 1 + backend/config/runtime.exs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 71d354b02..0ab9cf7d3 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,7 @@ # Technical requirements export PHX_SERVER=true +# export PHX_PROTOCOL=ipv4 export PHX_HOST=localhost export PORT=4000 export SECRET_KEY_BASE=CHANGE_ME diff --git a/INSTALL.md b/INSTALL.md index 48a4c9d9f..828a355a9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -125,6 +125,7 @@ Here is the full list of environment variables you can use to set up Azimutt app These are the basic variables you will **need** to set up Azimutt: - `PHX_SERVER` (optional): if `true`, start the Phoenix server in server mode +- `PHX_PROTOCOL` (optional, values: `ipv6` or `ipv4`, default: `ipv6`): if `ipv4`, the Phoenix server will listen to IPv4, otherwise IPv6 - `PHX_HOST` (required): host of the deployed website (ex: `localhost` or `azimutt.app`), it's used to build absolute urls - `PORT` (required): the port the server will listen to (ex: `4000`) - `SECRET_KEY_BASE` (required): the secret used for server encryption (cookies and others), should be at least 64 bytes and you probably want a random value for it diff --git a/backend/config/runtime.exs b/backend/config/runtime.exs index fa6f326b5..c18fb7760 100644 --- a/backend/config/runtime.exs +++ b/backend/config/runtime.exs @@ -64,7 +64,7 @@ if config_env() == :prod || config_env() == :staging do # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access. # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html # for details about using IPv6 vs IPv4 and loopback vs public addresses. - ip: {0, 0, 0, 0, 0, 0, 0, 0}, + ip: if(System.get_env("PHX_PROTOCOL") == "ipv4", do: {0, 0, 0, 0}, else: {0, 0, 0, 0, 0, 0, 0, 0}), port: port ], secret_key_base: System.fetch_env!("SECRET_KEY_BASE")