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

This tutorial is going to show you how to install Subsonic media server on Ubuntu 18.04, 19.04 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, 19.04

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, 19.04, 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 runs 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/19.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 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 19.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: 3 Average: 5]

13 Responses to “How to Install Subsonic Media Server on Ubuntu 18.04, 19.04 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

    • Xiao Guo-An (Admin)
      5 years ago

      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..

  • I followed the guide with a couple deviations necessary in order to make it work, but those were minor items.

    I can successfully connect to the https version of my site, but I still get the “Welcome to nginx” message. Subsonic, though it claims to be an active service, is nowhere to be found. 🙁 Ideas?

  • This is an awesome how to! Thank you so much.

    I’ve got the browser using https and proxy via apache2, and a dns _acme-challenge Let’s Encrypt.

    But I’m trying to configure LDAP user authentication with startTLS and am really not sure how to go about debugging it. Do you have any suggestions on where to look (I’ve checked for the usual suspects re: dn and search configs, and have tried putting certificates with appropriate permissions in /etc/ssl…)?

    Thanks again for lots of high quality how-tos!

  • Hi,
    I followed your tutorial, which is always great.
    But this time I get an error as soon as I edit subsonic-proxy.conf and restart nginx.
    I get a 502 bad gateway nginx error.

    A record is set, subdomain is cofigured correctly.
    nginx log says: 111: connection refused while connecting upstream

    Do you have an idea?
    Thanks

  • great guide. thx a lot

  • great guide. thx a lot

    but i get a strange situation:

    i have my subsonic.conf

    ServerName wolke:8085
    ErrorDocument 404 /404.html
    DocumentRoot /var/www
    ProxyPass / http://wolke:4040/
    ProxyPassReverse / http://wolke:4040/
    ProxyPreserveHost On
    ProxyRequests Off
    SSLEngine on
    SSLProxyEngine On
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
    SSLCertificateFile /etc/ssl/private/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key
    Header always unset X-Frame-Options

    by https://wolke:8085, i get:

    Bad Request
    Your browser sent a request that this server could not understand.
    Reason: You’re speaking plain HTTP to an SSL-enabled server port.
    Instead use the HTTPS scheme to access this URL, please.
    Apache/2.4.29 (Ubuntu) Server at wolke Port 443

    any hint in how to solve this?

    Thx!

  • great guide. thx a lot

    but i get a strange situation:

    i have my subsonic.conf

    
    
       ServerName wolke:8085
       ErrorDocument 404 /404.html
       DocumentRoot /var/www
       ProxyPass / http://wolke:4040/
       ProxyPassReverse / http://wolke:4040/
       ProxyPreserveHost On
       ProxyRequests Off
       SSLEngine on   
       SSLProxyEngine On
       SSLProtocol all -SSLv2 -SSLv3
       SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
       SSLCertificateFile      /etc/ssl/private/server.crt
       SSLCertificateKeyFile   /etc/ssl/private/server.key
       Header always unset X-Frame-Options
     
    
    

    by https://wolke:8085, i get:

    Bad Request
    Your browser sent a request that this server could not understand.
    Reason: You’re speaking plain HTTP to an SSL-enabled server port.
    Instead use the HTTPS scheme to access this URL, please.
    Apache/2.4.29 (Ubuntu) Server at wolke Port 443

    any hint in how to solve this?

    Thx!

  • Hello,

    I am having trouble installing subsonic. I installed the most current version 6.1.6. I am getting 404 error with the following message when I go to http://localhost:4040:

    HTTP ERROR: 404
    /error.jsp
    RequestURI=/error.jsp

    Caused by:
    java.lang.NoClassDefFoundError: net/sourceforge/subsonic/filter/ParameterDecodingFilter$DecodingServletRequestWrapper
    at net.sourceforge.subsonic.filter.ParameterDecodingFilter.doFilter(ParameterDecodingFilter.java:33)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    at net.sourceforge.subsonic.filter.BootstrapVerificationFilter.doFilter(BootstrapVerificationFilter.java:41)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
    at org.mortbay.jetty.Server.handle(Server.java:313)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
    at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

    I installed Java 8 and believe it is correctly configured:

    java -version
    openjdk version “1.8.0_252”
    OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
    OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

    Wondering if you have any insight onto what is amiss?

    Thanks!!

  • Hello,

    I am having trouble installing subsonic. I installed the most current version 6.1.6. I am getting 404 error with the following message when I go to http://localhost:4040:

    HTTP ERROR: 404
    /error.jsp
    RequestURI=/error.jsp
    
    Caused by:
    java.lang.NoClassDefFoundError: net/sourceforge/subsonic/filter/ParameterDecodingFilter$DecodingServletRequestWrapper
    at net.sourceforge.subsonic.filter.ParameterDecodingFilter.doFilter(ParameterDecodingFilter.java:33)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    at net.sourceforge.subsonic.filter.BootstrapVerificationFilter.doFilter(BootstrapVerificationFilter.java:41)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
    at org.mortbay.jetty.Server.handle(Server.java:313)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
    at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

    I installed Java 8 and believe it is correctly configured:

    java -version
    openjdk version “1.8.0_252”
    OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
    OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

    Wondering if you have any insight onto what is amiss?

    Thanks!!

  • very useful. thank you. my previous let’s encrypt cert had expired and this helped refresh my failing memory.

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