Darkice captures from the sound card and pushes it to Icecast. Icecast then streams the audio to connected clients. I am also using nginx to prevent users accessing the admin interface, for a layer of security.
As this is a quick and dirty guide, its assumed you have some Linux experience. If you get stuck, feel free to leave a comment.
Warning: In order to stream audio to the public internet, you will need to expose your system to the public internet, possibly by port forwarding if you're behind NAT.
You will need to ensure your system is suitably secured, which is not covered in full in this guide.
As a minimum, I'd suggest using iptables to prevent users accessing services they shouldn't. The native Icecast port 8000 should be blocked, ensuring that users only connect to the stream via NGINX.
First of all change to the root user:
And install some dependencies:
Then install the lame MP3 Library. Check the website for the latest version and update accordingly. The following commands should be run sequentially:
Then install darkice. Check the website for the latest version and update accordingly:
Then install icecast. Check the website for the latest version and update accordingly:
Create the user, and setup directories and permissions. Run the following commands sequentially:
Create a config file for icecast:
And use the following example as a guide. Refer to the icecast documentation for more complex setups:
Then create the Darkice configuration file:
And enter your configuration, using the following as a template:
Edit the nginx config file:
Enter the following, ensuring you update it with your details. The rewrite will redirect anyone thats not specified a stream to another URL of your choice.
Reload nginx so the settings take affect:
Securing the system with iptables
Editing firewall rules can potentially lock you out the system if you get it wrong. Be careful. The following is some 'inspiration' but you will need to edit the rules if you're hosting other services on the same system. Additionally, this only covers IPv4, as I don't have an IPv6 address on this system. If you're using IPv6, you will need to also secure traffic to the IPv6 address.
Create a rules file:
Enter the following. If you're running other services, remember to add the relevant rules. Also note the following rules will allow anyone to connect to your MP3 stream and attempt to SSH into your system:
Apply the rules:
I suggest you then disconnect from the SSH session and attempt to re-connect. Remember to sudo su again. If you're unable to connect, something has gone wrong. But don't panic! Rebooting the system will remove the rules, and you can fix the issue.
If you can successfully reconnect, then configure the interface to load the rules before it initialises:
Enter the following:
And make it executable:
Starting services on boot
Create a service to ensure Icecast starts up on boot:
Add the following:
Then create a service to ensure Darkice starts up on boot, after Icecast has started:
Add the following. The CPUScheduling sections help to minimise dropped audio if they system is under load.
Next reboot the server: