Reverse proxy for Logitech Media Server
Posted: 15 Dec 2015, 09:46
Let me start by saying that this had me stumped for quite a while. Years in fact. The theory is simple: you tell apache to proxy '/lms' or whatever base name you want to give it to http://localhost:9000 and you're done. Alas that doesn't work and although it does show you some of the content of the LMS web UI it's mostly an empty page with nothing to click on.
The cause of this is that apache is unable to add your chosen prefix to each and every reference that the page makes to (mostly) static content like stylesheets, images and java include scripts. As a result your browser will request those files to be served from your regular webroot where of course these files do not exist.
The answer is: you need to create a separate vhost. One where you can proxy '/' in stead of needing to proxy '/app' and thus do not need to translate any included links.
The virtual host definition is quite simple:
if you're running apache 2.3 or higher, the 'Proxy' part should read like this:
Next you need to make sure that http://squeezebox resolves to your b3 address. To do that open /etc/hosts in your editor and add the name squeezebox (preferably with its full domain name - if you didn't set any just leave it) to the end of the line that holds your B3's address and name. e.g.:
Next reload apache and restart dnsmasq
Now you can point your browser to http://squeezebox and forget about that crazy number behind the colon.
Note: be aware that apache will take your first vhost definition (the one in the file that is on top when sorted by name) as your default host. Any request to the server that does not match a vhost's ServerName or ServerAlias directive will be served by the default host.
The cause of this is that apache is unable to add your chosen prefix to each and every reference that the page makes to (mostly) static content like stylesheets, images and java include scripts. As a result your browser will request those files to be served from your regular webroot where of course these files do not exist.
The answer is: you need to create a separate vhost. One where you can proxy '/' in stead of needing to proxy '/app' and thus do not need to translate any included links.
The virtual host definition is quite simple:
Code: Select all
<VirtualHost *:80>
ServerName squeezebox
ServerAlias squeezebox.localdomain
DocumentRoot /home/www
ErrorLog logs/squeezebox_log
CustomLog logs/squeezebox-access_log common
<Proxy *>
Order deny,allow
Deny from all
Deny from 192.168.10.1
Allow from 192.168.10.0/24
</Proxy>
ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://localhost:9000/
ProxyPassReverse / http://localhost:9000/
</VirtualHost>
Code: Select all
<Proxy *>
<RequireAll>
Require not ip 192.168.10.1
Require ip 192.168.10.0/24
</RequireAll>
</Proxy>
Code: Select all
192.168.10.1 b3 b3.localdomain squeezebox.localdomain
Code: Select all
/etc/init.d/apache2 reload
/etc/init.d/dnsmasq restart
Note: be aware that apache will take your first vhost definition (the one in the file that is on top when sorted by name) as your default host. Any request to the server that does not match a vhost's ServerName or ServerAlias directive will be served by the default host.