CodeRunner Issues, Could it be Nginx???

CodeRunner Issues, Could it be Nginx???

de Bruce Nelson -
Número de respuestas: 7

Hi
I have used CodeRunner before and I like it. However, I recently migrated Moodle to Nginx. Initially, I thought it didn't work because I had upgraded to Moodle 4.3 before the CodeRunner Moodle plugin for Moodle 4.3 was released. However, I realized that it did not work on the new server (the one running on Nginx), but it does run on the old Moodle server, which is still on Moodle 4.2 and runs on Apache.

I installed Moodle 4.3 on a Virtual Machine running Nginx, but it did not work. It returned the error below.


I plan to install the 4.3 Version on Moodle running on Apache to confirm the theory.

Assuming the issue is due to running Nginx on Moodle:
Is there a way of solving this???
If I tried installing the Jobe server with Nginx, would that solve the problem???

En respuesta a Bruce Nelson

Re: CodeRunner Issues, Could it be Nginx???

de Richard Lobb -
CodeRunner works fine with nginx. I'm assuming you have installed the version of CodeRunner that works with Moodle 4.

The most likely explanation is a networking error or Moodle security settings blocking the connection to Jobe. If you are a Moodle administrator you should got to Site administration > General > Security > HTTP Security. Clear the cURL block hosts list and make sure the cURL allowed ports list includes port 80. If that solves your problem, see if you can figure out which of the default blocked hosts is causing the problems. If it doesn't fix the problem, post back.
En respuesta a Richard Lobb

Re: CodeRunner Issues, Could it be Nginx???

de Bruce Nelson -

Hi Richard,

Thank you for the help,  it worked! 

I however ran into another issue. So, when I create the quiz, and I preview it from the question tab.  it works as expected


Results:


But a preview under the quiz tab fails


It returns Bad Gateway, It does not even load the coding area:



That is what students get when they attempt the quiz. The problem seems to be specific to the coderunner quizzes. I tried previewing other quizzes like stack and multiple choices... they previewed correctly.
How do I go about this???

En respuesta a Bruce Nelson

Re: CodeRunner Issues, Could it be Nginx???

de Richard Lobb -
You need to check the log files - probably nginx/error.log and php-fpm/error.log. One of those should tell you what happened. My guess is that PHP crashed and you probably need to tweak the php.ini settings. Perhaps memory_limit?
En respuesta a Richard Lobb

Re: CodeRunner Issues, Could it be Nginx???

de Bruce Nelson -

Hi when I checked the Nginx error.log, this is what showed up:
[error] 938#938: *7907 upstream sent too big header while reading response header from upstream, client: 192.168.10.1, server: afru.ac.ug, request: "GET /mod/quiz/attempt.php?attempt=885&cmid=8774 HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "moodle.afru.ac.ug", referrer: "https://moodle.afru.ac.ug/mod/quiz/view.php?id=8774"


En respuesta a Bruce Nelson

Re: CodeRunner Issues, Could it be Nginx???

de Richard Lobb -
I don't have a system generating these errors, so I can't be sure of anything. But the response with 43 votes inthis thread on stack overflow seems a possible explanation? Apparently excessive stderr output from the PHP job can result in a 402. Are you sure there's nothing interesting in the php-fpm logs? 

What version of PHP are you running and what version of CodeRunner? Also, what level of error logging have you got in the php-fpm php.ini file?

PHP version 8.3 issues reports screeds of Notice "errors" with CodeRunner versions prior to 2024021900 due to dynamic attribute assignment. If these are being written to stderr, it might result in the error you're seeing.
En respuesta a Richard Lobb

Re: CodeRunner Issues, Could it be Nginx???

de Bruce Nelson -
That worked! Thank you so much!!!
I put the settings below in the HTTP block located in the nginx.conf file
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

However, I had made some changes and I am not sure how they affect the system:
After checking the PHP logs, I found this:

[22-Feb-2024 08:07:01] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
[22-Feb-2024 08:12:39] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
[22-Feb-2024 08:23:54] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
[22-Feb-2024 08:25:17] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
[22-Feb-2024 09:20:45] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
[22-Feb-2024 13:41:17] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
[22-Feb-2024 19:13:11] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

So I changed the pm.max_children setting from 5 to 30 www.conf
I also changed the memory_limit from 128 to 128 * 30 = 3840M in php.ini

After setting up, I got the following lines to follow in the logs:
[23-Feb-2024 22:00:59] NOTICE: fpm is running, pid 839
[23-Feb-2024 22:00:59] NOTICE: ready to handle connections
[23-Feb-2024 22:00:59] NOTICE: systemd monitor interval set to 10000ms

I am not sure whether I turned on the output_buffering but it set to  4096

Server Specifications:
8 Core CPU
32 GB of RAM

How do those changes affect the system???

Otherwise, I appreciate your support, thank you
En respuesta a Bruce Nelson

Re: CodeRunner Issues, Could it be Nginx???

de Richard Lobb -
Server tuning is a black art, and I don't have much experience with nginx servers. So I'm really not prepared to offer advice on your settings, except to comment that yes, it certainly looks to me that pm.max_children should be higher than 5. I see the tech staff have set it to 50 on our departmental server (8 core, 16 GB) but I'm not sure whether that's a well-calculated load-tested number or just a hack by someone.

I am however curious as to why you're using nginx? Moodle servers usually run Apache and after our own departmental experiences setting up a Moodle server on nginx, I'm wondering why people don't just stick with Apache!