Skip to content

Album Art on your LAN

jonathanmt edited this page Oct 30, 2012 · 8 revisions

How to configure your server to serve your album art

MPDroid supports loading album cover artwork from your music directory across your local network. In order to do this, you need to install a webserver on the box running MPD, and configure it to serve files from your music directory.

For nginx, we also add a rule to only serve to IP addresses on your local network to keep this secure.

MPDroid Setup

The following web server configs are written with an example MPD music_directory setting of "/home/mafrosis/MP3/", and a rewrite with the MPD server running at 192.168.1.102 on your LAN.

MPDroid settings

You don't need to specify IP addresses or domain names here - this is worked out from the MPD config.

Path to music is the part of the URL after the domain, where you're serving images from your music collection. It's there so you don't have to serve your cover images at root on your webserver.

The nginx config below demonstrates rewriting the path to /cover-art. In this case, the 'path to music' setting would be "cover-art".

Cover filename is the standardised name for album art throughout your collection. Using local artwork will happen if you have a convention for naming in your MP3 collection!

Webserver Setup

Using nginx

$ sudo aptitude install nginx

Existing nginx install

If you already have nginx configured on your server, you should only merge the location block from below into your existing server config and restart nginx.

New nginx install

For a new nginx install, copy the below into a new file at /etc/nginx/sites-available/mpd-cover-art.conf:

server {
    listen 80;
    server_name 192.168.1.102;

    location /cover-art/ {
        root /home/mafrosis/MP3/;
        rewrite /cover-art/(.*) /$1 break;
        try_files $uri $uri;
        allow   192.168.1.0/24;
        deny    all;
    }
}

Now run the following commands to get nginx to pick up the new config:

$ sudo rm /etc/nginx/sites-enabled/mpd-cover-art.conf
$ sudo ln -s /etc/nginx/sites-available/mpd-cover-art.conf /etc/nginx/sites-enabled/
$ sudo /etc/init.d/nginx restart

Using lighttpd

$ sudo aptitude install lighttpd

New lighttpd install

For a new lighttpd install, copy the below into a new file at /etc/lighttpd/lighttpd.conf:

server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/home/mafrosis/MP3/"
server.errorlog = "/var/log/lighttpd/error.log"
mimetype.assign = ( ".jpg" => "image/jpeg" )
You can’t perform that action at this time.