Fix IPv6 support and support listening to a specific IP - #2226
Conversation
Reorder build steps such that intermediate steps can more likely be reused, in particular installed apt, npm and mix packages.
config/runtime.exs: new variable PHX_HTTP_IP for specifying IP address to bind to; Logflare.Repo, :postgres_backend_adapter: set socket-options for IPv6; SharedRepo, ContextCache.Supervisor: hand socket-options on; update docs; update .template.env;
|
Thanks for the PR, looks like a good addition for self hosting setup |
runtime.exs: adapt logic from supabase/realtime:Realtime.Database.detect_ip_version/1; use :inet.parse_address/1 instead of IP.from_string!/1; shared_repo.ex: apply code-review suggestion;
Ziinc
left a comment
There was a problem hiding this comment.
thanks for the adjustments, was OOO. I can take over the postgres adaptor backend adjustments needed.
| opts ++ fields | ||
| end | ||
|
|
||
| opts = opts ++ [socket_options: config[:socket_options]] |
There was a problem hiding this comment.
@tvogel this shouldn't use the global config actually, we can add this in temporarily but it should be part of the backend's config instead. This would require adjusting the self-hosted backend config building.
There was a problem hiding this comment.
Why shouldn't it use the socket_options determined for the respective DB_HOSTNAME which it determines in
Map.take(config, [:username, :password, :hostname, :database, :port, :ssl])
? In which cases would you use different options?
There was a problem hiding this comment.
In this case, with inserts into one postgres instance it is ok. However, it will not apply in the situation where there is 2 postgres instances in a multi-backend setup, 1 on ipv6 and the other on ipv4. The same socket options would not apply
Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
|
(Sorry for the late replies - I was traveling.) |
|
@Ziinc, any update on this pull request? Hitting this issue currently as well and would love for this to be merged. |
|
@tvogel could you adjust the two remaining issues for the merge?
|
* perf: reduce docker rebuild overhead Reorder build steps such that intermediate steps can more likely be reused, in particular installed apt, npm and mix packages. * fix: support IPv6, allow specific binding to IPs config/runtime.exs: new variable PHX_HTTP_IP for specifying IP address to bind to; Logflare.Repo, :postgres_backend_adapter: set socket-options for IPv6; SharedRepo, ContextCache.Supervisor: hand socket-options on; update docs; update .template.env; * fix: address code-review runtime.exs: adapt logic from supabase/realtime:Realtime.Database.detect_ip_version/1; use :inet.parse_address/1 instead of IP.from_string!/1; shared_repo.ex: apply code-review suggestion; * address formatting linter * Update mix.exs: remove dependency not longer required Co-authored-by: Ziinc <Ziinc@users.noreply.github.com> * fix: only forward socket opts for single tenant PG * fix: fallback for host * fix: fallback for socket options --------- Co-authored-by: Chase Granberry <chase@logflare.app> Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
* perf: reduce docker rebuild overhead Reorder build steps such that intermediate steps can more likely be reused, in particular installed apt, npm and mix packages. * fix: support IPv6, allow specific binding to IPs config/runtime.exs: new variable PHX_HTTP_IP for specifying IP address to bind to; Logflare.Repo, :postgres_backend_adapter: set socket-options for IPv6; SharedRepo, ContextCache.Supervisor: hand socket-options on; update docs; update .template.env; * fix: address code-review runtime.exs: adapt logic from supabase/realtime:Realtime.Database.detect_ip_version/1; use :inet.parse_address/1 instead of IP.from_string!/1; shared_repo.ex: apply code-review suggestion; * address formatting linter * Update mix.exs: remove dependency not longer required Co-authored-by: Ziinc <Ziinc@users.noreply.github.com> * fix: only forward socket opts for single tenant PG * fix: fallback for host * fix: fallback for socket options --------- Co-authored-by: Chase Granberry <chase@logflare.app> Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
* Fix IPv6 support and support listening to a specific IP (#2226) * perf: reduce docker rebuild overhead Reorder build steps such that intermediate steps can more likely be reused, in particular installed apt, npm and mix packages. * fix: support IPv6, allow specific binding to IPs config/runtime.exs: new variable PHX_HTTP_IP for specifying IP address to bind to; Logflare.Repo, :postgres_backend_adapter: set socket-options for IPv6; SharedRepo, ContextCache.Supervisor: hand socket-options on; update docs; update .template.env; * fix: address code-review runtime.exs: adapt logic from supabase/realtime:Realtime.Database.detect_ip_version/1; use :inet.parse_address/1 instead of IP.from_string!/1; shared_repo.ex: apply code-review suggestion; * address formatting linter * Update mix.exs: remove dependency not longer required Co-authored-by: Ziinc <Ziinc@users.noreply.github.com> * fix: only forward socket opts for single tenant PG * fix: fallback for host * fix: fallback for socket options --------- Co-authored-by: Chase Granberry <chase@logflare.app> Co-authored-by: Ziinc <Ziinc@users.noreply.github.com> * chore: fix compilation errors * chore: remove net_address from lockfile * chore: PR comments --------- Co-authored-by: Tilman Vogel <tilman.vogel@web.de> Co-authored-by: Chase Granberry <chase@logflare.app>
* Fix IPv6 support and support listening to a specific IP (#2226) * perf: reduce docker rebuild overhead Reorder build steps such that intermediate steps can more likely be reused, in particular installed apt, npm and mix packages. * fix: support IPv6, allow specific binding to IPs config/runtime.exs: new variable PHX_HTTP_IP for specifying IP address to bind to; Logflare.Repo, :postgres_backend_adapter: set socket-options for IPv6; SharedRepo, ContextCache.Supervisor: hand socket-options on; update docs; update .template.env; * fix: address code-review runtime.exs: adapt logic from supabase/realtime:Realtime.Database.detect_ip_version/1; use :inet.parse_address/1 instead of IP.from_string!/1; shared_repo.ex: apply code-review suggestion; * address formatting linter * Update mix.exs: remove dependency not longer required Co-authored-by: Ziinc <Ziinc@users.noreply.github.com> * fix: only forward socket opts for single tenant PG * fix: fallback for host * fix: fallback for socket options --------- Co-authored-by: Chase Granberry <chase@logflare.app> Co-authored-by: Ziinc <Ziinc@users.noreply.github.com> * chore: fix compilation errors * chore: remove net_address from lockfile * chore: PR comments --------- Co-authored-by: Tilman Vogel <tilman.vogel@web.de> Co-authored-by: Chase Granberry <chase@logflare.app>
For running logflare on fly.io with their IPv6 based private networking, I had to fix/improve a few things. Please take a look and pick what you like!
(My first exposure to Elixir/Erlang, so thanks for that!)