First off thank you for taking the time to reply!! My goal is to use the coturn server that is deployed with OpenVidu’s docker image. With that in mind here is my setup. I host several websites so I have the need for a reverse proxy. I’ve tried both Apache and nginx with the exact same result. I only have one server and there is no NAT.
external_ip → router (fowards port 443 to server)-> Apache (depending on website forwards to correct service) → OpenVidu
Doing telnet 3478 external_ip it connects without issues. I also have ports 40000-65535 open.
I tried testing using this online tool but not sure where I create/set the userName/password for the coturn server. If I’m not mistaken the included coturn server that is deployed with OpenVidu’s docker image has a file called shared-secret-key and with in there there is a value COTURN_SHARED_SECRET_KEY. Is that the staticAuthSecret??
As for the proxy configs… The one you posted above ends up giving me a CORS error on the front end and not sure how I’d configure CORS on OpenVidu. I have the following config on apache that does reach OpenVidu and creates a token but when the websocket tries to connect something is either misconfigured or is not able to reach something? (I’m guessing is not able to reach coturn):
<VirtualHost *:443>
ServerName video.****.com
ServerAlias www.video.***.com
ServerAlias video.***.com
SSLEngine On
SSLCertificateFile /home/com.crt
SSLCertificateKeyFile /home/com.key
SSLCertificateChainFile /home/ServerCA.crt
LogLevel debug
Timeout 60
ProxyTimeout 60
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
SSLProxyEngine on
# ProxyPass for HTTP
<Location "/">
ProxyPass "http://192.168.254.11:5443/"
ProxyPassReverse "http://192.168.254.11:5443/"
</Location>
# ProxyPass for WebSocket
<Location "/wss">
ProxyPass "ws://192.168.254.11:5443/"
ProxyPassReverse "ws://192.168.254.11:5443/"
RewriteEngine On
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule .* "http://192.168.254.11:5443/$1" [P]
</Location>
<Directory "/opt/openvidu/">
AllowOverride All
</Directory>
KeepAliveTimeout 60
KeepAlive On
</VirtualHost>
I also turned off apache thinking it was a bug with wstunnel and here is my nginx config that gave me the exact same result as apache (able to create a session and a token but the websocket is unable to connect):
server {
listen 443 ssl;
server_name video.****.com www.video.****.com;
ssl_certificate /home/com.crt;
ssl_certificate_key /home/com.key;
ssl_trusted_certificate /home/ServerCA.crt;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /wss {
proxy_pass https://192.168.254.11:5443/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location / {
proxy_pass http://192.168.254.11:5443/;
}
location /opt/openvidu/ {
allow all;
satisfy any;
allow 127.0.0.1;
deny all;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
keepalive_timeout 60s;
keepalive_requests 100;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
My OpenVidu .env has:
DOMAIN_OR_PUBLIC_IP=video.****.com
CERTIFICATE_TYPE=owncert
#added but I really don't think i need this because coturn is deployed with OpenVidu docker image
OPENVIDU_WEBRTC_ICE_SERVERS=["url=turn:video.****.com:3478,staticAuthSecret=*******"]
Everything else in that .env file is as it came when I downloaded OpenVidu. I’m fairly confident the certs are working because when I first installed OpenVidu I had an issue with them and I wasn’t even able to create a token. After fixing the certs I was able to create a token when calling OpenVidu.
Here is logs from OpenVidu using the proxy config above:
openvidu-openvidu-server-1 | [INFO] 2023-06-09 14:27:15,414 [http-nio-0.0.0.0-5443-exec-5] io.openvidu.server.rest.SessionRestController - REST API: POST /openvidu/api/sessions/SessionA/connection {id=SessionA, object=session, sessionId=SessionA, createdAt=1686320835288, recording=false, broadcasting=false, mediaMode=ROUTED, recordingMode=MANUAL, defaultRecordingProperties={name=, hasAudio=true, hasVideo=true, outputMode=COMPOSED, recordingLayout=BEST_FIT, resolution=1280x720, frameRate=25, shmSize=536870912}, customSessionId=SessionA, forcedVideoCodec=MEDIA_SERVER_PREFERRED, allowTranscoding=false, connections={numberOfElements=0, content=[]}}
openvidu-openvidu-server-1 | [INFO] 2023-06-09 14:27:15,427 [http-nio-0.0.0.0-5443-exec-5] io.openvidu.server.rest.SessionRestController - Generated token wss://video.****.com?sessionId=SessionA&token=tok_AADGgKBEHWUWUu2M
openvidu-openvidu-server-1 | [INFO] 2023-06-09 14:28:40,461 [http-nio-0.0.0.0-5443-exec-7] io.openvidu.server.config.HttpHandshakeInterceptor - New HttpSession 401270C46746A9055AC2EB40194DF785
openvidu-openvidu-server-1 | [ERROR] 2023-06-09 14:28:40,462 [http-nio-0.0.0.0-5443-exec-7] org.springframework.web.socket.server.support.DefaultHandshakeHandler - "Handshake failed due to invalid Upgrade header: null"
openvidu-openvidu-server-1 | [INFO] 2023-06-09 14:28:51,480 [http-nio-0.0.0.0-5443-exec-8] io.openvidu.server.config.HttpHandshakeInterceptor - New HttpSession 1398A4D5E6EF075FF1059D20B7668BC1
openvidu-openvidu-server-1 | [ERROR] 2023-06-09 14:28:51,480 [http-nio-0.0.0.0-5443-exec-8] org.springframework.web.socket.server.support.DefaultHandshakeHandler - "Handshake failed due to invalid Upgrade header: null"
On the front-end I get the following error:
WebSocket connection to 'wss://video.****.com/openvidu?sessionId=SessionA' failed:
WebSocketWithReconnection @ webSocketWithReconnection.js:45
JsonRpcClient @ jsonrpcclient.js:136
OpenVidu.startWs @ OpenVidu.ts:884
(anonymous) @ Session.ts:1599
Session.connectAux @ Session.ts:1598
(anonymous) @ Session.ts:178
Session.connect @ Session.ts:168
(anonymous) @ App.js:126
Is this enough information that will help you help me?? My goal is to use as much out of the box as possible since OpenVidu is pretty rad.