Set up a Shoutcast Server on Ubuntu

Updated on November 21, 2023
Set up a Shoutcast Server on Ubuntu header image

Introduction

Shoutcast is a media streaming service that lets you create your own media streaming platform. It supports digital audio content in MP3 and Advanced Audio Coding (AAC) formats. This guide explains how to set up a Shoutcast server on Ubuntu and secure it with a Let's Encrypt SSL using Certbot.

Prerequisites

Set Up the Shoutcast Server

  1. Download Shoutcast Distributed Network Audio Server (DNAS) for Linux.

     $ wget https://download.nullsoft.com/shoutcast/tools/sc_serv2_linux_x64-latest.tar.gz

    Please see the Shoutcast DNAS download page for the latest Shoutcast DNAS version.

  2. Create a new folder for your Shoutcast server.

     $ mkdir ~/shoutcast_server
  3. Extract the downloaded Shoutcast DNAS to the new folder.

     $ tar -xzf sc_serv2_linux_x64-latest.tar.gz -C ~/shoutcast_server
  4. Change the directory to the new folder.

     $ cd ~/shoutcast_server
  5. By default, Shoutcast uses port 8000 for source and client connections and port 8001 for legacy source connections, so you need to allow ports 8000 and 8001 on the firewall.

     $ sudo ufw allow 8000 && sudo ufw allow 8001
  6. When you run Shoutcast on a normal SSH session, the Shoutcast process closes when you exit the SSH Session. To continuously run Shoutcast even when you leave the SSH session, use tmux, a terminal multiplexer. To create a tmux session, run:

     $ tmux new -s shoutcast

    You can change shoutcast with any session name you prefer. Please see How to Install and Use Tmux for more information.

  7. Run the setup.sh script to start the server and proceed with the setup.

     $ sudo bash setup.sh
  8. Log in to your Shoutcast account and navigate to your radio station's Advanced Settings, then save your radio station's Authhash. You will need this later when you configure your stream.

  9. In your browser, navigate port 8000 at your server's IP address. For example: http://192.0.1.2:8000

  10. On the setup's Stage 1 - Core Settings, Fill in your preferred Source Password and Admin Password. Leave the User Id and License Id text fields blank, and leave the server port by default 8000. Set the maximum number of listeners allowed to connect to your server, then click Continue to proceed with the setup.

  11. On the setup's Stage 2 - Stream Settings, set the number of streams you want to pre-configure. Set each stream's Source Password, Admin Password, the maximum number of listeners allowed to connect to your stream, and your radio station's Authhash that you saved in step 8, then click Continue to proceed with the setup.

  12. On the setup's Stage 3 - Confirm Settings, verify the information you entered in the previous stages, then click Continue to proceed with the setup. Please take note of your stream's Source Password because you will need it when you set up your stream's source later.

  13. On Setup Stage 4 - Save Settings, click Run Server. It redirects you to http://127.0.0.1:8000/admin.cgi?sid=0&pass=YourAdminPass. Replace 127.0.0.1 with your server's IP address and YourAdminPass with the Admin Password you entered on Stage 1 - Core Settings.

Configure Nginx as a Reverse Proxy

  1. Detach from the tmux session by pressing Ctrl + B then D.

  2. Install Nginx.

     $ sudo apt install nginx -y
  3. Create a new Nginx configuration file for your Shoutcast server.

     $ sudo nano /etc/nginx/conf.d/shoutcast.conf
  4. Paste this to your shoutcast.conf file. Replace example.com with your domain name.

     server {
         listen 80;
         listen [::]:80;
         server_name example.com;
    
         proxy_set_header Host $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-Host $host;
         proxy_set_header X-Forwarded-Server $host;
    
         location / {
             proxy_set_header Accept-Encoding "";
             proxy_set_header Accept "";
             proxy_pass http://127.0.0.1:8000/;
             sub_filter ':8000/' '/';
             sub_filter '@localhost' '@example.com';
             sub_filter 'localhost' $host;
             }
      }
  5. Save and exit the file.

  6. Test the Nginx configuration.

     $ sudo nginx -t
  7. Restart Nginx.

     $ sudo systemctl restart nginx
  8. Allow the HTTP Port 80 and the HTTPS Port 443 on the firewall.

     $ sudo ufw allow 'Nginx Full'

Install Let's Encrypt SSL with Certbot

  1. Install Certbot.

     $ sudo apt install certbot python3-certbot-nginx -y
  2. Request a new Let's Encrypt SSL Certificate using Certbot. Replace example.com with your domain name.

     $ sudo certbot --agree-tos -d example.com
  3. Let's Encrypt Certificates are only valid for 90 days. To automatically renew the SSL certificates, add a new cron job.

     $ sudo crontab -e

    Select your preferred editor, then paste this into the crontab file.

     0 0 1 * * certbot renew --quiet --post-hook="systemctl reload nginx"

    This command runs at midnight on every first day of the month. It checks if the certificate expires within the next 30 days and renews it if so.

  4. Save and exit the crontab file.

  5. On your browser, navigate to your domain name. Log in to the server using admin as the username and the Admin Password you entered at Stage 1 - Core Settings as the password.

Testing - Set Up Stream Source

  1. On your local computer, download and install Mixxx, a free and open-source DJ software.
  2. After installing, open Mixxx, then load your track or songs that you want to play on your radio station.
  3. On Mixxx's Menu bar, click Options, then select Preferences.
  4. Select Live Broadcasting from the sidebar menu.
  5. Enable the source connection by selecting the checkbox from the Enabled column. You may also rename the source connection by selecting it and clicking the Rename selected button.
  6. Select the Turn on Live Broadcasting when applying these settings checkbox.
  7. On the Server Connection section, select Shoutcast 1 for the Type. Type in your server's IP address on the Host field and 8000 on the Port field. Leave the Mount and Login fields blank, and enter your Stream's Source Password on the Password field.
  8. You may also configure the Encoding and Stream info sections, or you can leave it by default.
  9. Click Apply and wait for the status to become Connected.
  10. Play a song on Mixxx, then navigate to your domain name. You may now listen to your songs on your website.

More Information

To learn more about Shoutcast, please see these resources: