<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

ChangeDocumentRoot

From SqueezeboxWiki

Revision as of 01:28, 5 July 2010 by Soulkeeper (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To change the document root of the HTTP service (ie. make it appear somewhere other than http://server:9000/ - perhaps http://server:9000/slim/), try this:

Cheesy 'editing the source way'

Edit /usr/local/slimserver/Slim/Web/HTTP.pm, and head to line 424, in the processHTTP subroutine, where you should find something like:

if ($path) {
    $params->{'webroot'} = '/';
    if ($path =~ s{^/slimserver/}{/}i) {
        $params->{'webroot'} = "/slimserver/"
    }
    ...
}


The wrong way

...and change $params->{'webroot'} = '/'; to what ever you want, eg:

$params->{'webroot'} = '/slim/';

then restart Slimserver. And, all of a sudden the document root is http://server:9000/slim/ instead of http://server:9000/.

Note! The previous does not work, attempting to connect to http://server:9000/slim/ will result in a 404 as it will attempt to use the "slim" skin, which doesn't exist.

Unchanged, you can connect to either http://server:9000/ or http://server:9000/slimserver/. The reason that /slimserver/ works as a document root is the $path substitution in the above code. Replacing the slimserver in both the substitution and the assignment with your desired document root would be the correct way to change the code. However, you cannot use html, music, plugins, or any of the skins as your new root and expect everything to work correctly.

The proper way

Not sure about this - I couldn't figure it out, nor could I immediately find where the %params array was populated - I'm assuming via config or command line or something, but I wasn't sure (I tried adding "webroot=/slim/" to the config, but it dodn't seem to work).


First ask yourself why you need to do this. Then ask yourself if using /slimserver/ as the document root is acceptable. If you must have something other than slimserver as the document root, the only way to do it is by making the change above.

Related question; any suggestions or instructions on how to have the SlimServer interface be accessible at http://server/slimserver instead of http://server:9000? I am guessing this will involve routing slimserver through the webserver running on port 80 (Apache2, in my case); I am currently looking into this, but know little about such things, so thought someone else might have an idea. Reason I'd like to do this: some firewalls are set to block all webserver ports other than 80, so that http://server:9000 wouldn't be accessible.


Not sure what the proper wiki-etiquette for answering this is so i'll just paste it in here.

The way to do this with apache2 is via apache's proxy mechanism. Something like this should work (slightly modified from the apache docs:

ProxyRequests Off
<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>
ProxyPass /slimserver http://foo.example.com:9000/
ProxyPassReverse /slimserver http://foo.example.com:9000/

I've always found the documentation clear as mud regarding why you need [=ProxyPass] and [=ProxyPassReverse] but you probably need them both.

You need to make sure that mod_proxy is loaded, which it probably is by default but if you've removed modules then you'll need to re-enable it. - DanPritts