WeBWorK Main Forum

Where is Mathjax.js ?

Where is Mathjax.js ?

by Lars Jensen -
Number of replies: 26
Hi,

We're installing Webwork on a new test server and MathJax is not working. Images works fine. I noticed that the MathJax script MathJax.js is not present in /opt/webwork/MathJax - I figure this has to be the problem. Are there changes to the setup of Mathjax in webwork 2.15?

Thanks,
Lars.
In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Danny Glin -
Is there anything in that directory? If not, then it's likely that MathJax hasn't been downloaded.

If that is the case, then you can get MathJax as follows:
cd /opt/webwork
git clone https://github.com/mathjax/MathJax.git

If there is some stuff in /opt/webwork/MathJax but not everything, then you can try blowing it away and re-downloading it using the above commands.
In reply to Danny Glin

Re: Where is Mathjax.js ?

by Lars Jensen -
Hi Danny,

As you can see here: https://github.com/mathjax/MathJax there's no MathJax.js in the distribution. The files you see is exactly what I get with git.

After upgrade, many course pages give me utf8 errors, like:

Warning messages

  • Non-fatal warning: file /opt/webwork/courses/m126_jensen/course.conf contains at least one character code which is not valid in UTF-8. (The copyright sign is often a culprit -- use '©' instead.)
  • While this is not fatal you should fix it
Is there an easy fix?

Thanks,
Lars.
In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Glenn Rice -
You need to edit course.conf and change the invalid UTF-8 form of the copyright symbol to '©' as the message says. That is not related to MathJax at all, but is due to WeBWorK changes in version 2.15 to use multibyte characters.
In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Glenn Rice -
You also need to make sure that you are on the legacy-v2 branch of MathJax. WeBWorK no longer works with the master branch. So once you clone MathJax using the command that Danny gave, then run "git checkout legacy-v2". This is now needed for all versions of WeBWorK.

We have an issue to upgrade WeBWorK to use the newer version of MathJax. See https://github.com/openwebwork/webwork2/issues/1013
In reply to Glenn Rice

Re: Where is Mathjax.js ?

by Lars Jensen -
Hi Glen,

Thanks! This fixed both of my issues.

Lars.
In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Lars Jensen -

....well, not quite....

mathjax is still acting up. I can only see math rendered with mathjax in the Library Browser. Once I view a published set, or look at it in the editor, mathjax is not rendering the math expressions.

Any ideas?

Thanks,
lars.
In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Glenn Rice -
I am not sure what else could be going wrong.

Are you getting any errors when the page loads? What does your browser's javascript console show? To open the console hit F12 and select Console in the top of the side or bottom bar for Chrome or Firefox. Look in the menus for the console for Safari (I am not sure where).
In reply to Glenn Rice

Re: Where is Mathjax.js ?

by Lars Jensen -
Hi Glenn,

Thanks! The error in the console says:

Failed to load resource: the /webwork2_files/mathjax/es5/tex-mml-chtml.js:1

server responded with a status of 404 (Not Found)

The es5 directory is in the MathJax directory after getting it with git clone, but it disappears after I do git checkout legacy-v2 on the directory.

Lars
In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Glenn Rice -
"es5/tex-mml-chtml.js" is not part of MathJax version 2, and so will disappear when you switch to the legacy-v2 branch. It isn't needed and Webwork does not use the file.

You haven't changed the variable $webworkURLs{MathJax} in your localOverrides.conf file to point to that file instead have you? I don't know why you would, but just checking possibilities.

You didn't by chance look through the forks of webwork on github and switch to one of those (like the update-mathjax branch in my fork) that switches to MathJax version 3? This is even less likely.

This may be some odd issue that clearing the browser cache may resolve.

I am just fishing here. I am not sure what has happened on your system.


In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Danny Glin -
Have you restarted apache since you checked out MathJax v2? It's possible that some of the apache processes still have MathJax v3 loaded.
In reply to Lars Jensen

Re: Where is Mathjax.js ?

by Glenn Rice -
I thought about this some more, and I think my first idea that you must have changed the value of $webworkURLs{MathJax} in the localOverrides.conf file is probably correct. Check that file and make sure that the value is

$webworkURLs{MathJax} = "$webworkURLs{htdocs}/mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML-full";

That should be around line 240 of the file /opt/webwork/webwork2/conf/localOverrides.conf.

Make sure to restart apache2 after changing that line back to make the setting take effect.

