Set up a Shoutcast Server on Ubuntu
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
- Deploy an Ubuntu cloud server.
- Create a non-root user with sudo access and log in with SSH.
- Update the Ubuntu cloud server.
- Create a shoutcast account if you do not have one, then log in.
- Create a radio station if you do not have one.
- Create a fully-qualifed domain name pointed to your server's IP address.
Set Up the Shoutcast Server
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.
Create a new folder for your Shoutcast server.
$ mkdir ~/shoutcast_server
Extract the downloaded Shoutcast DNAS to the new folder.
$ tar -xzf sc_serv2_linux_x64-latest.tar.gz -C ~/shoutcast_server
Change the directory to the new folder.
$ cd ~/shoutcast_server
By default, Shoutcast uses port
8000
for source and client connections and port8001
for legacy source connections, so you need to allow ports8000
and8001
on the firewall.$ sudo ufw allow 8000 && sudo ufw allow 8001
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.Run the
setup.sh
script to start the server and proceed with the setup.$ sudo bash setup.sh
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.
In your browser, navigate port 8000 at your server's IP address. For example:
http://192.0.1.2:8000
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.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.
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.
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
. Replace127.0.0.1
with your server's IP address andYourAdminPass
with the Admin Password you entered on Stage 1 - Core Settings.
Configure Nginx as a Reverse Proxy
Detach from the tmux session by pressing Ctrl + B then D.
Install Nginx.
$ sudo apt install nginx -y
Create a new Nginx configuration file for your Shoutcast server.
$ sudo nano /etc/nginx/conf.d/shoutcast.conf
Paste this to your
shoutcast.conf
file. Replaceexample.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; } }
Save and exit the file.
Test the Nginx configuration.
$ sudo nginx -t
Restart Nginx.
$ sudo systemctl restart nginx
Allow the HTTP Port
80
and the HTTPS Port443
on the firewall.$ sudo ufw allow 'Nginx Full'
Install Let's Encrypt SSL with Certbot
Install Certbot.
$ sudo apt install certbot python3-certbot-nginx -y
Request a new Let's Encrypt SSL Certificate using Certbot. Replace
example.com
with your domain name.$ sudo certbot --agree-tos -d example.com
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.
Save and exit the crontab file.
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
- On your local computer, download and install Mixxx, a free and open-source DJ software.
- After installing, open Mixxx, then load your track or songs that you want to play on your radio station.
- On Mixxx's Menu bar, click Options, then select Preferences.
- Select Live Broadcasting from the sidebar menu.
- 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.
- Select the Turn on Live Broadcasting when applying these settings checkbox.
- 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. - You may also configure the Encoding and Stream info sections, or you can leave it by default.
- Click Apply and wait for the status to become Connected.
- 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: