How to Install Subsonic Media Server on Ubuntu 16.04

This tutorial is going to show you how to install Subsonic media server on Ubuntu 16.04 and how to set up a reverse proxy for Subsonic using Nginx or Apache.

Subsonic is a free, web-based media streamer written in Java, available for Linux, MacOS and Windows. With Subsonic, you can stream your music from home computer or any public-facing computer and listen to your music from anywhere with a web browser. So you don’t have to sync your music with a file sync application like resilio sync or Syncthing.

subsonic ubuntu install

Subsonic features

  • Supports MP3, OGG, AAC and any other audio or video format that streams over HTTP.
  • Works with any network-enabled media player, such as Winamp, iTunes, XMMS, VLC, MusicMatch and Windows Media Player
  • album art display, on-the-fly playlists, on-the-fly transcoding
  • Mobile App for Android, iPhone, Windows Phone and desktop app for Mac, Windows and Chrome. The Android app supports offline playback.
  • Listen to podcasts, assign ratings, add comments, and create playlists.
  • Share you music with friends and family.
  • Stream Videos (premium feature)
  • and more

Note that Subsonic is closed-source since version 6.0.

How to Install Subsonic Media Server on Ubuntu 16.04

Subsonic media server is written in Java, so you need to install Java runtime environment to run it. You can install openjdk 8 with the following command.

sudo apt install openjdk-8-jre

If you have previously installed Oracle Java 8, then there’s no need to install OpenJDK. Next, download Subsonic deb package with the following command, which downloads version 6.1.5. You can check out the latest version on Subsonic download page. If a new version is available, simply replace 6.1.5 with the new version number.

wget https://s3-eu-west-1.amazonaws.com/subsonic-public/download/subsonic-6.1.5.deb

Install it with dpkg.

sudo dpkg -i subsonic-6.1.5.deb

Once it’s installed, the Subsonic daemon will automatically start.

systemctl status subsonic

Sample output:

 subsonic.service - LSB: Subsonic daemon
   Loaded: loaded (/etc/init.d/subsonic; bad; vendor preset: enabled)
   Active: active (running) since Fri 2017-03-24 08:03:27 EDT; 7min ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/subsonic.service
           └─3316 java -Xmx150m -Dsubsonic.home=/var/subsonic -Dsubsonic.host=0

If it’s not running, then you can manually start it with

sudo systemctl start subsonic

And enable auto start at system boot time.

sudo systemctl enable subsonic

By default subsonic listens on 0.0.0.0:4040,which means it accepts requests from local network and the Internet.

If you installed Subsonic on a local Ubuntu computer, then type in the following address in browser to visit Subsonic web interface.

http://localhost:4040

If you installed Subsonic on an Internet-facing Ubuntu server, then type in the following address in browser to visit Subsonic web interface.

http://your-server-ip:4040

subsonic ubuntu 16.04

Please note that if you install Subsonic media server on a home server and you want to access it from outside network, then you will need to configure port forwarding in your router.

The default username and password are admin. After login you should go to Settings > Users to change the admin password.

subsonic media server

Also add media folders in the settings page and click the Save button. Note that the folder must be accessible to the user Subsonic is running as. After folder is added, click “Scan media folder now” button and you will be able to listen to music in the Index page.

subsonic add media folder

Changing User

By default the Subsonic process is run as the root user. For security reason you should change it to a normal user, which is done by editing the /etc/default/subsonic file.

sudo nano /etc/default/subsonic

Find the following line:

SUBSONIC_USER=root

Change root to your own user account like linuxbabe.

SUBSONIC_USER=linuxbabe

Save and close the file. Then restart subsonic daemon for the change to take effect.

sudo systemctl restart subsonic

Setting up Nginx Reverse Proxy for Subsonic

If you want to use a domain name for Subsonic web interface, then you can set up Nginx reverse proxy. Install Nginx on Ubuntu 16.04 using the command below.

sudo apt install nginx

Then create a server block file for proxy.

sudo nano /etc/nginx/conf.d/subsonic-proxy.conf

Put the following text into the file. Replace subsonic.your-domain.com with your own domain name. The location {…} block will make Nginx proxy requests to Subsonic daemon. Don’t forget to set A record for the sub domain.

server {
        listen 80;
        server_name subsonic.your-domain.com;

        location / {
                proxy_pass http://127.0.0.1:4040;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
        }
}

Save and close the file. Then test Nginx configuration.

sudo nginx -t

If the test is successful, then reload Nginx for the new configuration to take effect.

sudo systemctl reload nginx

Now subsonic media server is put behind Nginx and you can access Subsonic web UI using a domain name (subsonic.your-domain.com)

Enabling HTTPS with Nginx

To enable HTTPS secure connection, you can obtain and install a free TLS/SSL certificate from Let’s Encrypt. Install Let’s Encrypt (certbot) client with:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx

Then issue the following command, which uses Certbot Nginx plugin to automatically obtain and install TLS certificate. Replace red text with your actual data.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email your-email-address --domain subsonic.your-domain.com

subsonic certbot nginx