After looking at the webwork2 code I realized that the library browser does not use that variable. It instead uses a hardcoded value (although it probably shouldn't). However, the rest of the code does use the value. So that is why the problems in the library work, but the rest don't. Since your javascript console is showing that the webwork page is requesting the file /webwork2_files/mathjax/es5/tex-mml-chtml.js you must have at some point changed the variable to use that file instead.
In reply to Glenn Rice

Re: Where is Mathjax.js ?

by Lars Jensen -
Hi Glenn,

Thank you so much. You were absolutely right. I had forgotten that had changed the line in localOverrides pointing to MathJax in an attempt to make things work, and I had left the line changed after I went to the legacy-v2 branch of MathJax. Everything is good after I changed that line back to its default form.

Lars.
In reply to Glenn Rice

Re: Where is Mathjax.js ?

by Nicholas Jacob -

I am working on a new WW server and have gotten so far along but seem to have hit this same road block.  I followed the instructions here and have the legacy version of MathJax running.  I am getting a different error though, a mixed content error...

Blocked loading mixed active content “http://156.110.194.114:8080/webwork2_files/mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML-full

Chrome and Safari won't load any equations but Firefox will let you load images but not MathJax.

I cannot seem to find anybody else having my mixed content issues...

TIA

In reply to Nicholas Jacob

Re: Where is Mathjax.js ?

by Nicholas Jacob -
And of course I figured it out moments later!

https://webwork.maa.org/wiki/Installing_from_WW2.15_Ubuntu20.04_Server_Virtual_Machine_Image#Trouble_with_SSL_certificates

Fail at using the forums!
In reply to Nicholas Jacob

Re: Where is Mathjax.js ?

by Thomas Mullaly -
I'm having the same issue but I'm going through a reverse proxy.

Mixed Content: The page at 'https://webwork2.math.school.edu/webwork2/f21-Math_2-section_03/instructor/setmaker/' was loaded over HTTPS, but requested an insecure stylesheet 'http://192.168.104.40/webwork2_files/js/vendor/bootstrap/css/bootstrap-responsive.css'. This request has been blocked; the content must be served over HTTPS.

I requested a valid certificate but even when it gets issued, it's using the ip address of the webserver and not web url

In site.conf, the $server_root_url is the ip address now, if I change it to the dns name then I get :

183 setmaker.js: /webwork2/instructorXMLHandler: Forbidden

thoughts?

-tom
In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Thomas Mullaly -
So I fixed the name resolving error by adding the web url to the local hosts file. The proxy gets the dns name.

Now I'm back to the mixed content error:

Mixed Content: The page at 'https://webwork2.math.school.edu/webwork2/f21-Math_2-section_03/instructor/setmaker/' was loaded over HTTPS, but requested an insecure stylesheet 'http://webwork2.math.school.edu/webwork2_files/js/vendor/bootstrap/css/bootstrap.css'. This request has been blocked; the content must be served over HTTPS.

I don't see any errors in the webwork apache logs, what is blocking the request?
In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Danny Glin -

Mixed content errors are usually on the client side.  The web server has no issue with serving some pages over https and others over http.  In fact, apache isn't even aware that the css file being requested is associated with a particular webpage, so it's most likely the browser that is blocking the request.

Do you have $server_root_url as https?  The URLs to auxiliary files in WeBWorK are created based on that variable, so if that does not have https, then you will see URLs like the one you see for bootstrap.css (i.e. with http:// rather than https://).  This should lead to all URLs starting with https, and browsers being happy.

In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Arnold Pizer -

In general, you should grep through the .conf files, especially localOverrides.conf, and search for any occurrences of "http" and change to https if necessary.

In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Thomas Mullaly -
Thanks for your quick answers.

My reverse proxy is adding the extra complication. When I configure the $server_root_url in site.conf to be the fqdn over https everything works except when I go to Instructor Tools -> Library Browser. The Subject pull down works but then the Chapter pull down gives the "183 setmaker.js: /webwork2/instructorXMLHandler: Forbidden" error.

this is the proxy logs:

158.121.104.40 - - [26/Oct/2021:09:40:34 -0400] "POST /mod_xmlrpc HTTP/1.1" 404 153 "-" "SOAP::Lite/Perl/1.27"
158.121.33.14 - - [26/Oct/2021:09:40:34 -0400] "POST /webwork2/instructorXMLHandler HTTP/1.1" 403 1826 "https://webwork2.math.umb.edu/webwork2/f21-Math_242-section_03/instructor/setmaker/?effectiveUser=tom.mullaly" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30"

and then on the webwork server logs:
158.121.106.227 - - [26/Oct/2021:09:40:34 -0400] "POST /webwork2/instructorXMLHandler HTTP/1.1" 403 5208 "https://webwork2.math.umb.edu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30"


158.121.104.40 is the webwork server
158.121.33.14 is my client browser
158.121.106.227 is the proxy server

thoughts?
-tom
In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Arnold Pizer -

This is a common and tricky problem.   It's a long shot but you could try 

$server_root_url   = 'https://localhost'

See e.g.

https://webwork.maa.org/wiki/WeBWorK_2.16_Ubuntu_Server_20.04_LTS_Virtual_Machine_Image#Edit_the_site.conf_file 

In reply to Arnold Pizer

Re: Where is Mathjax.js ?

by Thomas Mullaly -
using localhost gives me these errors in the browser:

about:srcdoc:9

GET http://localhost/webwork2_files/js/vendor/bootstrap/css/bootstrap.css net::ERR_EMPTY_RESPONSE
In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Arnold Pizer -
It was a longshot but why is the error showing http and not https?
In reply to Arnold Pizer

Re: Where is Mathjax.js ?

by Thomas Mullaly -
The webwork server is only listening on 80, the proxy listens on both 80 and 443 but only connects to 80 on webwork
In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Danny Glin -

One thing that seems odd is that on the proxy server the log lists the full path as the referrer, whereas the webwork server just lists the root url of the server (assuming that these are both using the default apache log format).  This may be a setting on the proxy server, and I don't know if it affects the behaviour.

Do you see anything in either the browser error console or the apache error log when you get the "forbidden" error?

Looking at old forum posts, it looks like there are sometimes issues with having $server_root_url in double quotes rather than single quotes, so that's something else to check.

Was the Library Browser working properly before you set up the proxy?

In reply to Danny Glin

Re: Where is Mathjax.js ?

by Thomas Mullaly -
Yes, it was. I added the valid certificate to the web proxy and configured the webwork server $server_root_url to be https://webwork2.math.umb.edu

I'm getting the same 183 setmaker.js: /webwork2/instructorXMLHandler: Forbidden error

On the webwork server here is the access and error.log:

==> /var/log/apache2/access.log <==
158.121.106.227 - - [27/Oct/2021:09:11:10 -0400] "GET /webwork2/f21-Math_242-section_03/instructor/setmaker/?effectiveUser=tom.mullaly HTTP/1.1" 200 5427 "https://webwork2.math.umb.edu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30"
158.121.106.227 - - [27/Oct/2021:09:11:10 -0400] "GET /webwork2_files/node_modules/iframe-resizer/js/iframeResizer.map HTTP/1.1" 200 19375 "https://webwork2.math.umb.edu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30"

==> /var/log/apache2/error.log <==
There were a lot of errors
Errors:
404 Not Found at /opt/webwork/webwork2/lib/WebworkClient.pm line 301.

End Errors
xmlrpcCall to searchLib returned no result for
[Wed Oct 27 09:11:13.426988 2021] [perl:error] [pid 182962] [client 158.121.106.227:53886] [5cb15bc7-d42b-5be7-bb5c-ee249e546918::5c597db1-3727-11ec-ab69-d5d9f98114fc] [/webwork2/instructorXMLHandler] {"Time":"Wed Oct 27 09:11:13 2021","Error record identifier":"5cb15bc7-d42b-5be7-bb5c-ee249e546918::5c597db1-3727-11ec-ab69-d5d9f98114fc","Warnings":[],"HTTP Headers":{"Accept":"*/*","Accept-Language":"en-US,en;q=0.9","sec-ch-ua":"Microsoft Edge;v=95, Chromium;v=95, ;Not A Brand;v=99","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30","Cookie":"WeBWorKCourseAuthen.f21-Math_242-section_03=tom.mullaly%09wsiJL85VdlybXC0iurvmPgG6ZMAmPdyY%091635340270","Host":"webwork2.math.umb.edu","sec-ch-ua-platform":"\\"Windows\\"","Origin":"https://webwork2.math.umb.edu","Sec-Fetch-Dest":"empty","X-Real-IP":"158.121.33.14","Referer":"https://webwork2.math.umb.edu","Sec-Fetch-Site":"same-origin","Sec-Fetch-Mode":"cors","Accept-Encoding":"gzip, deflate, br","sec-ch-ua-mobile":"?0","Connection":"close","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8","Content-Length":"240","X-Requested-With":"XMLHttpRequest"},"Method":"POST","URI":"/webwork2/instructorXMLHandler"} xmlrpcCall to searchLib returned no result for \n * in WeBWorK::ContentGenerator::instructorXMLHandler::content called at line 232 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm\n * in WeBWorK::ContentGenerator::go called at line 386 of /opt/webwork/webwork2/lib/WeBWorK.pm, referer: https://webwork2.math.umb.edu

==> /var/log/apache2/access.log <==
158.121.106.227 - - [27/Oct/2021:09:11:13 -0400] "POST /webwork2/instructorXMLHandler HTTP/1.1" 403 5002 "https://webwork2.math.umb.edu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30"
In reply to Thomas Mullaly

Re: Where is Mathjax.js ?

by Thomas Mullaly -
I got it working.

I added the real certificate to both the proxy and the webwork server.
webwork2.math.umb.edu is a cname that points to the proxy so I added a local webwork2.math.umb.edu on the webwork server in /etc/hosts so it can call itself without going through the proxy, using the routable address (not localhost, although that might work.)
I changed $server_root_url in site.conf to be https://webwork2.math.umb.edu

Voila