Tag: icecast

  • Enable SSL for icecast steam using nginx

    On ubuntu server running icecast, when i try enable SSL as per CentovaCast Enable SSL on icecast, i get following error

    connection/get_ssl_certificate No SSL capability
    

    I don’t compile my own icecast installation as it use Ubunu version of icecast, that get updated using apt.

    Instead of getting icecast serve steam using SSL, i installed Nginx, and proxy traffic from SSL port to icecast.

    Install nginx with

    apt install nginx
    

    remove default server entry

    rm -f /etc/nginx/sites-enabled/default
    

    Create file

    vi /etc/nginx/sites-enabled/stream.comf
    

    Add

    server {
        listen       9000 ssl;
        server_name  icecast.serverok.in;
        root         /var/www/html;
        ssl_certificate /etc/letsencrypt/live/icecast.serverok.in/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/icecast.serverok.in/privkey.pem;
    
        client_max_body_size 100M;
        proxy_read_timeout 600s;
        proxy_buffer_size   128k;
        proxy_buffers   4 256k;
        proxy_busy_buffers_size   256k;
    
        location / {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8000;
        }
    }
    

    In above configuration

        ssl_certificate /etc/letsencrypt/live/icecast.serverok.in/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/icecast.serverok.in/privkey.pem;
    

    is the SSL i already have on server. Replace it with path to SSL certifciate on your server. If you don’t have an SSL, you need to purcahse one or get a free SSL using LetsEncrypt.

    Restart Nginx

    systemctl restart nginx
    

    Now stream on port 8000 will work using HTTPS on port 9000.

    Modify ports as required.

    If you use Free LetsEncrypt SSL, you may need to add a cronjob to auto reastart nginx when SSL get updated.

    crontab -e
    

    Add

    @weekly systemctl restart nginx
    

    See Icecast, Nginx

  • Autostart icecast using systemd

    To autostart icecast using systemd, create a unit file

    vi /etc/systemd/system/icecast.service
    

    Add following content

    [Unit]
    Description=Icecast Network Audio Streaming Server
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/local/bin/icecast -c /etc/icecast/icecast.xml
    ExecReload=/bin/kill -HUP $MAINPID
    User=icecast
    Group=icecast
    WorkingDirectory=/home/icecast/
    
    [Install]
    WantedBy=multi-user.target

    Enable icecast to start on boot with

    systemctl enable icecast

    To start/stop/restart icecast, use

    systemctl start icecast
    systemctl stop icecast
    systemctl restart icecast
  • How to install icecast KH on CentOS 7 Server

    Download latest source code for IceCast KH server from

    https://github.com/karlheyes/icecast-kh/releases

    At the time of writing this post, latest version is 2.4.0-kh15

    cd /usr/local/src
    wget https://github.com/karlheyes/icecast-kh/archive/icecast-2.4.0-kh15.tar.gz
    tar -zxf icecast-2.4.0-kh15.tar.gz
    cd icecast-kh-icecast-2.4.0-kh15
    ./configure
    make CFLAGS="-D_XOPEN_SOURCE=600"
    make install
    

    If you get error related to “XSLT configuration could not be found”, see configure: error: XSLT configuration could not be found

    You need a non root user to run icecast, create a user

    useradd -m -s /bin/bash icecast
    

    Copy the sample conif file

    mkdir /etc/icecast
    cp /usr/local/src/icecast-kh-icecast-2.4.0-kh13/examples/icecast_minimal.xml /etc/icecast/
    chown -R icecast:icecast /etc/icecast/
    cp -R /usr/local/src/icecast-kh-icecast-2.4.0-kh13/admin/ /home/icecast/admin/
    cp -R /usr/local/src/icecast-kh-icecast-2.4.0-kh13/web/ /home/icecast/web/
    chown -R icecast:icecast /home/icecast/admin/
    chown -R icecast:icecast /home/icecast/web/
    

    Switch to user icecast

    su - icecast
    

    Create folders for logs

    mkdir /home/icecast/logs
    

    To start icecast, run

    icecast -c /etc/icecast/icecast.xml
    

    Edit icecast.xml, set the password and ports as required.

    To autostart icecast on server boot, check Autostart icecast using systemd.

    See icecast