diff --git a/.env b/.env
index b1c9560..dc0f397 100644
--- a/.env
+++ b/.env
@@ -1,15 +1,13 @@
-# Only 'openvidu-local.dev', '*.openvidu-local.dev' or 'localhost' can be used.
-# To access in a LAN environment using 'openvidu-local.dev', just add the IP as a
-# subdomain. For example if your IP is 192.168.1.105, just use '192-168-1-105.openvidu-local.dev'.
-# In this way, you can access from any device in your LAN.
-LOCAL_DOMAIN=localhost
-# If false, services will not run with TLS.
+
+# Expose OpenVidu with HTTPS.
USE_TLS=false
-# Announced IP for LAN access. If 'auto', best effort will be made to find
-# the private IP of the machine.
-# If the detected IP is not correct, you can set it manually.
-PRIVATE_IP=auto
+# If true, you can access OpenVidu through your LAN
+# If true USE_TLS must be true
+LAN_MODE=false
+
+# LAN IP Address to expose OpenVidu
+LAN_PRIVATE_IP=auto
# LiveKit API Key and Secret used for apps to connect to the LiveKit server.
LIVEKIT_API_KEY=key1
diff --git a/README.md b/README.md
index 8d4f872..5aef657 100644
--- a/README.md
+++ b/README.md
@@ -34,9 +34,9 @@ If you want to access the deployment in your LAN for Android or iOS devices, you
1. Get the private IP of your computer in your LAN.
2. Configure your Firewall to allow devices in your LAN to access your computer.
-3. Change `LOCAL_DOMAIN` in the `.env` file to have the IP of your computer in your LAN.
+3. Change `LAN_DOMAIN` in the `.env` file to have the IP of your computer in your LAN.
- If your IP for example is `192.168.1.10`, `LOCAL_DOMAIN` should be `192-168-1-10.openvidu-local.dev`.
+ If your IP for example is `192.168.1.10`, `LAN_DOMAIN` should be `192-168-1-10.openvidu-local.dev`.
### About `openvidu-local.dev`
diff --git a/caddy-proxy/main.go b/caddy-proxy/main.go
index 694f68b..543e2e9 100644
--- a/caddy-proxy/main.go
+++ b/caddy-proxy/main.go
@@ -14,6 +14,7 @@ type TemplateData any
var indexData = &templates.IndexData{}
var caddyData = &templates.CaddyData{}
+var app502Data = &templates.App502Data{}
func main() {
err := Initialize()
@@ -21,6 +22,7 @@ func main() {
fmt.Println(err)
os.Exit(1)
}
+
rawIndex, err := GenerateTemplate(templates.IndexTemplate, indexData)
if err != nil {
fmt.Println(err)
@@ -43,7 +45,7 @@ func main() {
os.Exit(1)
}
- rawApp502, err := GenerateTemplate(templates.App502Template, nil)
+ rawApp502, err := GenerateTemplate(templates.App502Template, app502Data)
if err != nil {
fmt.Println(err)
os.Exit(1)
@@ -57,25 +59,52 @@ func main() {
}
func Initialize() error {
+ httpPort := 8090
+ httpsPort := 4443
+ AppPort := 5442
version := os.Getenv("VERSION")
if version == "" {
return fmt.Errorf("VERSION is not set")
}
- localDomain := os.Getenv("LOCAL_DOMAIN")
- if localDomain == "" {
- return fmt.Errorf("LOCAL_DOMAIN is not set")
- }
-
rawUseTLS := os.Getenv("USE_TLS")
if rawUseTLS == "" {
- return fmt.Errorf("USE_TLS is not set")
+ rawUseTLS = "false"
}
useTLS, err := strconv.ParseBool(rawUseTLS)
if err != nil {
return fmt.Errorf("USE_TLS is not a boolean")
}
+ lanMode := os.Getenv("LAN_MODE")
+ if lanMode == "" {
+ lanMode = "false"
+ }
+
+ lanPrivateIP := os.Getenv("LAN_PRIVATE_IP")
+ if lanPrivateIP == "" {
+ return fmt.Errorf("LAN_PRIVATE_IP is not set")
+ }
+
+ lanDomain := os.Getenv("LAN_DOMAIN")
+ if lanDomain == "" {
+ lanDomain = "openvidu-local.dev"
+ }
+
+ if lanPrivateIP != "none" && lanDomain == "openvidu-local.dev" {
+ ipDashes := strings.ReplaceAll(lanPrivateIP, ".", "-")
+ lanDomain = fmt.Sprintf("%s.%s", ipDashes, lanDomain)
+ }
+
+ httpUrl := fmt.Sprintf("http://localhost:%d", httpPort)
+ httpsUrl := ""
+ if useTLS {
+ httpsUrl = fmt.Sprintf("https://localhost:%d", httpsPort)
+ if lanMode == "true" {
+ httpsUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsPort)
+ }
+ }
+
livekitApiKey := os.Getenv("LIVEKIT_API_KEY")
if livekitApiKey == "" {
return fmt.Errorf("LIVEKIT_API_KEY is not set")
@@ -107,9 +136,9 @@ func Initialize() error {
indexData = &templates.IndexData{
OpenViduVersion: version,
- DomainName: localDomain,
- IsLocalhost: localDomain == "localhost",
- IsTLS: useTLS,
+ LanMode: lanMode == "true",
+ HttpUrl: httpUrl,
+ HttpsUrl: httpsUrl,
LiveKitApiKey: livekitApiKey,
LiveKitApiSecret: livekitApiSecret,
OpenViduSecret: openviduSecret,
@@ -120,9 +149,17 @@ func Initialize() error {
}
caddyData = &templates.CaddyData{
- DomainName: localDomain,
- IsLocalhost: localDomain == "localhost",
- IsTLS: useTLS,
+ LanMode: lanMode == "true",
+ LanDomain: lanDomain,
+ HttpUrl: httpUrl,
+ HttpsUrl: httpsUrl,
+ HttpPort: strconv.Itoa(httpPort),
+ HttpsPort: strconv.Itoa(httpsPort),
+ AppPort: strconv.Itoa(AppPort),
+ }
+
+ app502Data = &templates.App502Data{
+ AppPort: strconv.Itoa(AppPort),
}
return nil
diff --git a/caddy-proxy/templates/app502.go b/caddy-proxy/templates/app502.go
index 80dd296..84d8813 100644
--- a/caddy-proxy/templates/app502.go
+++ b/caddy-proxy/templates/app502.go
@@ -1,5 +1,9 @@
package templates
+type App502Data struct {
+ AppPort string
+}
+
const App502Template = `
@@ -35,7 +39,7 @@ const App502Template = `
502 - Bad Gateway
OpenVidu Application Not Found
-
If you are developing an application and run it locally at port 5442, you will see here your application, under
+
If you are developing an application and run it locally at port {{.AppPort}}, you will see here your application, under
the same domain and TLS certificate as OpenVidu.
Your App:http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:8000:
- If you are developing an application and run it locally at port 5442, you will see your application here, under the same domain and TLS certificate as OpenVidu.
- {{- if not .IsLocalhost }}
-
If you want to access this deployment with http(s)://localhost:4443, just change the LOCAL_DOMAIN variable to localhost in the .env file.
- {{- else }}
-
If you want to access this deployment with http(s)://openvidu-local.dev:4443, just change the LOCAL_DOMAIN variable to openvidu-local.dev in the .env file.
- {{- end }}
- {{- if .IsTLS }}
-
If you want to disable TLS, just change the USE_TLS variable to false in the .env file.
- {{- else }}
-
If you want to enable TLS, just change the USE_TLS variable to true in the .env file.