I am creating an online IDE for different languages. So my approach to the same is to spin up a docker container from my DJango app once a user runs his code, but the problem is how do I expose the terminal of the docker container to the internet and make it accessible via the browser? I am planning to use xterm.js for the frontend of the terminal but am unable to connect to it.
Any form of insight is appreciable.
CodePudding user response:
You can you an reverse-proxy with NGINX to point to your localIP:<container_port>, and then modify with your domain name. As this exemple below:
location /some/path/ {
proxy_pass http://www.example.com/link/;
}
Adding some links to help you. enter link description here
Also you can use 'Nginx Proxy Manager'
CodePudding user response:
Short answer: Your application uses a port to access it (for example, you use 127.0.0.1:8080 or 192.168.1.100:3000). 127.0.0.1 means the computer you are using right now, 192.168.1.100 is a computer inside the 192.168.1.0 network. (Your LAN)
You must create (on your router) access from the internet to your application. For exemple, if your public IP address is 123.245.123.245, you need to use an external port (ex: 80), and map it to your internal address and port (ex: 192.168.1.100:3000)
the URL 123.245.123.245:80 will redirect to the website on 192.168.1.100:3000.
On the short term, this is the easiest solution.
For the long term, you should try using a Reverse Proxy.
It's a program that will (depending on the domain) redirect to sites inside your network and adding encryption in the requests (if possible).
Check this link : doc