r/CodingHelp • u/Doltishdp • 6h ago
[How to] Is it possible to set up a localhost server that allows WebRTC services outside your own network?
For a personal project, I needed to create a video call and screen sharing service, but to avoid paying for a server, I was wondering if it’s actually possible to run the server on localhost and have the other person connect through a Cloudflare tunnel. Do you know if this is possible? How feasible is it, and what problems might arise?
•
u/Buttleston Professional Coder 5h ago
Yes, there are a number of services that would make it possible. ngrok is an example - it basically runs on your machine and creates a proxy between their services and your machine, assigning you a temporary address
You could probably do it with something like Tailscale if it's for demo purposes and you just need one other specific person to have access. You'd just need both your computer and theirs to be part of the same tailscale vpn (this would work with any VPN of this type)
Reading about a cloudflare tunnel, this would likely work as well, but I don't have personal experience with it
There are cloud services that have a free tier - not sure if what you want to do would fit within that, they usually allow only pretty low powered VM instances but it might work for you.
•
u/Buttleston Professional Coder 5h ago
Actually, reading more, I am not sure cloudflare tunnel would be a good choice for webrtc. Ngrok probably won't work well either, because apparently webrtc uses UDP quiet heavily instead of TCP
You can force webrtc to use tcp but the performance will be worse
•
u/bishakhghosh_ 4h ago
the point of using webrtc is that the traffic will not go through the "server", and ideally it will be browser to browser. the only server component is the signalling server. If the users are too unlucky they might need a relay called a TURN server.
I had implemented these things before AI, by hand. I know i sound like "I walked to school uphill both ways - in the snow, barefoot!"
•
•
u/Buttleston Professional Coder 4h ago
And fwiw I'm 50 and started programming in an era where package repos basically did not exist, so we programmed pretty much everything by ourselves, with occasional libraries from random websites
•
u/bishakhghosh_ 4h ago
Yes. For webrtc calling you just need the signalling server. You can host that locally and share that via any tunneling tool. For example if you run that on localhost:8080 then you can get a public url for it using pinggy.io by running ssh -p 443 -R0:localhost:8080 free.pinggy.io .
For STUN, there are many STUN servers available - google has some, see here https://gist.github.com/zziuni/3741933
If you are unaware of what signalling server or STUN means, you should definitely read https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling
•
u/AutoModerator 6h ago
Thank you for posting on r/CodingHelp!
Please check our Wiki for answers, guides, and FAQs: https://coding-help.vercel.app
Our Wiki is open source - if you would like to contribute, create a pull request via GitHub! https://github.com/DudeThatsErin/CodingHelp
We are accepting moderator applications: https://forms.fillout.com/t/ua41TU57DGus
We also have a Discord server: https://discord.gg/geQEUBm
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.