Within a few seconds, you should see a congrats message like below which means the certificate is successfully obtained.
subsonic ubuntu 16.04 https letsencrypt
Go to your Subsonic media server Web interface again, you will find HTTP connection is automatically redirected to HTTPS secure connection. Next, we need to modify the Nginx configuration file.

sudo nano /etc/nginx/conf.d/subsonic-proxy.conf

There’s now two server {…} blocks, becaus Certbot automatically configured the SSL server block (listen 443 ssl). In the SSL server block, add the following line in the location / {…} block.

proxy_redirect http:// https://;

subsonic https settings page

This line will redirect any http server response to https server response, which is needed to properly display Subsonic settings page. Save and close the file. Test Nginx configuration and reload.

sudo nginx -t

sudo systemctl reload nginx

Setting up Apache Reverse Proxy

If you prefer Apache to Nginx, then install it with:

sudo apt install apache2

To use Apache as a reverse proxy, we need to enable the proxy modules and the header module.

sudo a2enmod proxy proxy_http headers

Then create a virtual host file for Subsonic media server.

sudo nano /etc/apache2/sites-available/subsonic-proxy.conf

Put the following configurations into the file. Replace subsonic.your-domain.com with your actual domain name. Don’t forget to create DNS A record for this sub-domain.

<VirtualHost *:80>
   ServerName subsonic.your-domain.com
   ErrorDocument 404 /404.html
   DocumentRoot /var/www
   ProxyPass / http://localhost:4040/
   ProxyPassReverse / http://localhost:4040/
   Header always unset X-Frame-Options
</VirtualHost>

Save and close the file. Then enable this virtual host.

sudo a2ensite subsonic-proxy.conf

Restart Apache

sudo systemctl restart apache2

Now you can access Subsonic web UI using a domain name.

Enabling HTTPS with Apache

To enable HTTPS secure connection, you can obtain and install a free TLS/SSL certificate from Let’s Encrypt. Install Let’s Encrypt (certbot) client with:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt install certbot python3-certbot-apache

Then obtain and install a certificate using the apache plugin.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --must-staple --email your-email-address -d subsonic.your-domain.com

Within a few seconds, you should see a congrats message like below which means the certificate is successfully obtained.subsonic ubuntu 16.04 https letsencrypt

Your TLS certificate will be automatically installed. Go to your Subsonic media server Web interface again, you will find HTTP connection is automatically redirected to HTTPS secure connection.

How to Upgrade to the Latest Version

It is very easy to upgrade existing Subsonic server to the latest version. First go to Subsonic download page and download the latest Debian/Ubuntu package (6.1.2 in this example). You can get the download link in Firefox download manager as shown in the screenshot below.

subsonic upgrade

Then in the terminal you can paste the download link after wget to download Subsonic from the command line.

wget https://s3-eu-west-1.amazonaws.com/subsonic-public/download/subsonic-6.1.2.deb

Next, use dpkg to install the deb package.

sudo dpkg -i subsonic-6.1.2.deb

Restart Subsonic Systemd service and you are done.

sudo systemctl restart subsonic

I hope this tutorial helped you install Subsonic media server on Ubuntu 16.04. As always, if you found this post useful, then subscribe to our free newsletter. You can also follow us on Google+Twitter or like our Facebook page.

Rate this tutorial
[Total: 10 Average: 4.8]

10 Responses to “How to Install Subsonic Media Server on Ubuntu 16.04

  • jenkinsm74
    6 years ago

    Hi. Is there an easy way of upgrading subsonic to a new version, what is the procedure ?
    I am running version 6.1.1 but version 6.1.2 is available.
    Thanks

    • Xiao Guo-An (Admin)
      6 years ago

      It is very easy to do. The upgrade instruction is added at the end of this article.

  • Hi Xiao,

    I’m running Subsonic from within a docker container. Regarding this:
    – do I need to install reverse proxy on the host or inside the container (add to the image)?
    – I cannot acces its DLNA-server because it uses random port and I cannot expose it from the container. How can I fix some specific port for DLNA in Subsonic config, so I could expose it?

    Thanks

  • Had it working in Ubuntu 16.04 LTS, now on 18.04

    HTTP ERROR: 503
    SERVICE_UNAVAILABLE
    RequestURI=/
    Powered by jetty://

    PS: Life is too short to be messing with Linux.

  • What would cause Subsonic not to show any music? I selected the music directory in Ubuntu 16.04, but nothing shows. I tried from a browser and I tried from an android app “Subsonic.” The app says “No media found.”
    Your tutorial was really nice, btw.

  • Benjamin Rios
    4 years ago

    How would you map your media folder to a Windows SMB share?

  • Hello, I want to go with this tutorial using Apache2 as my web server. I don’t understand “Don’t forget to create DNS A record for this sub-domain.” Where and how do I do that ? Somewhere in Apache configuration ?

    • Xiao Guoan (Admin)
      4 years ago

      You need to have a domain name and edit the domain name’s DNS record at your domain registrar’s website. You can buy a cheap domain name from NameCheap. It also provides whois privacy protection free for life.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here