tip: VPL behind nginx reverse-proxy and "URL path not found"

tip: VPL behind nginx reverse-proxy and "URL path not found"

by Jacques Theys -
Number of replies: 2

Hello everyone,

I have been struggling for days trying to make our vpl jail server work behind an nginx reverse proxy. Everytime I tried to compile and run a program inside the vpl module in Moodle, I got no console displaying and a logged message "URL path not found" in syslog. When I traced connections to the vpl server, I could see that the Moodle server correctly sent the piece of code and all relevant data to the vpl server, but the Websocket connection from the browser to monitor the execution failed.

Eventually, I had a look into the source code of the vpl server and discovered that this error message is thrown when vpl is called using a plain http request that do not match robots.txt or favicon.ico. Websocket requests are handled by another part of the code. So, I managed to find why vpl did not consider calls to the monitor as WS requests.

It seems that a specific header is used to check if a request is a plain http or WS request. After Qwanting (like Googling, but using Qwant), I found two lines I had to add to my nginx site configuration file to make it proxy requests as WS requests:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Now, everything is working smoothly.

BTW, I was previously using HAProxy as reverse proxy and it correctly handled ws connections without any further configuration.

I hope this will be helpful to other people...

Average of ratings: -
In reply to Jacques Theys

Re: tip: VPL behind nginx reverse-proxy and "URL path not found"

by Saiful Bahri -

Hello Jacques,

Thanks for sharing the nginx reverse proxy tip.

It seem to work partially for me though. During preview question, it works during "Pre-Check". But is giving me an Evaluation error upon clicking "Submit and finish" - 

An error occured during question grading (no grade obtained).
In my internaljail vpl server syslog, I caught this output.

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: Read config param STARTTIME=1645371273

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: Non interactive execution

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: Installing .vpl_launcher.sh in vpl_batch_launcher.sh

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: run: maxtime: 240 seg, maxfilesize: 65536 Kb, maxmemory 131072 Kb, maxprocesses: 200

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: child pid 5398

Feb 20 15:34:35 internaljail vpl-jail-system[5398]: chrooted "/jail"

Feb 20 15:34:35 internaljail vpl-jail-system[5398]: setLimits: maxtime: 240 seg, maxfilesize: 65536 Kb, maxmemory 131072 Kb, maxprocesses: 200

Feb 20 15:34:35 internaljail vpl-jail-system[5398]: change user to 10415

Feb 20 15:34:35 internaljail vpl-jail-system[5398]: Jail::transferExecution to /home/p10415+.vpl_launcher.sh

Feb 20 15:34:35 internaljail vpl-jail-system[5398]: Running "/home/p10415/.vpl_launcher.sh"

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: New redirector state 0 => 2

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: Program end or I/O error: Invalid argument 16 (POLLHUP ).

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: New redirector state 2 => 5

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: Complete program output: Testing 1/5 : Test0#015#012Testing 2/5 : Test2#015#012Testing 3/5 : Test4#015#012Testing 4/5 : Test6#015#012Testing 5/5 : Test8#015#012#015#012<|--#015#012-Summary of tests#015#012>+------------------------------+#015#012>|  5 tests run/ 5 tests passed |#015#012>+------------------------------+#015#012#015#012--|>#015#012#015#012Grade :=>>100#015

Feb 20 15:34:35 internaljail vpl-jail-system[5354]: Write execution result


vpljail version 2.7.1

moodle version 3.8



Attachment Screenshot 2022-02-20 at 11.32.04 PM.png
Attachment Screenshot 2022-02-20 at 11.37.45 PM.png
In reply to Saiful Bahri

Re: tip: VPL behind nginx reverse-proxy and "URL path not found"

by Jacques Theys -
Hello,
For what I can see, this does not seem to be related to a nginx problem. It looks like there is something missing on your vpl server, preventing correct execution of jailed programs.
POLLHUP means hangup: somewhere in the test chain, some parent program called a child, expected it from writing things on standard output and getting them through a pipe, but the pipe broke up or was not even opened. Maybe there is something missing on your server for correct execution of jailed programs: compilers, build chains or something similar.

Did you change the content of launcher scripts ?

If this can help you, here is my nginx configuration file for VPL:

server {
listen 443 ssl http2;
server_name vpl.mysuperservername.tld;
proxy_buffering off;

location ^~ / {
proxy_http_version 1.1;
proxy_pass http://internalvpladdress;
// This one allows requests from Moodle server
add_header 'Access-Control-Allow-Origin' 'https://moodle.mysuperservername.tld';
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

Hope you will find...
Average of ratings: Useful (1)