Skip to content

Commit

Permalink
Remove JF_HOST_PORT. Update comments in .env.sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Sep 22, 2023
1 parent d38811c commit fcca80d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 58 deletions.
52 changes: 11 additions & 41 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,46 +1,15 @@
# JF_IP and JF_PORT defines ip and port
# our HTTP endpoint socket will listen to.
# The default for Docker builds is 0.0.0.0 to allow
# access from the outside of container.
# Note that this cannot be 127.0.0.1 as
# in Docker it only allows for traffic
# from within the container.
# For other builds, it is 127.0.0.1 not to
# accidentaly expose Jellyfish to the outside world
# when it runs behind some proxy like nginx.
#
# IP and PORT an HTTP endpoint will listen to
# JF_IP=0.0.0.0
# JF_PORT=5002


# JF_HOST and JF_HOST_PORT defines how Jellyfish
# should be seen from the outside.
# When you run Jellyfish behind proxy, your
# Jellyfish will run on 127.0.0.1 or 0.0.0.0
# (see JF_IP and JF_PORT for more information)
# but you don't want to and in fact you can't
# use those addresses for generating URLs, or
# telling Jellyfish Client to which server instance it
# should connect to (when running Jellyfish in a cluster).
# That's why we have separate environment variables.
#
# Example
#
# You run Jellyfish on a machine with some public
# ip address `PUB_IP` and domain `DOMAIN`.
# You most likely want to provide the following
# configuration when running Jellyfish using Docker
#
# JF_HOST=$DOMAIN or $PUB_IP
# JF_HOST_PORT=443
# JF_IP = 0.0.0.0
# JF_PORT = 5002
#
# JF_IP and JF_PORT are set by default
# so everything you need to set is JF_HOST and JF_HOST_PORT
#
JF_HOST=localhost
JF_HOST_PORT=443
# Defines how Jellyfish is seen from the outside.
# It can be in one of the following forms:
# * ip:port
# * fqdn:port
# * fqdn
# By default, it is equal to "JF_IP:JF_PORT".
JF_HOST=localhost:5002

# JF_METRICS_IP=0.0.0.0
# JF_METRICS_PORT=9568
Expand All @@ -49,7 +18,7 @@ JF_HOST_PORT=443
JF_SERVER_API_TOKEN=jellyfish_docker_token

# Used by the server e.g. to create client tokens.
# If not set, it will be generated
# If not set, it will be generated.
# JF_SECRET_KEY_BASE=super-secret-key

# Decide if jellyfish will check origin of requests
Expand All @@ -71,6 +40,7 @@ JF_WEBRTC_USED=true

# TURN default configuration
# note: loopback address as INTEGRATED_TURN_IP cannot be used inside a Docker container
# note: when running locally, JF_INTEGRATED_TURN_IP can be your private ip address
JF_INTEGRATED_TURN_IP=<your_public_ip_address>
JF_INTEGRATED_TURN_LISTEN_IP=0.0.0.0
JF_INTEGRATED_TURN_PORT_RANGE=50000-59_999
JF_INTEGRATED_TURN_PORT_RANGE=50000-50050
32 changes: 16 additions & 16 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ port =

host =
case System.get_env("JF_HOST") do
nil -> :inet.ntoa(ip) |> to_string()
nil -> "#{:inet.ntoa(ip)}:#{port}"
other -> other
end

host_port =
case ConfigReader.read_port("JF_HOST_PORT") do
nil -> port
other -> other
{host_name, host_port} =
case String.split(host, ":") do
[host_name, host_port] -> {host_name, String.to_integer(host_port)}
_ -> {host, 443}
end

config :jellyfish,
Expand All @@ -55,20 +55,10 @@ config :jellyfish,
integrated_turn_tcp_port: ConfigReader.read_port("JF_INTEGRATED_TURN_TCP_PORT"),
jwt_max_age: 24 * 3600,
output_base_path: System.get_env("JF_OUTPUT_BASE_PATH", "jellyfish_output") |> Path.expand(),
address: "#{host}:#{host_port}",
address: "#{host}",
metrics_ip: ConfigReader.read_ip("JF_METRICS_IP") || {127, 0, 0, 1},
metrics_port: ConfigReader.read_port("JF_METRICS_PORT") || 9568

config :jellyfish, JellyfishWeb.Endpoint,
secret_key_base:
System.get_env("JF_SECRET_KEY_BASE") || Base.encode64(:crypto.strong_rand_bytes(48)),
http: [ip: ip, port: port],
url: [host: host, port: host_port]

if check_origin = ConfigReader.read_boolean("JF_CHECK_ORIGIN") do
config :jellyfish, JellyfishWeb.Endpoint, check_origin: check_origin
end

case System.get_env("JF_SERVER_API_TOKEN") do
nil when prod? == true ->
raise """
Expand All @@ -84,6 +74,16 @@ case System.get_env("JF_SERVER_API_TOKEN") do
config :jellyfish, server_api_token: token
end

config :jellyfish, JellyfishWeb.Endpoint,
secret_key_base:
System.get_env("JF_SECRET_KEY_BASE") || Base.encode64(:crypto.strong_rand_bytes(48)),
http: [ip: ip, port: port],
url: [host: host_name, port: host_port]

if check_origin = ConfigReader.read_boolean("JF_CHECK_ORIGIN") do
config :jellyfish, JellyfishWeb.Endpoint, check_origin: check_origin
end

if prod? do
config :jellyfish, JellyfishWeb.Endpoint, url: [scheme: "https"]
end
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ x-jellyfish-template: &jellyfish-template
environment: &jellyfish-environment
ERLANG_COOKIE: "panuozzo-pollo-e-pancetta"
JF_SERVER_API_TOKEN: "development"
JF_HOST: "localhost"
JF_NODES: "app@app1 app@app2"
networks:
- net1
Expand Down Expand Up @@ -37,6 +36,7 @@ services:
<<: *jellyfish-environment
RELEASE_NODE: app@app1
NODE_NAME: app@app1
JF_HOST: "localhost:4001"
JF_PORT: 4001
ports:
- 4001:4001
Expand All @@ -47,6 +47,7 @@ services:
<<: *jellyfish-environment
RELEASE_NODE: app@app2
NODE_NAME: app@app2
JF_HOST: "localhost:4002"
JF_PORT: 4002
ports:
- 4002:4002
Expand Down

0 comments on commit fcca80d

Please sign in to comment.