jcrodriguez-dis / vpl-jail-system

Execution/jail server for VPL
GNU General Public License v3.0
21 stars 21 forks source link

Handle public and private domains to connect to the jail. #33

Open alphonse92 opened 4 years ago

alphonse92 commented 4 years ago

Hi! Me again.

I dockerized all components: moodle (with vpl), mysql and the jail. However, i want to know if there is a way to make vpl plugin return a public domain name to conect to the jail, instead of return the private network domain.

Explanation:

In docker, you could reach another container using it name. So, i can set to vpl moodle a jail with the url . http://jail:80/, because docker is able to resolve internally "jail" domain.

All its good and works as expected in this point. But, my computer machine can't reach http://jail:80 because my computer machine is not in the same context that docker, its outside.

I can reach the jail using http://localhost:80 (if i maps the container ports), i need to add a hostname in my hosts file to reach jail.

When i try to run code using vpl i cant to connect to the jail socket. Because moodle returns the url that it can resolve (http://jail:80) , but not the jail url that i can resolve (http://localhost:80).

So, i dont know if i can set a private jail url and public jail url, in order to resolve the jail internally and externally. In few words, moodle could send the code to http://jail:80 and returns a url that i can resolve from my local machine http://localhost:80.

If there is not a way, it could be cool, and i think its not hard to set in vpl moodle plugin.

I propose instead add a jail in this form:

http://jail:80

we could add the jail in this way: (add "->" literal)

http://jail:80->http://localhost:80

Its to hard to configure private dns and lot networking stuff to reach it.

jcrodriguez-dis commented 4 years ago

Hi @alphonse92, I guess that you are trying to configure the dockerized implementation of Moodle+VPL+mysql+jail in a way that works with minimum human intervention.

Notice that the browser needs to connect directly with the jail by Websocket. This is the reason the VPL plugin requires URLs to a jail that can also be used by the browser to reach the jail server. I think that http://jail:80 (resolved by docker) or http://localhost:80 do not fulfill this requisite.

If my guess is correct, I think that it may be possible to change the response to the browser replacing "localhost" by the server name of the current request. Defining the jail URL as

http(s)://localhost:port

the VPL module will send to the browser

http(s)://hostname:port

The plugin gets the host name from the current request to the Moodle. Notice that this solution may not be compatible with a load balancer or when the URL that arrives at the Moodle server does not contain the correct hostname.

The bad news is that this change needs a small development.

Best regards, Juan Carlos.

alphonse92 commented 4 years ago

Of course, That is what i mean. Im so busy right now, but i can do a PR with those changes

jcrodriguez-dis commented 4 years ago

I have added this feature to the TODO list.