Install Icecast on Ubuntu 20.04
1. Installation
- Update the server.
$ sudo apt update - Upgrade server packages.
$ sudo apt upgrade - Install Icecast
$ sudo apt install icecast2Several prompts show up, select
yesto configure passwords, keeplocalhostas the server hostname, then set the Icecast source, relay, and administrator passwords. - Enable Icecast to start at boot time.
$ sudo systemctl enable icecast2 - Start the Icecast server.
$ sudo systemctl start icecast2
2. Configuration
- Edit the main Icecast configuration file.
$ sudo nano /etc/icecast2/icecast.xml - 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,
8000by default. - 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.
- Restart Icecast to load changes.
$ sudo systemctl restart icecast2
3. Configure Nginx as a Reverse Proxy
- Using a text editor, create a new Nginx configuration file.
$ sudo nano /etc/nginx/conf.d/icecast.conf - Add the following contents to the file. Replace
onlineradio.example.comwith 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.
- Check the Nginx configuration for errors.
$ sudo nginx -t - Restart Nginx.
$ sudo systemctl restart nginx
4. Security
- Allow Full Nginx access through the firewall.
$ sudo ufw allow 'nginx full' - Allow the Icecast port to enable broadcast requests to the server.
$ sudo ufw allow 8000/tcp - Restart the firewall to load changes.
$ sudo ufw reload
5. SSL
- Install the Certbot Nginx package.
$ sudo apt install certbot python3-certbot-nginx - Request a new SSL certificate.
$ sudo certbot -d onlineradio.example.com --agree-tos - Restart Nginx to load changes.
$ sudo systemctl restart nginx
6. Test
- Visit your domain to confirm that Icecast is up and running.
https://onlineradio.example.com/ - Download and Install Mixx on your computer.
- Open Mixx, and navigate to Preferences.
- Select Live Broadcasting, and enter your domain in the Host field, enter
sourcein 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. - Start your Mix, and toggle ON AIR to go live.
- Using a different device, load your mount point on the domain.
https://onlineradio.example.com/stream
Your Mixx stream should start playing.