How to Install Subsonic Media Server on Ubuntu 18.04, 18.10 and Enable HTTPS

This tutorial is going to show you how to install Subsonic media server on Ubuntu 18.04, 18.10 and how to set up a reverse proxy for Subsonic using Nginx or Apache web server, then enable HTTPS.

Subsonic is a free (as in free bear), 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-18.04-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

How to Install Subsonic Media Server on Ubuntu 18.04, 18.10

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

sudo apt update

sudo apt install openjdk-8-jre

At the time of this writing, Subsonic is not compatible with Java 11, If you have previously installed Java 11 on Ubuntu 18.04, 18.10, then you need to run the following command to select the default Java version.

sudo update-alternatives --config java

Type a number to select Java 8 as the default version.

subsonic java 8 java 11

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. You can check its status with:

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 2018-12-02 08:03:27 UTC; 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-18.04-18.10

If you use Java 11 on Ubuntu, you will see the following error. The solution is to use Java 8.

subsonic HTTP ERROR: 503 service unavailable

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. If you have a dynamic IP address given by your ISP, you should also set up dynamic DNS.

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

subsonic-media-server-ubuntu 18.04

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

Change the 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 18.04/18.10 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 install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt 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 https certificate

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.

I hope this tutorial helped you install Subsonic media server on Ubuntu 18.04 and Ubuntu 18.10. 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: 3 Average: 5]

3 Responses to “How to Install Subsonic Media Server on Ubuntu 18.04, 18.10 and Enable HTTPS

  • Following your hoot with Nginx throws this message:
    The following packages have unmet dependencies:
    libnginx-mod-http-geoip : Depends: nginx-common (= 1.14.0-0ubuntu1.2) but it is not going to be installed
    libnginx-mod-http-image-filter : Depends: nginx-common (= 1.14.0-0ubuntu1.2) but it is not going to be installed
    libnginx-mod-http-passenger : Depends: nginx-common (>= 1.14.0-0ubuntu1.2) but it is not going to be installed
    Depends: nginx-common (< 1.14.1) but it is not going to be installed
    libnginx-mod-http-xslt-filter : Depends: nginx-common (= 1.14.0-0ubuntu1.2) but it is not going to be installed
    libnginx-mod-mail : Depends: nginx-common (= 1.14.0-0ubuntu1.2) but it is not going to be installed
    libnginx-mod-stream : Depends: nginx-common (= 1.14.0-0ubuntu1.2) but it is not going to be installed
    nginx : Depends: nginx-core (< 1.14.0-0ubuntu1.2.1~) but it is not going to be installed or
    nginx-full (< 1.14.0-0ubuntu1.2.1~) but it is not going to be installed or
    nginx-light (< 1.14.0-0ubuntu1.2.1~) but it is not going to be installed or
    nginx-extras (= 1.14.0-0ubuntu1.2) but it is not going to be installed or
    nginx-full (>= 1.14.0-0ubuntu1.2) but it is not going to be installed or
    nginx-light (>= 1.14.0-0ubuntu1.2) but it is not going to be installed or
    nginx-extras (>= 1.14.0-0ubuntu1.2) but it is not going to be installed
    E: Unmet dependencies. Try ‘apt –fix-broken install’ with no packages (or specify a solution).

    apt –fix-broken install is not successful. Any idea?
    rgds

    • Perhaps Nginx is already installed on your machine from another repository. You can check if it’s installed by running

      nginx -v

      Check if it’s running

      systemctl status nginx

      If that’s not the case, try updating the repository.

      sudo apt update
      • thanx. you are right. It was already installed. I did not know..

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.
  • If my answer helped you, please consider supporting this site. Thanks :)