'localhost' in theme /css urls

'localhost' in theme /css urls

by Jelle Boomstra -
Number of replies: 4
Hi forum,

The moodle installation I use is installed with a debian package, and I encountered some unexpected problems.

The problem i could fix myself was a restriction in /etc/apache/conf.d/moodle that caused connections other than localhost to be denied.
the second might be related to that, but I have not found the cause yet. All pictures and css are referenced to localhost, not the hostname the site should be/is serving from. so I can get text pages, but no pictures or pretty display.
Any ideas how this happened and how i should rectify it?

And to answer myself:
wwwroot is set to localhost. Duh!
sorry to have bothered you.

(yes I might look into the debian installation routine, I cannot remember any questions if i only wanted to use moodle locally. I would expect a service to work out of the box if possible.)

Average of ratings: -
In reply to Jelle Boomstra

Re: 'localhost' in theme /css urls

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
This would definitely be a Debian issue, not a Moodle issue.  Moodle's install script clearly asks you what you want for wwwroot.
In reply to Martin Dougiamas

Re: 'localhost' in theme /css urls

by Jelle Boomstra -
it is. postinst (the script that is run after installing the files in the package) links an unaltered config file into apache/conf.d/moodle and writes the config.php file Both files contain references to localhost instead of using the hostname or asking for it.
A quick workaround would be to mention this at the end of the debconf part, like there is now a warning that you have to go to /admin to have all tables created.

I have not foud the bug yet that gave me a bumby ride when inmstalling on/with pgsql.

If somebody feels the need to report this bug to debian: go ahead, I got something else to do tonight wink
In reply to Jelle Boomstra

Re: 'localhost' in theme /css urls

by Isaac Clerencia -
Hi, I'm Isaac, the packager for Moodle in Debian.

Every Debian package has documentation in /usr/share/doc/. You can read about your problem (the one you fixed about Moodle being accesible only from localhost) in /usr/share/doc/moodle/README.Debian.

The Debian package for Moodle works out of the box, but it's dangerous to allow remote access to moodle before it's completely configured. So you must enable it explicitly.

About the other problem, you just have to change the wwwroot variable from:
$CFG->wwwroot = 'http://localhost/moodle';

to something like:
$CFG->wwwroot = 'http://yourdomain.com/moodle';

Best regards
In reply to Isaac Clerencia

Re: 'localhost' in theme /css urls

by Jelle Boomstra -
Thank You Isaac for your reply,

Why would it be so dangerous to have moodle accesible from the outside? Moodle's own installation script does it, noumerous other debian packages do something similar. I don't see a reason to be holier than the pope.

If you insist on it, please add a mention of it in the configuration dialog. There is a warning there to run moodle/admin, but nothing about changing wwwroot or restricting acces to localhost.

If there was a configuration item for wwwroot and acces rights, the default could still be localhost, which would have the same default security, but have the added convenience that you don't have to go hunting these errors five minutes after you have anounced your site to the world.