Hello everyone, I have the following situation: I ...
# ask-ai
l
Hello everyone, I have the following situation: I have set up LiveKit using docker-compose and livekit image v1.0.5 alongside Caddy. I have imported my own ssl certificate on the server and referenced it inside of the caddy.yaml configuration file. Everything finally works (web app, mobile app) but for some reason it doesnt work on firefox browser, can someone help me or contact me so i can send you configuration files (livekit.yaml and caddy.yaml) just so you can take a look and help somehow?
t
Thanks for reaching out, Kenan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To help us get to the bottom of the Firefox issue you’re experiencing, could you share a bit more info? • How are you setting up your custom SSL certificates in Caddy? Are you completely replacing the automatic Let’s Encrypt/ZeroSSL certificates? • Are your custom certificates valid for all the domains you need (like both your main domain and TURN domains)? You can double-check this by running:
openssl s_client -connect yourdomain:443
. • What exact error messages or strange behavior are you seeing in Firefox? If you could peek at the browser’s developer console, LiveKit server logs, and Caddy logs, any details there would be super helpful. • Which version of Firefox are you using? • And just to compare, do other browsers like Chrome or Safari work fine with your current setup? Sources: release/adapter_no_global.js | CHANGELOG.md | CHANGELOG.md | Deploy to a VM | LiveKit Docs | Deploy to a VM | LiveKit Docs
l
Copy code
mzadmin@mz-edosije-livekit1-t:/opt/livekit$ cat caddy.yaml
logging:
  logs:
    default:
      level: INFO

storage:
  module: file_system
  root: /data

apps:
  tls:
    certificates:
      load_files:
        - certificate: /opt/livekit/certs/restofthedomain-fullchain.pem
          key: /opt/livekit/certs/restofthedomain.key

  layer4:
    servers:
      main:
        listen: [":443"]
        routes:
          - match:
              - tls:
                  sni:
                    - "video1-turn.restofthedomain"
            handle:
              - handler: tls
              - handler: proxy
                upstreams:
                  - dial: ["10.36.16.243:5349"]

          - match:
              - tls:
                  sni:
                    - "livekit1-stage.restofthedomain"
            handle:
              - handler: tls
                connection_policies:
                  - alpn: ["http/1.1"]
              - handler: proxy
                upstreams:
                  - dial: ["localhost:7880"]
Here is the caddy configuration file My custom certificates are valid for all the domains I need, I ran the openssl command, works for all the domains In the image you can see the errors im getting, there are no logs in livekit server or application logs All of the other browsers work perfetcly, chrome safari etc..
t
Thanks so much for sharing your Caddy configuration and the extra details! Based on what you’ve provided, here are a few friendly steps that might help sort out the Firefox-specific issue: • Verify Certificate Trust: Even though your certificates are valid for all domains, it’s a good idea to double-check that Firefox trusts them explicitly. Firefox uses its own certificate store, and if it doesn’t trust a certificate, that can cause WebRTC and CORS hiccups. • Check CORS Headers: Make sure your Caddy setup includes the right CORS headers, like
Access-Control-Allow-Origin
with specific origins (try to avoid wildcards if you’re using credentials) and
Access-Control-Allow-Credentials: true
if that applies. • Validate WebRTC Adapter: Take a look to confirm the LiveKit WebRTC adapter is loading properly in Firefox. It’s worth checking the browser console for any JavaScript errors that might be stopping it from initializing correctly. • SSL Certificate Validation: If you can, try testing with certificates from a trusted CA (like Let’s Encrypt) just to rule out any certificate-related issues. Firefox tends to be a bit stricter with security for WebRTC connections. • Cross-Origin Headers: You might want to add headers like
Cross-Origin-Opener-Policy: same-origin
and
Cross-Origin-Embedder-Policy: credentialless
to your Caddy config to better align with WebRTC requirements. Also, could you let me know if Firefox is showing any certificate warnings or security errors? And if the WebRTC connection state (like
room.engine.connectedServerAddr
) gives any hints? I’m here to help if you want to dig deeper! Sources: JavaScript & React Components | livekit/livekit_composite | DeepWiki | test/singlenode_test.go | Deploying LiveKit | LiveKit Docs | Deploy to a VM | LiveKit Docs | release/adapter_no_global.js
l
How can I add CORS configuration when im using layer 4 and not http block of code inside my caddy configuration?
t
Adding CORS headers in Caddy's layer 4 configuration can be a bit tricky since layer 4 works at the transport layer and doesn’t really look at or change HTTP headers. But don’t worry, here are a few options that might help: • Application-Level CORS Handling: You could set up your application (like your LiveKit server) to handle CORS headers directly. This usually gives you the most flexibility, especially for WebRTC apps. • Switch to HTTP Mode: If it’s an option, try using Caddy’s HTTP mode instead of layer 4 for the traffic you’re dealing with. In HTTP mode, adding CORS headers is straightforward with the
header
directive. • Custom Middleware: If you really need to stick with layer 4, think about adding a middleware or proxy layer that can peek into and modify HTTP headers before the traffic hits Caddy. Could you share a bit more about the kind of traffic you’re proxying with Caddy’s layer 4 and what your CORS needs look like? That way, I can help find the best fit for your setup. Sources: pkg/whip/server.go | tools/server/server.cpp | Deploy to a VM | LiveKit Docs