diff --git a/.env b/.env index 9dd5e01..5623e6a 100644 --- a/.env +++ b/.env @@ -1,17 +1,20 @@ +# Configure here the private IP of your machine +# It is used by the Media Server to announce it self +# and to configure LAN_MODE ip address +LAN_PRIVATE_IP=192.168.1.60 + # Expose OpenVidu with HTTPS. -USE_TLS=false +USE_HTTPS=true # If true, you can access OpenVidu through your LAN -# If true USE_TLS must be true -LAN_MODE=false +# If true, USE_HTTPS must be true +LAN_MODE=true -# IP Address to expose OpenVidu in your LAN -LAN_PRIVATE_IP=auto -# LiveKit API Key and Secret used for apps to connect to the LiveKit server. -LIVEKIT_API_KEY=key1 -LIVEKIT_API_SECRET=abcdefghijklmnopqrstuvwxyz123456 +# LiveKit API Key and Secret. +LIVEKIT_API_KEY=devkey +LIVEKIT_API_SECRET=secret # Dashboard admin user and password. DASHBOARD_ADMIN_USERNAME=admin diff --git a/README.md b/README.md index 5aef657..604954d 100644 --- a/README.md +++ b/README.md @@ -9,50 +9,34 @@ On **Linux**: - **Docker** - **Docker Compose** -## How to run +## Install + +### Windows ```sh git clone https://github.com/OpenVidu/openvidu-local-deployment cd openvidu-local-deployment +.\configure_lan_private_ip_windows.ps1 +``` + +### Mac + +```sh +git clone https://github.com/OpenVidu/openvidu-local-deployment +cd openvidu-local-deployment +./configure_lan_private_ip_mac.sh +``` + +### Linux + +```sh +git clone https://github.com/OpenVidu/openvidu-local-deployment +cd openvidu-local-deployment +./configure_lan_private_ip_linux.sh +``` + +## Run OpenVidu + +```sh docker compose up ``` - -When the deployment is ready you will see the following message in the logs: - -``` -readycheck | ------------------------ -readycheck | OpenVidu is ready! -readycheck | Open http://localhost:4443/ in your browser -readycheck | ------------------------ -``` - -## Additional Notes - -### LAN Access (Optional) - -If you want to access the deployment in your LAN for Android or iOS devices, you need to do the following: - -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 `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`, `LAN_DOMAIN` should be `192-168-1-10.openvidu-local.dev`. - -### About `openvidu-local.dev` - -When you develop WebRTC applications, you require a secure context (HTTPS) to access the camera and microphone. This is a requirement of the WebRTC standard. - -With the aim of making it easier to develop with OpenVidu, we provide a magic domain name `openvidu-local.dev` which can resolve to any IP specified as a subdomain and it offers a valid wildcard certificate for HTTPS. It is similar to [nip.io](https://nip.io) or [traefik.me](https://traefik.me) or [localtls](https://github.com/Corollarium/localtls). - -But take into account that this is just as secure as a HTTP connection, so it is not suitable for production environments. - -### Edge cases: - -- Linux: All works just fine -- Windows (Docker desktop): - It looks like there is a little edge case which we are fighting with WSL + Docker. Looks related with this: https://stackoverflow.com/questions/61629450/webrtc-does-not-work-in-the-modern-browsers-when-a-peer-is-not-behind-a-nat-beca - - The behaviour is the following - - **Chrome based browsers**: Looks like everything works fine. ICE protocol finds a path to communicate the browser and openvidu. - - **Firefox browser**: - The only working candidate in Firefox is filtered, I was able to workaround this limitation with `media.peerconnection.ice.obfuscate_host_addresses=false`. diff --git a/caddy-proxy/entrypoint.sh b/caddy-proxy/entrypoint.sh index 94c740b..47b2ed3 100644 --- a/caddy-proxy/entrypoint.sh +++ b/caddy-proxy/entrypoint.sh @@ -11,9 +11,13 @@ if [ ! -f /var/www/index.html ]; then mkdir -p /var/www cp "$TMP_DIR/index.html" /var/www/index.html fi -if [ ! -f /var/www/app502.html ]; then +if [ ! -f /var/www/app502client.html ]; then mkdir -p /var/www - cp "$TMP_DIR/app502.html" /var/www/app502.html + cp "$TMP_DIR/app502client.html" /var/www/app502client.html +fi +if [ ! -f /var/www/app502server.html ]; then + mkdir -p /var/www + cp "$TMP_DIR/app502server.html" /var/www/app502server.html fi if [ ! -f /config/caddy/Caddyfile ]; then mkdir -p /config/caddy diff --git a/caddy-proxy/main.go b/caddy-proxy/main.go index 543e2e9..68b17bf 100644 --- a/caddy-proxy/main.go +++ b/caddy-proxy/main.go @@ -3,18 +3,19 @@ package main import ( "bytes" "fmt" - "html/template" "local-caddy-generate/templates" "os" "strconv" "strings" + "text/template" ) type TemplateData any var indexData = &templates.IndexData{} var caddyData = &templates.CaddyData{} -var app502Data = &templates.App502Data{} +var app502ClientData = &templates.App502Data{} +var app502ServerData = &templates.App502Data{} func main() { err := Initialize() @@ -45,12 +46,23 @@ func main() { os.Exit(1) } - rawApp502, err := GenerateTemplate(templates.App502Template, app502Data) + rawAppClient502, err := GenerateTemplate(templates.App502Template, app502ClientData) if err != nil { fmt.Println(err) os.Exit(1) } - err = WriteStringToFile("app502.html", rawApp502) + err = WriteStringToFile("app502client.html", rawAppClient502) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + rawAppServer502, err := GenerateTemplate(templates.App502Template, app502ServerData) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = WriteStringToFile("app502server.html", rawAppServer502) if err != nil { fmt.Println(err) os.Exit(1) @@ -59,21 +71,30 @@ func main() { } func Initialize() error { - httpPort := 8090 - httpsPort := 4443 - AppPort := 5442 + // OpenVidu && LiveKit API + httpPort := 7880 + httpsPort := 7443 + + // Http ports + appClientPort := 5080 + appClientServer := 6080 + + // Https ports + httpsAppClientPort := 5443 + httpsAppServerPort := 6443 + version := os.Getenv("VERSION") if version == "" { return fmt.Errorf("VERSION is not set") } - rawUseTLS := os.Getenv("USE_TLS") - if rawUseTLS == "" { - rawUseTLS = "false" + rawUseHTTPS := os.Getenv("USE_HTTPS") + if rawUseHTTPS == "" { + rawUseHTTPS = "false" } - useTLS, err := strconv.ParseBool(rawUseTLS) + useTLS, err := strconv.ParseBool(rawUseHTTPS) if err != nil { - return fmt.Errorf("USE_TLS is not a boolean") + return fmt.Errorf("USE_HTTPS is not a boolean") } lanMode := os.Getenv("LAN_MODE") @@ -98,10 +119,20 @@ func Initialize() error { httpUrl := fmt.Sprintf("http://localhost:%d", httpPort) httpsUrl := "" + wsUrl := fmt.Sprintf("ws://localhost:%d", httpPort) + wssUrl := "" + httpsAppClientUrl := "" + httpsAppServerUrl := "" if useTLS { httpsUrl = fmt.Sprintf("https://localhost:%d", httpsPort) + wssUrl = fmt.Sprintf("wss://localhost:%d", httpsPort) + httpsAppClientUrl = fmt.Sprintf("https://localhost:%d", httpsAppClientPort) + httpsAppServerUrl = fmt.Sprintf("https://localhost:%d", httpsAppServerPort) if lanMode == "true" { httpsUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsPort) + wssUrl = fmt.Sprintf("wss://%s:%d", lanDomain, httpsPort) + httpsAppClientUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsAppClientPort) + httpsAppServerUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsAppServerPort) } } @@ -139,6 +170,8 @@ func Initialize() error { LanMode: lanMode == "true", HttpUrl: httpUrl, HttpsUrl: httpsUrl, + WsUrl: wsUrl, + WssUrl: wssUrl, LiveKitApiKey: livekitApiKey, LiveKitApiSecret: livekitApiSecret, OpenViduSecret: openviduSecret, @@ -151,15 +184,30 @@ func Initialize() error { caddyData = &templates.CaddyData{ LanMode: lanMode == "true", LanDomain: lanDomain, - HttpUrl: httpUrl, - HttpsUrl: httpsUrl, + // Main OpenVidu and LiveKit API ports HttpPort: strconv.Itoa(httpPort), HttpsPort: strconv.Itoa(httpsPort), - AppPort: strconv.Itoa(AppPort), + // Main OpenVidu and LiveKit API URLs + HttpUrl: httpUrl, + HttpsUrl: httpsUrl, + // Tutorial ports + AppClientPort: strconv.Itoa(appClientPort), + AppServerPort: strconv.Itoa(appClientServer), + HttpsAppClientPort: strconv.Itoa(httpsAppClientPort), + HttpsAppServerPort: strconv.Itoa(httpsAppServerPort), + // Tutorial URLs + HttpsAppClientUrl: httpsAppClientUrl, + HttpsAppServerUrl: httpsAppServerUrl, } - app502Data = &templates.App502Data{ - AppPort: strconv.Itoa(AppPort), + app502ClientData = &templates.App502Data{ + Title: "Application Client Not Found", + Message: fmt.Sprintf("Run your Application Client at port %d and you will see it here", appClientPort), + } + + app502ServerData = &templates.App502Data{ + Title: "Application Server Not Found", + Message: fmt.Sprintf("Run your Application Server at port %d and you will see it here", appClientServer), } return nil diff --git a/caddy-proxy/templates/app502.go b/caddy-proxy/templates/app502.go index 84d8813..c9cafec 100644 --- a/caddy-proxy/templates/app502.go +++ b/caddy-proxy/templates/app502.go @@ -1,7 +1,8 @@ package templates type App502Data struct { - AppPort string + Title string + Message string } const App502Template = ` @@ -37,14 +38,12 @@ const App502Template = `
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.
+{{ .Message }}