Ant Media Server on Ubuntu 18.04

This short guide will show you how to install Ant Media Server (Community Edition) on a Ubuntu 18.04 VPS server. Ant Media Server is a fork of Red5.

The community Edition is free, but it does have it’s limitations that can be unlocked by purchasing a license. It runs on Java so we’re also installing that on our server.

The server that I used in this example has Nginx installed and running with the additional RTMP module on port 1935. Ant Media Server will also require this port so to avoid any conflicts we need to stop Nginx before anything else. I also choose to disable it temporary but you don’t need to do this.

systemctl stop nginx
systemctl disable nginx

Another option you have to avoid conflicts is to change the port Nginx uses for RTMP by changing it in your /etc/nginx/nginx.conf file as shown on the image.

Let’s start by installing the default java (version 8) for Ubuntu.

apt install -y openjdk-8-jdk openjdk-8-jre
java -version

You must have to set JAVA_HOME and JRE_HOME environment variables, which is used by many of the Java applications to find Java libraries during runtime. You can set these variables in /etc/environment file using the following command.

cat >> /etc/environment <<EOL JAVA_HOME= /usr/lib/jvm/java-8-openjdk-amd64 JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre EOL
wget https://github.com/ant-media/Ant-Media-Server/releases/download/ams-v2.0.0/ant-media-server-2.0.0-community-2.0.0-20200504_1842.zip
unzip ant-media-server-2.0.0-community-2.0.0-20200504_1842.zip
cd /opt/ant-media-server
wget https://raw.githubusercontent.com/ant-media/Scripts/master/install_ant-media-server.sh && chmod 755 install_ant-media-server.sh
sudo ./install_ant-media-server.sh ant-media-server-2.0.0-community-2.0.0-20200504_1842.zip
service antmedia status

http://SERVER_IP_ADDRESS:5080

In order to server run properly you need to open some network ports.

  • TCP:1935 (RTMP)
  • TCP:5080 (HTTP)
  • TCP:5443 (HTTPS)
  • UDP:5000-65000 (WebRTC)
  • TCP:5000-65000 (You need to open this range in only cluster mode for internal network. It should not be open to public.)
sudo ufw allow 1935/tcp
sudo ufw allow 5080/tcp
sudo ufw allow 5443/tcp

CLUSTER MODE ONLY
sudo ufw allow 5000:65000/udp

We’re done for now. Everything should be working now. A logical next step would be to install certificates and enable secure live-streaming. More about that on this page: https://github.com/ant-media/Ant-Media-Server/wiki/SSL-Setup

There’s a well written Wiki on the project’s github pages. You can use this if you run in to any issues. No need to click the link below at this moment because then you will see that I basically copy / pasted this whole page. In other words: I stole content. Sue me.. At least I’m honest about it.

https://github.com/ant-media/Ant-Media-Server/wiki/Installation

Fix the Nginx module in Webmin (Ubuntu 18.04)

For a long time now, the Nginx plugin that exists for Webmin did not work after installing it on Ubuntu/Debian. I never got around to figure out how to fix this but today I did. Here’s how to fix the Nginx plugin in Webmin on a Ubuntu server.

Now in all honesty I have no idea what step of all the steps below did the trick of actually getting it to work, but I’m guessing it had something to do with the brackets in the config file. I still need to try this out on a different server without installing the Perl modules first. You’re free to experiment yourself if you dare. If so, let me know what the specific fix was.

First of course you need to install the Nginx module for Webmin. It’s a third party module so add it using the correct option on the screen you see here.

Search for Nginx, select it and install it. Once it is installed you will find the tab on the left under Servers. If not, refresh your modules first. Chances are very likely that you will see a page with some errors that are Perl related. If this is the case continue to follow these steps.

In webmin open the Others tab, and then Perl Modules. Choose “From CPAN, named” and search for DBD::mysql and installit. Do the same thing for all of the following:

HTML::Entities
DBI
GD
DBD::mysql

If you run into any problems you can alternatively install the plugin through the command line. To start first use this command:

perl -MCPAN -e shell

Now you can install any plugin by entering:

i HTML::Entities

When it’s installed optionally do a “reload cpan” or install more plugins. Use te “quit” command to exit the perl inputline. If you’re running the earlier mentioned command for the first time you might also want to start of with “install CPAN” and “reload CPAN

Next step may seem difficult but it really isn’t. We need to add some \ to a config file. So edit the following file and make the changes I placed below.

nano /usr/share/webmin/nginx/nginx-lib.pl

Go to line 199 and add a backslash before the opening bracket.

