{"id":1358,"date":"2022-08-02T14:43:38","date_gmt":"2022-08-02T07:43:38","guid":{"rendered":"https:\/\/www.whplus.com\/blog\/?p=1358"},"modified":"2024-04-05T09:36:17","modified_gmt":"2024-04-05T02:36:17","slug":"securing-icecast-stream-with-ssl-letsencrypt","status":"publish","type":"post","link":"https:\/\/www.whplus.com\/blog\/2022\/08\/02\/securing-icecast-stream-with-ssl-letsencrypt.html","title":{"rendered":"Securing Icecast Stream with SSL Letsencrypt"},"content":{"rendered":"<p>Icecast is a popular and well loved live audio streaming application. It is free, and requires very limited resources to run. In this guide, we&#8217;ll explain how to enable HTTPS on Icecast, and how to generate SSL certificates for free via Lets Encrypt. This guide assumes you&#8217;re running Debian 11 or newer. Older versions may work, but there&#8217;s a lot of painful stuffing around with package dependencies.<\/p>\n<p>Some online guides show you how to place Nginx or Apache in front of Icecast for SSL termination, but that&#8217;s not necessary. Now, you can install or update Icecast:<\/p>\n<p><code>apt-get install icecast2<\/code><\/p>\n<p>At this point, you may need to configure Icecast. If this is an existing installation, Icecast should still be running with your existing configuration. Make sure you test this now.<br \/>\n<!--more--><\/p>\n<p><strong>Icecast Configuration<\/strong><\/p>\n<p>To open Icecast configuration , type the following and press enter:<\/p>\n<p><code>nano \/etc\/icecast2\/icecast.xml<\/code><\/p>\n<p>For now, we&#8217;re only going to change two settings \u2013 the port number, and the user that Icecast runs under.<\/p>\n<p>Using your arrow keys, scroll until you see the line &#8216;8000&#8217;. Change the number &#8216;8000&#8217; to &#8217;80&#8217;. This puts Icecast on the default HTTP port, making it easier for people to listen behind a corporate firewall.<\/p>\n<p>Next, scroll right to the bottom of the file where you can see a security section. Delete the text &#8216;&lt;!\u2013&#8217; and &#8216;\u2013&gt;&#8217;\u00a0 (leaving everything in the middle)<\/p>\n<p>To exit and save, press Ctrl + X, Y and Enter.<\/p>\n<p>We also need to change one more file to make this work. Type in:<\/p>\n<p><code>nano \/etc\/default\/icecast2<\/code><\/p>\n<p>Change the USERID and GROUPID values to &#8216;root&#8217;<\/p>\n<p>To exit and save, press Ctrl + X, Y and Enter.<\/p>\n<p>Finally, we probably need to change the log file ownership with this command:<\/p>\n<p><code>chown -R nobody \/var\/log\/icecast2\/<\/code><\/p>\n<p>Then, you need to restart the service with the following command:<\/p>\n<p><code>service icecast2 restart<\/code><\/p>\n<p><strong>Installing and running Lets Encrypt Certbot for Icecast<\/strong><\/p>\n<p>In order for the SSL Certificate validation to work, you will need to have DNS setup and pointing to this server. Icecast must already be running on Port 80.<\/p>\n<p>Now, we can begin to install and run the tools needed to generate an SSL certificate. This section assumes your server can be located at &#8216;stream.example.com&#8217;.<\/p>\n<p><code>apt-get install certbot<\/code><\/p>\n<p>Run certbot with the correct domain for your server:<\/p>\n<p><code>certbot certonly --webroot-path=\"\/usr\/share\/icecast2\/web\" -d 'stream.example.com'<\/code><\/p>\n<p>When prompted, select the &#8216;webroot&#8217; option and input your email address. Your certificate should be generated at this point. If you receive errors, take note of them and start doing some research online. The most common error is the inability to validate \u2013 in this case, make sure Icecast is accessible via DNS on Port 80, and check your webfoot is indeed &#8216;\/usr\/share\/icecast2\/web&#8217;.<\/p>\n<p>We now need to concatenate two certificate files so they are in the correct format for Icecast to use:<\/p>\n<p><code>cat \/etc\/letsencrypt\/live\/stream.example.com\/fullchain.pem \/etc\/letsencrypt\/live\/stream1.example.com\/privkey.pem &gt; \/etc\/icecast2\/bundle.pem<\/code><\/p>\n<p>Also:<\/p>\n<p><code>chmod 666 \/etc\/icecast2\/bundle.pem<\/code><\/p>\n<p>If you know which user Icecast is running under, you can run a chown instead of a chmod. Icecast needs to be able to read this new PEM file \u2013 that&#8217;s the goal here.<\/p>\n<p>While we&#8217;re thinking about it, we should also make sure certificate renewals run correctly. Open the certificate config file in a text editor:<\/p>\n<p><code>nano \/etc\/letsencrypt\/renewal\/stream.example.com.conf<\/code><\/p>\n<p>Add this line to the [renewalparams] section:<\/p>\n<p><code>post_hook = cat \/etc\/letsencrypt\/live\/stream.example.com\/fullchain.pem \/etc\/letsencrypt\/live\/stream.example\/privkey.pem &gt; \/etc\/icecast2\/bundle.pem &amp;&amp; service icecast2 restart<\/code><\/p>\n<p>You can validate the renewal process to make sure it works correctly:<\/p>\n<p><code>certbot renew --dry-run<\/code><\/p>\n<p><strong>Configure Icecast for SSL<\/strong><\/p>\n<p>We are now ready to finish this off and get Icecast running with our new certificate.<br \/>\nEdit Icecast.xml in a text editor:<\/p>\n<p><code>nano \/etc\/icecast2\/icecast.xml<\/code><\/p>\n<p>Add this line to the &lt; paths&gt;&lt; \/paths&gt; section:<\/p>\n<p>&lt; ssl-certificate&gt;\/etc\/icecast2\/bundle.pem&lt; \/ssl-certificate&gt;<br \/>\nNow, add this section to the document (in the root XML node):<\/p>\n<p>&lt;listen-socket&gt;<br \/>\n    &lt;port&gt;443&lt;\/port&gt;<br \/>\n    &lt;ssl&gt;1&lt;\/ssl&gt;<br \/>\n&lt;\/listen-socket&gt;<\/p>\n<p>Quit the text editor, and now restart Icecast:<\/p>\n<p><code>service icecast2 restart<\/code><\/p>\n<p>If all goes well, you can now browse to httsp:\/\/stream.example.com\/ and also listen to your internet streams over HTTPS.<\/p>\n<p>source: https: \/\/mediarealm.com.au\/articles\/icecast-https-ssl-setup-lets-encrypt\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Icecast is a popular and well loved live audio streaming application. It is free, and requires very limited resources to run. In this guide, we&#8217;ll explain how to enable HTTPS on Icecast, and how to generate SSL certificates for free via Lets Encrypt. This guide assumes you&#8217;re running Debian 11 or newer. Older versions may\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.whplus.com\/blog\/2022\/08\/02\/securing-icecast-stream-with-ssl-letsencrypt.html\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1358","post","type-post","status-publish","format-standard","hentry","category-tutorial"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/1358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/comments?post=1358"}],"version-history":[{"count":10,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/1358\/revisions"}],"predecessor-version":[{"id":1407,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/1358\/revisions\/1407"}],"wp:attachment":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/media?parent=1358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/categories?post=1358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/tags?post=1358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}