flutter-webrtc / flutter-webrtc-server

A simple WebRTC signaling server for flutter-webrtc.
MIT License
756 stars 304 forks source link

如何让客户端不用开4442, 4443端口? #9

Closed Leadrive closed 5 years ago

Leadrive commented 5 years ago

在NGINX中,想把端口4443集成到443中,不想让客户端再开4442,4443

upstream webrtcServer { server 0.0.0.0:8086; } upstream webrtcWSS { server 0.0.0.0:4443; } server { listen 443 ssl; server_name webrtc.touroad.cn; index index.html index.htm index.php; ssl on; ssl_certificate /home/ssl/webrtc.touroad.cn.pem; ssl_certificate_key /home/ssl/webrtc.touroad.cn.key; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; gzip_min_length 1k; gzip_comp_level 2; gzip_types text/plain text/css application/xml image/jpeg image/gif image/png image/jpg text/javascript application/javascript; location / { if ( $http_sec_websocket_protocol = "" ) { proxy_pass https://webrtcServer; } if ( $http_sec_websocket_protocol != "" ) { proxy_pass https://webrtcWSS; } proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }

我测试了这样的配置,不成功,请问有办法吗? 谢谢

Leadrive commented 5 years ago

改成了用二级目录的形式,可以了。

location /wss { proxy_pass https://webrtcWSS; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; }

通过 wss://x.xxx.cn/wss来访问,不用开4443端口了。

cloudwebrtc commented 5 years ago

已经更新项目, 你可以先用 npm run build 编译出dist 目录, 再使用 node server/index.js.

之后就可以通过http://localhost:4442/, https://localhost:4443/ 访问。

Leadrive commented 5 years ago

@cloudwebrtc 按你说的,在浏览器中,出现错误 Cannot GET /