Install Icecast on Ubuntu 20.04

Updated on November 21, 2023
Install Icecast on Ubuntu 20.04 header image

Icecast is a free audio media streaming solution that lets you create an audio streaming platform with support for MP3 and Ogg Vorbis audio streams. This guide explains how you can install Icecast on a Ubuntu 20.04 server.

Prerequisites

1. Installation

  1. Update the server.

      $ sudo apt update
  2. Upgrade server packages.

      $ sudo apt upgrade
  3. Install Icecast

      $ sudo apt install icecast2

    Several prompts show up, select yes to configure passwords, keep localhost as the server hostname, then set the Icecast source, relay, and administrator passwords.

  4. Enable Icecast to start at boot time.

      $ sudo systemctl enable icecast2
  5. Start the Icecast server.

      $ sudo systemctl start icecast2

2. Configuration

  1. Edit the main Icecast configuration file.

      $ sudo nano /etc/icecast2/icecast.xml
  2. Find the following line.

      <listen-socket>
        <port>8000</port>
        <!-- <bind-address>127.0.0.1</bind-address> -->
        <!-- <shoutcast-mount>/stream</shoutcast-mount> -->
      </listen-socket>

    Change the Icecast port to your preferred setting, 8000 by default.

  3. To change the administrator and source passwords, find the following section.

      <authentication>
        <!-- Sources log in with username 'source' -->
        <source-password>12345678</source-password>
        <!-- Relays log in with username 'relay' -->
        <relay-password>12345</relay-password>
    
        <!-- Admin logs in with the username given below -->
        <admin-user>admin</admin-user>
        <admin-password>admin123</admin-password>
      </authentication>

    Save the file.

  4. Restart Icecast to load changes.

      $ sudo systemctl restart icecast2

3. Configure Nginx as a Reverse Proxy

  1. Using a text editor, create a new Nginx configuration file.

      $ sudo nano /etc/nginx/conf.d/icecast.conf
  2. Add the following contents to the file. Replace onlineradio.example.com with your real domain.

      server {
       listen 80;
       listen [::]:80;
       server_name onlineradio.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_pass http://127.0.0.1:8000/;
       sub_filter_types application/xspf+xml audio/x-mpegurl audio/x-vclt text/css text/html text/xml;
       sub_filter ':8000/' '/';
       sub_filter '@localhost' '@onlineradio.example.com';
       sub_filter 'localhost' $host;
       sub_filter 'Mount Point ' $host;
      }
      }

    Save the file.

  3. Check the Nginx configuration for errors.

      $ sudo nginx -t
  4. Restart Nginx.

      $ sudo systemctl restart nginx

4. Security

  1. Allow Full Nginx access through the firewall.

      $ sudo ufw allow 'nginx full'
  2. Allow the Icecast port to enable broadcast requests to the server.

      $ sudo ufw allow 8000/tcp
  3. Restart the firewall to load changes.

      $ sudo ufw reload

5. SSL

  1. Install the Certbot Nginx package.

      $ sudo apt install certbot python3-certbot-nginx
  2. Request a new SSL certificate.

      $ sudo certbot -d onlineradio.example.com --agree-tos
  3. Restart Nginx to load changes.

      $ sudo systemctl restart nginx

6. Test

  1. Visit your domain to confirm that Icecast is up and running.

      https://onlineradio.example.com/
  2. Download and Install Mixx on your computer.

  3. Open Mixx, and navigate to Preferences.

  4. Select Live Broadcasting, and enter your domain in the Host field, enter source in the Login field, specify a Mount point, for example /stream, enter the Icecast port, blank, then, the source Password specified in the Icecast configuration file.

  5. Start your Mix, and toggle ON AIR to go live.

  6. Using a different device, load your mount point on the domain.

      https://onlineradio.example.com/stream

Your Mixx stream should start playing.

More Information

You have installed Icecast on Ubuntu 20.04, for more information and configuration options, visit the following guides.