Installation

Proxy webwork2 through apache2

Proxy webwork2 through apache2

by Joseph Maher -
Number of replies: 9

I'm currently having some problems using apache2 as a proxy for webwork2.  This is my current apache2 proxy config:

<Location /webwork2/>
  ProxyPass http://10.8.0.14:80/webwork2/
  ProxyPassReverse http://10.8.0.14:80/webwork2/
</Location>

<Location /webwork2_files>
  ProxyPass http://10.8.0.14:80/webwork2_files/
  ProxyPassReverse http://10.8.0.14:80/webwork2_files/
</Location>

<Location /webwork2_course_files>
  ProxyPass http://10.8.0.14:80/webwork2_course_files/
  ProxyPassReverse http://10.8.0.14:80/webwork2_course_files/
</Location>

<Location /webwork2_rpc>
  ProxyPass http://10.8.0.14:80/webwork2_rpc/
  ProxyPassReverse http://10.8.0.14:80/webwork2_rpc/
</Location>

<Location /pg_files>
  ProxyPass http://10.8.0.14:80/pg_files/
  ProxyPassReverse http://10.8.0.14:80/pg_files/
</Location>

Is there an easier way of doing this?  Am I missing anything obvious?


Joseph
In reply to Joseph Maher

Re: Proxy webwork2 through apache2

by Danny Glin -
Can you please provide some more detail on exactly what you are trying to do, and what you're seeing?

I'm assuming that this is a separate apache server in front of your WeBWorK server.  When you visit those addresses what do you see?
In reply to Danny Glin

Re: Proxy webwork2 through apache2

by Joseph Maher -

Setup:  there is a webserver with a public ip and domain name running apache2 ssl, providing a proxy for a machine running the webwork2 installation over an openvpn connection.  I think I'm having a similar problem to this post:

  https://webwork.maa.org/moodle/mod/forum/discuss.php?d=8133#p19727


If I set $server_root_url to the domain name, the problems do not appear in the library browser, I get the webwork2/html2xml: JSON.parse: unexpected character at line 1 column 1 of the JSON data 


If I set $server_root_url to localhost, then the problems appear, but the MathJax does not appear.

Using https instead of http on the webwork2 host doesn't make any difference in these two cases.


What works:  setting $server_root_url to localhost and hard coding the external url ($SITE_URL) in

 /opt/webwork/webwork2/lib/WebworkClient/simple_format.pl



In reply to Joseph Maher

Re: Proxy webwork2 through apache2

by Glenn Rice -

Instead of hard coding the external URL in simple_format.pl, try removing the "base href" line from that file entirely.  Let me know if that works.

In reply to Glenn Rice

Re: Proxy webwork2 through apache2

by Glenn Rice -
Actually, looking at the proxy settings that you posted, it seems that you should have $server_root_url='http://10.8.0.14:80' in site.conf. Not localhost or the external address.
In reply to Glenn Rice

Re: Proxy webwork2 through apache2

by Joseph Maher -

With $server_root_url='http://10.8.0.14:80' I still get the MathJax not displaying in the library browser, but everything works with the base href line removed from  /opt/webwork/webwork2/lib/WebworkClient/simple_format.pl


Thanks a lot!

In reply to Joseph Maher

Re: Proxy webwork2 through apache2

by Danny Glin -

In my proxy configuration I have $server_root_url set to the public address and everything is working.

It seems to me that setting $server_root_url to the private address is the wrong thing to do for a couple of reasons:

  1. WeBWorK crafts some URLs based on that variable, and these will be inaccessible from outside of the local network, which is likely what you're seeing with MathJax in the library browser.
  2. If your proxy server has SSL enabled, and you set $server_root_url to something without SSL, then any URLs crafted for auxiliary files (e.g. the MathJax js files) will likely not be loaded by modern browsers, since they don't like mixed https and http content.

Most likely there is something going on with your proxy server settings that are preventing things from working with $server_root_url set to the address of the proxy server.

Is there a reason that you don't want to proxy all addresses on the public address to your WeBWorK server?  i.e. have you tried

<Location />
  ProxyPass http://10.8.0.14:80/
  ProxyPassReverse http://10.8.0.14:80/
</Location>

In reply to Danny Glin

Re: Proxy webwork2 through apache2

by Joseph Maher -

We don't want to proxy all the addresses to the webwork2 machine as the proxy machine also hosts a bunch of other websites and proxies...

Even with the the base href line removed I get the "webwork2/html2xml: JSON.parse: unexpected character at line 1 column 1 of the JSON data" error with $server_root_url set to the public proxy url..

In reply to Joseph Maher

Re: Proxy webwork2 through apache2

by Danny Glin -
Fair enough.

Is there anything in the browser's js error console when you get the JSON.parse error?
In reply to Danny Glin

Re: Proxy webwork2 through apache2

by Joseph Maher -

Yes, there are some errors:


Cookie “WeBWorKCourseAuthen.test” has been rejected for invalid domain.        setmaker


TypeError: u.app is undefined        content_script_bundle.js:122:360


 - both of these errors show up when the page works

- we're using keys not cookies