if ($if ($line =~ /server \{$/) {

Do not forget to add a backslash before the closing bracket on line 202.

if ($line =~ /\}$/) {

Save the file and now it should work after refreshing the Webmin Nginx page.

Build a live-stream server

This guide will show you step by step how to install Nginx webserver & Certbot SSL certificates, the RTMP module, Ffmpeg on a Ubuntu 18.04 VPS server. It will then will also explain how to setup HLS live-streaming and create a webpage with Video.JS to show the live-stream.
I decided to write this guide after receiving a lot of questions and responses on a video or two that I made a while ago. HLS and SSL related mostly. So hopefully this guide will clear up all of those questions for you all. If not, please leave any questions at the bottom of this page or as comment on the Youtube page.

This guide contains 7 steps. I strongly advice to read through them all beforehand so you’ll know what you’re doing in stead of just blindly start copy/pasting everything, because that rarely works out like it should, in my experience. This looks like a long-ass guide, and it is in a way, but you could do this all in under 25 minutes. Anyways, it’s too long for this blog’s layout so click on the continue reading link below to read the full article and to see the video.

Continue reading

Block all traffic from a Geo-located country with UFW firewall on Ubuntu

I was noticing some really strange requests in my web server’s log files on a VPS that I manage. Requests that seem to be focused on finding vulnerabilities or exploits. Turns out most of the originating IP addresses are from China. Since the VPS is not behind a router or otherwise managed firewall device, I decided to investigate if I could just block all traffic from China to my VPS. Turns out the software “Uncomplicated Firewall” or better know as UFW, that I already had running can do this easily. If you’re new to UFW have a look at this very comprehensive page showing how to set it up.

Here are two examples showing how to setup your UFW firewall to block IP addresses or ports based on Geo location. This should work on any system running UFW but in this case I did it on a headless Ubuntu 18.04 system. Click on Read more to view the rest of this article.

Continue reading

How to setup Nginx+RTMP live stream server

IMPORTANT UPDATE! These guides may be outdated. Please see the new guide here:
https://www.ustoopia.nl/featured/nginx-rtmp-hls-ssl-videojs-on-ubuntu-18-04/

I made a couple of Youtube video’s with some instructions on how to setup your own private live-stream server using Nginx running on Ubuntu 18.04. . Click on the CONTINUE READING link below to see a copy of the variables that I used in the video’s. You can also find it on my Pastebin if you prefer.

Continue reading

Install MariaDB 10.1 on Ubuntu16.04

I have Ubuntu16.04 servers running and I want to run database engines like MariaDB on it. Normally I would just type sudo apt install mariadb-server and the database system would be up and running in under two minutes. Ubuntu16.04 will install version 10.0 by default, but I want to install a different version. At the very least 10.1. Why 10.1 you might ask? Well because 10.1 was the first release that had Galera included by default in the package. Galera is a gift from the gods for all system administrators, developers, backup operators and other people who work with databases a lot. With three nodes, the minimum, it will offer you fast and reliable database synchronization and redundancy. Galera is a solid foundation for an easy to build load balancing environment. But first of we will install the MariaDB 10.1 instance on a clean Ubuntu16.04 server. If you want to be absolutely certain that the instructions below will work flawlessly for you, I would advise to use a clean fresh installed server also. Please remember that upgrading (or downgrading) from a different release version is NOT a good idea. When I was learning this the hard way I did a lot of reading on the subject and I can safely say that you should not follow these instructions on a system that runs, or used to run a MariaDB or MySQL instance. Even if you have removed it first apt remove you are still at risk of running into problems. When I was having problems with this I tried many things that included killing the process: kill -9 $(pgrep mysql)  and then purging the removed packages apt purge and also apt autoremove and I even had to delete some left-over files manually. Don’t even try to install it on a system that ran a higher version > 10.1 because that will be guaranteed imminent failure. You’ve been warned! Let’s get started and install some required software and updates.

sudo apt update && sudo apt upgrade
sudo apt-get install nano ssh openssh-server software-properties-common rsync

To see the rest of this article please click on the read more link.

Continue reading

Unattended Ubuntu ISO Maker

Just found an awesome script online that I tested today and it works great. It’s a script that allows you to create an ISO for a unattended installation for Ubuntu 16.04.3 LTS. Just made myself one of those ISO’s and I’m going to try to see if I can implement it in my PXE environment. If not, I can always place it on a USB flash drive and boot from that. This makes the life of a person who tends to install Ubuntu very often (either on a virtual or a physical machine) a whole lot easier and it’s time-saving. All you need for this script to work is a running Ubuntu system (I used VMware Workstation to create a fresh net-install, and I assume that VMware Player also works) and the script itself of course. The scripts and the really easy to follow instructions are all the github page right here. Took me approx 15 minutes to install a fresh Ubuntu server, follow the instructions, and the actual creation of the ISO. Give the author a star for his efforts cause he deserves it.

Adding cloud storage as permanent mount to Ubuntu Server 16.04

Many cloud storage services give you the option to mount your online storage as an extra drive on your operating system. This can be done really easy on any operating system that runs a desktop environment. But I wanted to add my storage as a mounted drive on Ubuntu Server, and it does not use a desktop environment so I use WinSCP and Putty to administrate my server.
I did some research on how to mount my cloud storage I use at Stackstorage. In my account info on their website they showed me that the address I have to use for WebDAV should be . This was all the information I needed to get started. Here’s a step by step guide how I did this that you can follow but keep in mind that some commands should be different depending on what cloud storage provider you are using. Click on READ MORE to read the full article.

Continue reading

Disable IPv6 on Ubuntu 16.04 Permanently

If you want IPv6 disabled permanently on a Ubuntu 16.04 system, here’s a good way to do it. Disabling it like this should keep it disabled permanently, even after performing updates that could potentially enable it again without you knowing it. I haven’t tested it so I’m not 100% certain but if you decide to upgrade Ubuntu to 16.10 or the most recent version, it should still have ipv6 disabled after upgrading. Now let’s get to it! Simply enter the following commands in your console:

sudo echo "net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee /etc/sysctl.d/99-my-disable-ipv6.conf
sudo service procps reload
ifconfig

The ifconfig should not show any ipv6 address. A reboot is not required, but it won’t hurt either.

 

How to install MP4Box on Ubuntu 16.04 Headless

MP4Box is a multimedia packager, with a vast number of functionalities: conversion, splitting, hinting, dumping and others. It can be used for performing many manipulations on multimedia files like AVI, MPG, TS, but mostly on ISO media files (e.g. MP4, 3GP). It is a command-line tool so it can be utilized by scripts like the php script that I want to use. MP4Box is included in the GPAC package.”

I want to be able to use a certain media hosting package but during installation it tells me that it will require MP4Box to continue. I tried installing it regularly (apt-get install mp4box) but that didn’t work. After doing a bit of research I decided to build MP4Box from scratch so that means compiling the source and here’s how I did that.

Continue reading