Installing Webmin and Virtualmin behind NGINX on Ubuntu LTS

Webmin provides you with a web-based panel to manage your server directly. You can change common packages on the fly, modify files and manage users and groups.

We will be installing Webmin, Virtualmin, and Cloudmin behind NGINX as a reverse-proxy.

Things you will need:

  • A fresh Ubuntu 16.04 or 18.04 server, with a sudo non-root user.
  • A basic firewall using UFW or IPTables.
  • A Fully-Qualified Domain Name or (FQDN) setup with a DNS A Record point to your fresh server.
  • Certbot or Let’s Encrypt SSL Certificate OR your own SSL Certificate (or a cloudflare origin certificate)

Let’s get started.
Step 1 - Installing Webmin
First, we need to add the Webmin repository to easily install and update Webmin with the apt package manager. We can echo this package into our source list directory by running

echo "deb http://download.webmin.com/download/repository sarge contrib" >> /etc/apt/sources.list.d/webmin.list

If at any time you wish to remove this repository, you can remove /etc/apt/sources.list.d/webmin.list

We then need to add Webmin’s PGP key so that we can download from this repository. We can do so as follows.

sudo apt install gnupg2 # Allows us to install our key file.
wget http://www.webmin.com/jcameron-key.asc #Downloads our key file.
sudo apt-key add jcameron-key.asc # Installs our key file.

We can now update our list of packages to include our new repository and install Webmin:

sudo apt update #Update our packages.
sudo apt install webmin #Install our webmin package.

Shortly after installing we will receive a message:

Webmin install complete. You can now login to https://your_public_ip:10000/
as root with your root password, or as any user who can use sudo
to run commands as root.

Webmin is now installed.

Step 3 - Installing Virtualmin
To my knowledge, Virtualmin only supports Ubuntu LTS versions and it will fail to install if you are not on a LTS version. Correct me if I am wrong.

Installing Virtualmin will enable you to manage DNS, user accounts and apache2 virtual hosts (but we’re using nginx).

We can start by downloading virtualmin’s install script and installing it.
Be prepared to enter your domain name. This script will install the LEMP package bundle.
If you wish to use Apache over NGINX, you can change LEMP to LAMP in the install command

wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh #Makes our file executable.
#You can inspect your install file with nano install.sh if you do not trust its contents.
sudo ./install.sh --bundle LEMP #Installs virtualmin with NGINX in mind

If you wish to uninstall any of the packages installed by the installer, you can use this command to uninstall it but it will be destructive. Read the warning before continuing.

sudo ./install.sh --uninstall

You will be asked to continue the script after reading the warning, you can answer Y (yes) or N (no).
After some time you will be greeted with a message:

[SUCCESS] Installation Complete!
[SUCCESS] If there were no errors above, Virtualmin should be ready
[SUCCESS] to configure at https://yourdomain:10000 (or https://your_public_ip:10000).
[SUCCESS] You'll receive a security warning in your browser on your first visit.

Upon visiting the page to configure, you will be greeted by the wizard.


You can select “Next” to continue this wizard.
You will be offered a list of suggestions on setting to use. By default the recommended settings are pre-filled in for you. You can hit “Next” until you reach the Password Storage screen, it is up to you if you want to store passwords in a hashed format or plain-text.
After the install you will be greeted with a message confirming the install. You are now done installing Virtualmin.

If you already have another email provider, you can disable clamav-daemon with:

sudo /etc/init.d/clamav-daemon stop
systemctl disable clamav-daemon

Step 3 - Install PHP 7.3 and required dependencies
It’s a good idea to install the latest php, so we are going to do that here.
We’re going to install software-properties-common to provide a abstraction of the used apt repositories. It allows you to easily manage your distribution and independent software vendor software sources.

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php #You will have to press ENTER to accept the changes.
sudo apt update
sudo apt install php7.3-cgi php7.3-mysql php7.3-curl php7.3-gd php7.3-imap php7.3-tidy php7.3-xmlrpc  php7.3-xsl  php7.3-mbstring php7.3-zip php7.3-cli php7.3-fpm

Step 4 - Configure NGINX

We’re gonna have to configure NGINX ourselves, but never fear as I have already written a configuration for this.
You will need to change all instances of your.domain.name with your domain you own.

cd /etc/nginx/sites-available #Site Directory
wget https://gist.githubusercontent.com/Kashalls/42549ffe3055daae5b83d67369164660/raw/5718b27117e0f6ca528089fa0d281630674c7231/webmin.conf
nano webmin.conf #Change all instances of the domain now. To exit, use CTRL + X and answering Y to save file.
ln -s /etc/nginx/sites-available/webmin.conf /etc/nginx/sites-enabled/webmin.conf #Creates a symbolic soft link.
sudo service nginx restart

Step 5 - Install Certbot
We need SSL to secure our panel, so we will do that here.

sudo add-apt-repository ppa:certbot/certbot #Add new PPA.
sudo apt update #Check for updates
sudo apt install certbot python-certbot-nginx -y #Install Certbot Script To Automate Certificates.

We can have certbot get and install a certificate by running this simple command

sudo certbot --nginx

If your configuration is detected you see something along the lines of this:

Options entered were no input then ENTER then setting up a redirect.

Congrats, your webmin panel is available by your domain name!