Alberto Grespan

UniFi Network Controller Install in a Raspberry Pi

— August 31, 2021

Simple and direct instructions on how to install the UniFi Network Controller in a Raspberry Pi. I’ve only tested this in Raspberry Pi OS, but it should also work in Ubuntu.

I’m not going to show how to install Raspberry Pi OS. I assume at this point you have a fresh installation of the OS. See the official website for installation instructions, and remote access to the Raspberry Pi.

Rename hostname

We want to ensure the Raspberry Pi has the correct Hostname. In my case I have dnsmasq in my network and I reach hosts by their hostnames. You can check the following post on domain names for home networks.

sudo hostnamectl set-hostname unifi-controller

Install OpenJDK version 8

We will need OpenJDK version 8 for now. It seems that version 11 also works but I haven’t tested it.

sudo apt install openjdk-8-jre

Install UniFi Network Controller

Install some additional software requirements

sudo apt update && sudo apt install ca-certificates apt-transport-https

Add the Debian repository for the UniFi Network Controller.

echo 'deb stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list

Install the package.

sudo apt install unifi -y

At this point the unifi package installed all of its dependencies and it’s ready to use.

Start UniFi Network Controller

Now that everything is ready we need start the service.

sudo service unifi start

Open your browser and point to <raspberry-pi-IP-address>:8443 and you’ll see the UniFi Network Controller.

Additional steps

These are some additional steps only if you’d like to serve the UniFi Network Controller from nginx. Additional steps include:

Note: additional steps will only work if you have DNS resolution to the IP address of the Raspberry Pi.

mkcert certificate

For the certificate we will use mkcert. mkcert is a simple zero-config tool to make locally trusted development certificates with any names you’d like.

At this point we are assuming that you have dnsmasq or local DNS resolution that will allow you resolve to the IP address of the Raspberry Pi.

Generate the cert.

mkcert ""

With that cert ready we will proceed with the nginx install.

Install nginx

Now we need nginx. Any reverse proxy server will work.

sudo apt install nginx

Set the nginx config

On to the configuration we would like to have custom redirects from HTTP to HTTPS, some proxy headers, and our custom certs.

You can copy the cert from your local computer into the Raspberry Pi using SCP.

scp ~/* [email protected]:/home/pi/

Now for the configuration piece. Create the following code in /etc/nginx/sites-avaliable/unifi

server {
  listen 80;

  return 301 https://$server_name$request_uri;

server {
  # SSL configuration
  listen 443 ssl;


  ssl on;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_certificate /home/pi/;
  ssl_certificate_key /home/pi/;

  location / {
    proxy_pass https://localhost:8443;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_buffering off;

Once you have it. Now link it into the enabled sites.

sudo ln -s /etc/nginx/sites-available/unifi /etc/nginx/sites-enabled/unifi

Restart nginx.

sudo systemctl restart nginx

That’s it. At this point you can open your browser and point to and you’ll see the UniFi Network Controller.