Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-26705

File Picker reports JSON error when moodle is on a reverse proxy.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.2
    • Fix Version/s: None
    • Component/s: Files API
    • Labels:
    • Environment:
      Ubuntu Server 10.10, Apache 2.2.16, PHP 5.3.4, Mod_Proxy
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      When accessing Moodle through the reverse proxy http://domainname/moodle the File Picker is completely unusable. All of the repository plugins give a JSON error similar to

      ERROR: Invalid JSON string

      {"nologin":true,"nosearch":true,"norefresh":true,"list":[],"dynload":false,"upload":

      {"label":"Attachment","id":"repo-form"}

      ,"repo_id":3}

      When bypassing the reverse proxy config and changing the CFG->wwwroot string to point to the ip address http://x.x.x.x/moodle and accessing moodle directly then the File Picker works.

        Gliffy Diagrams

          Activity

          Hide
          skodak Petr Skoda added a comment -

          Moodle can work one address only, if you want to use reverse proxy you must add following to your config.php:

          $CFG->reverseproxy = true;

          Unfortunately I do not have any reverse proxy test setup to verify it works properly.

          Show
          skodak Petr Skoda added a comment - Moodle can work one address only, if you want to use reverse proxy you must add following to your config.php: $CFG->reverseproxy = true; Unfortunately I do not have any reverse proxy test setup to verify it works properly.
          Hide
          mralan Alan Tomlinson added a comment -

          $CFG->reverseproxy = true; does not work for me. Strangly when set to true I get the message:
          Reverse proxy enabled, server can not be accessed directly, sorry.

          Which is wrong because I am not accessing it directly.

          Moodles local name is: moodle.local/moodle
          The external address is: www.domain.com/moodle

          in which 'www.domain.com' is a separate server configured with mod_proxy as follows:

          ProxyPass /moodle http://moodle.local/moodle
          ProxyPassReverse /moodle http://moodle.local/moodle

          So in my moodle config on moodle.local
          $CFG->wwwroot = 'http://www.domain.com/moodle';

          When is set to true $CFG->reverseproxy = true; and I browse to http://www.domain.com/moodle I get the error: Reverse proxy enabled, server can not be accessed directly, sorry.

          When $CFG->reverseproxy = false; then http://www.domain.com/moodle works but the File Picker reports a JSON error.

          and as I described in my original post that if I changed the $CFG->wwwroot = 'http://moodle.local/moodle' and then accessed it internally the JSON error goes away but then I'm left with a configuration that I can't access externally.

          I have upgraded from version 1.9.11 if that makes any difference?

          Show
          mralan Alan Tomlinson added a comment - $CFG->reverseproxy = true; does not work for me. Strangly when set to true I get the message: Reverse proxy enabled, server can not be accessed directly, sorry. Which is wrong because I am not accessing it directly. Moodles local name is: moodle.local/moodle The external address is: www.domain.com/moodle in which 'www.domain.com' is a separate server configured with mod_proxy as follows: ProxyPass /moodle http://moodle.local/moodle ProxyPassReverse /moodle http://moodle.local/moodle So in my moodle config on moodle.local $CFG->wwwroot = 'http://www.domain.com/moodle'; When is set to true $CFG->reverseproxy = true; and I browse to http://www.domain.com/moodle I get the error: Reverse proxy enabled, server can not be accessed directly, sorry. When $CFG->reverseproxy = false; then http://www.domain.com/moodle works but the File Picker reports a JSON error. and as I described in my original post that if I changed the $CFG->wwwroot = 'http://moodle.local/moodle' and then accessed it internally the JSON error goes away but then I'm left with a configuration that I can't access externally. I have upgraded from version 1.9.11 if that makes any difference?
          Hide
          skodak Petr Skoda added a comment -

          1/ You can have only one address in $CFG->wwwroot - it can not change on the fly, that means you have to use the same URL when accessing it from internal and external networks - I suppose you have it configured correctly.

          2/ The $CFG->reverseproxy is used only when all traffic is going through the reverse proxy for load balancing purposes - I thought you are having a different set-up.

          I am afraid no developer tested this set up yet in 2.0, the best tool for diagnostics of these problem is Firebug extension for Firefox, sometimes it is necessary to use packet inspection tools such as wireshark and check what is going into and from the proxy server.

          I am sorry I can not help you if I can not reproduce the problem on my test servers. Thanks for the report.

          Show
          skodak Petr Skoda added a comment - 1/ You can have only one address in $CFG->wwwroot - it can not change on the fly, that means you have to use the same URL when accessing it from internal and external networks - I suppose you have it configured correctly. 2/ The $CFG->reverseproxy is used only when all traffic is going through the reverse proxy for load balancing purposes - I thought you are having a different set-up. I am afraid no developer tested this set up yet in 2.0, the best tool for diagnostics of these problem is Firebug extension for Firefox, sometimes it is necessary to use packet inspection tools such as wireshark and check what is going into and from the proxy server. I am sorry I can not help you if I can not reproduce the problem on my test servers. Thanks for the report.
          Hide
          skodak Petr Skoda added a comment -

          I might be able to find out what is wrong if you send me content of $_SERVER variable when accessing your server from internal and external network.

          Show
          skodak Petr Skoda added a comment - I might be able to find out what is wrong if you send me content of $_SERVER variable when accessing your server from internal and external network.
          Hide
          mralan Alan Tomlinson added a comment - - edited

          Thanks Petr,
          I only changed the $CFG->wwwroot variable for testing purposes. In our production environment it always points to 'http://www.northcote.school.nz/moodle' for both internal and external networks.

          I'll investiage further with Firebug and Wireshark to see what I can find.

          Here is my $_SERVER variables (I have removed some that I didn't think were relevant to shorten the post):
          Accessing http://www.northcote.school.nz/moodle/phpinfo.php from outside the network :
          _SERVER["HTTP_HOST"] www.northcote.school.nz
          _SERVER["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
          _SERVER["HTTP_ACCEPT_CHARSET"] ISO-8859-1,utf-8;q=0.7,*;q=0.7
          _SERVER["HTTP_X_FORWARDED_FOR"] 119.215.63.146
          _SERVER["HTTP_X_FORWARDED_HOST"] www.northcote.school.nz
          _SERVER["HTTP_X_FORWARDED_SERVER"] www.northcote.school.nz
          _SERVER["PATH"] /usr/local/bin:/usr/bin:/bin
          _SERVER["SERVER_SIGNATURE"] <address>Apache/2.2.16 (Ubuntu) Server at www.northcote.school.nz Port 80</address>
          _SERVER["SERVER_SOFTWARE"] Apache/2.2.16 (Ubuntu)
          _SERVER["SERVER_NAME"] www.northcote.school.nz
          _SERVER["SERVER_ADDR"] 192.168.126.248
          _SERVER["SERVER_PORT"] 80
          _SERVER["REMOTE_ADDR"] 192.168.4.254
          _SERVER["DOCUMENT_ROOT"] /var/www/localhost/htdocs
          _SERVER["SCRIPT_FILENAME"] /var/www/localhost/htdocs/moodle/phpinfo.php
          _SERVER["REMOTE_PORT"] 59219

          Accessing http://www.northcote.school.nz/moodle/phpinfo.php from inside the network:
          _SERVER["HTTP_HOST"] www.northcote.school.nz
          _SERVER["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
          _SERVER["HTTP_X_FORWARDED_FOR"] 192.168.66.11
          _SERVER["HTTP_X_FORWARDED_HOST"] www.northcote.school.nz
          _SERVER["HTTP_X_FORWARDED_SERVER"] www.northcote.school.nz
          _SERVER["PATH"] /usr/local/bin:/usr/bin:/bin
          _SERVER["SERVER_SIGNATURE"] <address>Apache/2.2.16 (Ubuntu) Server at www.northcote.school.nz Port 80</address>
          _SERVER["SERVER_SOFTWARE"] Apache/2.2.16 (Ubuntu)
          _SERVER["SERVER_NAME"] www.northcote.school.nz
          _SERVER["SERVER_ADDR"] 192.168.126.248
          _SERVER["SERVER_PORT"] 80
          _SERVER["REMOTE_ADDR"] 192.168.4.254
          _SERVER["DOCUMENT_ROOT"] /var/www/localhost/htdocs
          _SERVER["SCRIPT_FILENAME"] /var/www/localhost/htdocs/moodle/phpinfo.php
          _SERVER["REMOTE_PORT"] 39487

          Accessing http://192.168.126.248/moodle/phpinfo.php
          _SERVER["HTTP_HOST"] 192.168.126.248
          _SERVER["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
          _SERVER["PATH"] /usr/local/bin:/usr/bin:/bin
          _SERVER["SERVER_SIGNATURE"] <address>Apache/2.2.16 (Ubuntu) Server at 192.168.126.248 Port 80</address>
          _SERVER["SERVER_SOFTWARE"] Apache/2.2.16 (Ubuntu)
          _SERVER["SERVER_NAME"] 192.168.126.248
          _SERVER["SERVER_ADDR"] 192.168.126.248
          _SERVER["SERVER_PORT"] 80
          _SERVER["REMOTE_ADDR"] 192.168.128.10
          _SERVER["DOCUMENT_ROOT"] /var/www/localhost/htdocs
          _SERVER["SCRIPT_FILENAME"] /var/www/localhost/htdocs/moodle/phpinfo.php
          _SERVER["REMOTE_PORT"] 58102

          Thanks.

          Show
          mralan Alan Tomlinson added a comment - - edited Thanks Petr, I only changed the $CFG->wwwroot variable for testing purposes. In our production environment it always points to 'http://www.northcote.school.nz/moodle' for both internal and external networks. I'll investiage further with Firebug and Wireshark to see what I can find. Here is my $_SERVER variables (I have removed some that I didn't think were relevant to shorten the post): Accessing http://www.northcote.school.nz/moodle/phpinfo.php from outside the network : _SERVER ["HTTP_HOST"] www.northcote.school.nz _SERVER ["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9, / ;q=0.8 _SERVER ["HTTP_ACCEPT_CHARSET"] ISO-8859-1,utf-8;q=0.7,*;q=0.7 _SERVER ["HTTP_X_FORWARDED_FOR"] 119.215.63.146 _SERVER ["HTTP_X_FORWARDED_HOST"] www.northcote.school.nz _SERVER ["HTTP_X_FORWARDED_SERVER"] www.northcote.school.nz _SERVER ["PATH"] /usr/local/bin:/usr/bin:/bin _SERVER ["SERVER_SIGNATURE"] <address>Apache/2.2.16 (Ubuntu) Server at www.northcote.school.nz Port 80</address> _SERVER ["SERVER_SOFTWARE"] Apache/2.2.16 (Ubuntu) _SERVER ["SERVER_NAME"] www.northcote.school.nz _SERVER ["SERVER_ADDR"] 192.168.126.248 _SERVER ["SERVER_PORT"] 80 _SERVER ["REMOTE_ADDR"] 192.168.4.254 _SERVER ["DOCUMENT_ROOT"] /var/www/localhost/htdocs _SERVER ["SCRIPT_FILENAME"] /var/www/localhost/htdocs/moodle/phpinfo.php _SERVER ["REMOTE_PORT"] 59219 Accessing http://www.northcote.school.nz/moodle/phpinfo.php from inside the network: _SERVER ["HTTP_HOST"] www.northcote.school.nz _SERVER ["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9, / ;q=0.8 _SERVER ["HTTP_X_FORWARDED_FOR"] 192.168.66.11 _SERVER ["HTTP_X_FORWARDED_HOST"] www.northcote.school.nz _SERVER ["HTTP_X_FORWARDED_SERVER"] www.northcote.school.nz _SERVER ["PATH"] /usr/local/bin:/usr/bin:/bin _SERVER ["SERVER_SIGNATURE"] <address>Apache/2.2.16 (Ubuntu) Server at www.northcote.school.nz Port 80</address> _SERVER ["SERVER_SOFTWARE"] Apache/2.2.16 (Ubuntu) _SERVER ["SERVER_NAME"] www.northcote.school.nz _SERVER ["SERVER_ADDR"] 192.168.126.248 _SERVER ["SERVER_PORT"] 80 _SERVER ["REMOTE_ADDR"] 192.168.4.254 _SERVER ["DOCUMENT_ROOT"] /var/www/localhost/htdocs _SERVER ["SCRIPT_FILENAME"] /var/www/localhost/htdocs/moodle/phpinfo.php _SERVER ["REMOTE_PORT"] 39487 Accessing http://192.168.126.248/moodle/phpinfo.php _SERVER ["HTTP_HOST"] 192.168.126.248 _SERVER ["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9, / ;q=0.8 _SERVER ["PATH"] /usr/local/bin:/usr/bin:/bin _SERVER ["SERVER_SIGNATURE"] <address>Apache/2.2.16 (Ubuntu) Server at 192.168.126.248 Port 80</address> _SERVER ["SERVER_SOFTWARE"] Apache/2.2.16 (Ubuntu) _SERVER ["SERVER_NAME"] 192.168.126.248 _SERVER ["SERVER_ADDR"] 192.168.126.248 _SERVER ["SERVER_PORT"] 80 _SERVER ["REMOTE_ADDR"] 192.168.128.10 _SERVER ["DOCUMENT_ROOT"] /var/www/localhost/htdocs _SERVER ["SCRIPT_FILENAME"] /var/www/localhost/htdocs/moodle/phpinfo.php _SERVER ["REMOTE_PORT"] 58102 Thanks.
          Hide
          jamessnell James Snell added a comment -

          I too have this problem. I can confirm that accessing the site from within my network works fine. But when connecting through a reverse proxy everything but the file picker works. I get the same error message.

          I don't have to change my CFG->wwwroot though.

          My reverse proxy is implemented with Apache2. I use it for many sites without problems. I must be missing something through as it's definitely happening at the reverse proxy. Any tips on how to learn more about the specific problem happening? I've tired Firefox'x FireBug addon, but I haven't observed any helpful info with that.

          Tips? Help?

          Show
          jamessnell James Snell added a comment - I too have this problem. I can confirm that accessing the site from within my network works fine. But when connecting through a reverse proxy everything but the file picker works. I get the same error message. I don't have to change my CFG->wwwroot though. My reverse proxy is implemented with Apache2. I use it for many sites without problems. I must be missing something through as it's definitely happening at the reverse proxy. Any tips on how to learn more about the specific problem happening? I've tired Firefox'x FireBug addon, but I haven't observed any helpful info with that. Tips? Help?
          Hide
          serendipitytech Troy Shimkus added a comment -

          We have our moodle behind an ISA, so that externally, the address is https:// while internally, it is http://
          This is causing the same JSON error on file picker use outside the network, reverse proxy doesn't really apply here I guess, trying it resulted in the server cannot be accessed directly error.
          This ISA setup was always a problem with moodle 1.9 as well in that assets uploaded outside the network didn't always display correctly when being accessed internally. An annoyance, but workable. Having 0 access is of course not good.
          Would appreciate any thoughts here... I have no control over the ISA, I'm an outside contracted helping the maintain a moodle installation.

          Show
          serendipitytech Troy Shimkus added a comment - We have our moodle behind an ISA, so that externally, the address is https:// while internally, it is http:// This is causing the same JSON error on file picker use outside the network, reverse proxy doesn't really apply here I guess, trying it resulted in the server cannot be accessed directly error. This ISA setup was always a problem with moodle 1.9 as well in that assets uploaded outside the network didn't always display correctly when being accessed internally. An annoyance, but workable. Having 0 access is of course not good. Would appreciate any thoughts here... I have no control over the ISA, I'm an outside contracted helping the maintain a moodle installation.
          Hide
          salvetore Michael de Raadt added a comment -

          Thanks for reporting this issue.

          We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported.

          If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

          Michael d.

          TW9vZGxlDQo=

          Show
          salvetore Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d. TW9vZGxlDQo=
          Hide
          salvetore Michael de Raadt added a comment -

          I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported.

          This is being done as part of a bulk annual clean-up of issues.

          If you still believe this is an issue in supported versions, please create a new issue.

          Show
          salvetore Michael de Raadt added a comment - I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported. This is being done as part of a bulk annual clean-up of issues. If you still believe this is an issue in supported versions, please create a new issue.

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: