1

I'm trying to set a moodle server up on an Ubuntu box, which already serves Plone & Trac via Apache.

In my Moodle config I have $CFG->wwwroot = 'http://www.server-name.org/moodle'

The (convoluted, but working) configuration below works fine for the first two, but when I visit www.server-name.com/moodle I get:

Incorrect access detected, this server may be accessed only through "http://xxx.xxx.xxx.xxx:8888/moodle" address, sorry

It then forwards to the IP address, where Moodle functions fine.

What am I missing to get the server name approach working correctly?


Apache Config follows:

LoadModule transform_module /usr/lib/apache2/modules/mod_transform.so
Listen 8080
Listen 8888

Include /etc/phpmyadmin/apache.conf

<VirtualHost xxx.xxx.xxx.xxx:8080>

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  ProxyPreserveHost On

  <Location />
    ProxyPass http://127.0.0.1:8082/
    ProxyPassReverse http://127.0.0.1:8082/
  </Location>

</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx:80>
  ServerName  www.server-name.org
  ServerAlias server-name.org

  ProxyRequests Off

  FilterDeclare MyStyle RESOURCE
  FilterProvider MyStyle XSLT resp=Content-Type $text/html
  TransformOptions +ApacheFS +HTML
  TransformCache /theme.xsl /home/web/webapps/plone/theme.xsl
  TransformSet /theme.xsl
  FilterChain MyStyle

  ProxyPass /issue-tracker !
  ProxyPass /moodle !  

  <Location /issue-tracker/login>

    AuthType Basic
    AuthName "Trac"
    AuthUserFile /home/web/webapps/plone/parts/trac/trac.htpasswd
    Require valid-user

  </Location>


  Alias /moodle /usr/share/moodle/

  <Directory /usr/share/moodle/>

    Options +FollowSymLinks
    AllowOverride None

    order allow,deny
    allow from all

    <IfModule mod_dir.c>
      DirectoryIndex index.php
    </IfModule>

  </Directory>

  </VirtualHost>
Jon Hadley
  • 305
  • 2
  • 7
  • 20
  • 1
    Can you post your whole apache config? I don't see anything moodle related. Also, why are you using mod_proxy? – Kyle Mar 25 '12 at 23:03
  • @Kyle the moodle related stuff is at the bottom. The mod_proxy usage is left over from a previous maintainer of the site - but I'm assuming to was the only way he found he cold serve multiple servers on the same IP. – Jon Hadley Mar 26 '12 at 09:19

1 Answers1

5

The problem lies in Moodle configuration, as the $CFG->wwwroot shouldn't be affected by the server at all.

Perhaps if you used a third party installation script, that variable was set again and/or in a different file. Try doing a grep search for http://xxx.xxx.xxx.xxx:8888/moodle in the moodle directories.

As a workaround, you could try using $CFG->wwwroot = 'http://'.$_SERVER["HTTP_HOST"];

Sašo
  • 1,494
  • 2
  • 10
  • 14
  • Along with a search replace of the database (see http://docs.moodle.org/22/en/Moodle_migration#Changed_URL_image_links_set_to_old_site), this worked a treat, thanks. – Jon Hadley Apr 24 '12 at 20:14