How to Install Webmin on Ubuntu 20.04 Server

Webmin is a free and open-source control panel for administering Unix/Linux servers. This tutorial will be showing you how to install Webmin on Ubuntu 20.04 server.

This tutorial also works on Ubuntu 20.10.

Install Webmin on Ubuntu 20.04 Server

Webmin provides users with a graphical web-based user interface to configure common system tasks and settings. If you don’t like the idea of using the command line to manage your server, then Webmin is a good graphical alternative for you. The following is a list of functionalities provided by Webmin.

Install Webmin on Ubuntu 20.04 From Webmin Repository

Webmin has been around since 1997. At the time of this writing, the latest stable version available is 1.970, which was released on January 6, 2021. Webmin isn’t in Ubuntu software repository. It’s recommended to install Webmin from its official repository so that you can always get the latest version.

To add Webmin repository, create a source list file with a command-line text editor such as Nano.

sudo nano /etc/apt/sources.list.d/webmin.list

Add the following line in the file.

deb http://download.webmin.com/download/repository sarge contrib

webmin-ubuntu-20.04

Save and close the file. To save the file in Nano text editor, press CTRL+O, then press Enter to confirm. To close the file, press CTRL+X . Next, we need to run the following command to download and import Webmin PGP signing key to APT keyring so that the APT package manager can verify the integrity of packages downloaded from Webmin repository.

wget http://www.webmin.com/jcameron-key.asc

Then import it with:

sudo apt-key add jcameron-key.asc

Now we can update local package index and install Webmin.

sudo apt update

sudo apt install webmin -y

Once installed, the Wemin built-in web server will automatically start as can be seen by running the systemctl command below:

systemctl status webmin

Output:

install webmin on ubuntu 20.04

Hint: If the above command doesn’t quit immediately, you can press the Q key to gain back control of the terminal.

If it’s not running, you can start it with:

sudo systemctl start webmin

Webmin server listens on port 10000. If you use a firewall like UFW on your server, then you need to open TCP port 10000.

sudo ufw allow 10000/tcp

Now you can access the web-based control panel via

https://your-server-ip:10000

Because it’s running in HTTPS mode and using a self-signed TLS certificate, so you will be told by the browser that the connection is not secure.

webmin ssl mode

But you know this is your own server, so simply click the Advanced tab in Firefox and add exception. If you are using Google Chrome, you can click Advanced -> Proceed.

Now you will be presented with Webmin login screen. You can use root or any user accounts in the sudo group on your Ubuntu 20.04 system to login.

webmin ubuntu install

If you don’t like the default color on the navigation menu, you can change it to a different color by clicking the theme configuration icon on the bottom of the navigation menu,

webmin theme configuration

then select navigation menu options and set the color palette. For example, I selected Midnight blue.

webmin navigation menu color

Save the change.

Setting Up Reverse Proxy

If you install Webmin on a production server, you might want to set up reverse proxy with Apache or Nginx so that you can use a domain name to access the Webmin interface without specifying the port number (10000). This also allows you to obtain and install a valid Let’s Encrypt TLS certificate for Webmin.

If you don’t have a real domain name, I recommend going to NameCheap to buy one. The price is low and they give whois privacy protection free for life.

Apache

If you prefer to use Apache web server, then follow the instructions below to set up reverse proxy.

Install Apache web server.

sudo apt install apache2

To use Apache as a reverse proxy, we need to enable the proxy, proxy_http and rewrite module.

sudo a2enmod proxy proxy_http rewrite

Then create a virtual host file for Webmin.

sudo nano /etc/apache2/sites-available/webmin.conf

Add the following texts into the file. Replace webmin.your-domain.com with your actual domain name and don’t forget to create DNS A record for it.

<VirtualHost *:80>
    ServerName webmin.your-domain.com

    ProxyPass / http://127.0.0.1:10000/
    ProxyPassReverse / http://127.0.0.1:10000/

    ErrorLog ${APACHE_LOG_DIR}/webmin.error.log
    CustomLog ${APACHE_LOG_DIR}/webmin.access.log combined
</VirtualHost>

Save and close the file. Then enable this virtual host.

sudo a2ensite webmin.conf

Reload Apache for the changes to take effect.

sudo systemctl reload apache2

Now you can remotely access Webmin by entering the domain name (webmin.your-domain.com ) in browser address bar.

Nginx

If you prefer to use Nginx web server, then follow the instructions below to set up reverse proxy.

Install Nginx on Ubuntu.

sudo apt install nginx

Start Nginx web server.

sudo systemctl start nginx

Then create a new server block file in /etc/nginx/conf.d/ directory.

sudo nano /etc/nginx/conf.d/webmin.conf

Paste the following text into the file. Replace webmin.your-domain.com with your preferred domain name and don’t forget to create DNS A record for it.

server {
       listen 80;
       listen [::]:80;
       server_name webmin.your-domain.com;

       access_log /var/log/nginx/webmin.access;
       error_log /var/log/nginx/webmin.error;

       location / {
              proxy_pass http://127.0.0.1:10000;
              #proxy_set_header Host $http_host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Forwarded-Proto $scheme;
        }
}

Save and close the file. Then test Nginx configuration.

sudo nginx -t

If the test is successful, reload Nginx.

sudo systemctl reload nginx

Now you can access Webmin Web interface via webmin.your-domain.com.

Enable HTTPS

To encrypt the HTTP traffic when you visit Webmin web interface, we can enable HTTPS by installing a free TLS certificate issued from Let’s Encrypt. Run the following command to install Let’s Encrypt client (certbot) on Ubuntu.

sudo apt install certbot

If you use Apache, then you need to install the Certbot Apache plugin.

sudo apt install python3-certbot-apache

Next, run the following command to obtain and install TLS certificate.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d webmin.your-domain.com

If you use Nginx, then you need to install the Certbot Nginx plugin.

sudo apt install python3-certbot-nginx

Next, run the following command to obtain and install TLS certificate.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d webmin.your-domain.com

Where:

  • --apache: Use the Apache plugin.
  • --nginx: Use the nginx plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.

The certificate should now be obtained and automatically installed. And you will be able to access Webmin web interface over a secure HTTPS connection.

webmin ssl certificate

Disable HTTPS Mode in Webmin

Now that TLS connection is terminated at Apache/Nginx, we need to disable HTTPS mode in the Webmin’s built-in web server. Edit the Webmin configuration file.

sudo nano /etc/webmin/miniserv.conf

Find the following line.

ssl=1

Change it to the following to disable HTTPS mode in Webmin.

ssl=0

We can also add the following line in this file so that the built-in web server only allows access from localhost. Visitors using the http://public-ip:10000 scheme will be forbidden.

allow=127.0.0.1

Save and close the file. Then restart Webmin.

sudo systemctl restart webmin

Add Trusted Referrers

Because Webmin itself is running in HTTP mode and we enabled HTTPS in Apache/Nginx, Webmin will think that https://webmin.your-domain.com is outside the Webmin server. So we need to add trusted referrers.

Edit the Webmin config file.

sudo nano /etc/webmin/config

Add the following line at the end.

referers=webmin.your-domain.com

Save and close the file. Then restart Webmin.

sudo systemctl restart webmin

Troubleshooting

If you see any errors, you can check the Webmin error log (/var/webmin/miniserv.error) to troubleshoot.

Apache Error #1

If you use Apache, check the Apache virtual host files under /etc/apache2/sites-enabled/ directory. Make sure there’s no files using

<VirtualHost example.com:80>

They should use the following format.

<VirtualHost *:80>

Apache Error #2

<VirtualHost *:80> is used for plain HTTP virtual host and <VirtualHost *:443> is used for SSL virtual host. If you use port 443 for a plain HTTP virtual host, then it might produce the “SSL_ERROR_RX_RECORD_TOO_LONG” in your web browser.

SSL_ERROR_RX_RECORD_TOO_LONG

Wrapping Up

I hope this tutorial helped you install Webmin on Ubuntu 20.04. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂

Rate this tutorial
[Total: 7 Average: 4.9]

12 Responses to “How to Install Webmin on Ubuntu 20.04 Server

  • Emigdio Lopez
    3 years ago

    Great post!. Thank you!

  • It amazing for system administrator if you can make the tutorial of all function in webmin is good

  • This is awesome! I had no idea this even existed. You guys are doing a great job of spreading the joy of Linux around. We appreciate you!

  • i try to follow the steep by steep but when i try to config sudo nano /etc/nginx/conf.d/webmin.conf and i replace it but i can’t run on a browser like webmin.mydomain.com

  • Works great, however not sure how to fix one issue.

    When i successfully log in first time browser routes to https://server.example.com:10000 with the port appended. But when i refresh browser it’s removed and works fine.

    System is Ubuntu 20.04 w NGINX, and HTTPS certs installed successfully.

    • Xiao Guoan (Admin)
      3 years ago

      Comment out the following line in /etc/nginx/conf.d/webmin.conf file.

      proxy_set_header Host $http_host

      Then reload Nginx.

  • Great quality tutorial as ever, please will appreciate a tutorial on Adminer (Setting Up Reverse Proxy using Nginx).

    Thanks you so much.

  • Dear Xiao Guoan,

    Thank you very much , you write very well and I learn many thing from you .

    Kind regards
    Davoud

  • Dear Xiao Guoan,

    Congrats for this great tutorial. Really helpfull indeed !

    Thanks a lot.

    Freddy

  • Hullio GQ
    3 years ago

    Great tutorial as usual. Will the reverse proxy work with Virtualmin as well? I’d like to block port 10000 on a CentOS server.

  • may you make the tutorial about the cockpit?

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here