How to Create a UniFi Server on AWS in 6 Easy Steps

If you are looking for an alternative to the Ubiquiti Enterprise Unifi service, hosting your UniFi server on AWS is a great alternative. Plus it’s super easy! If you have a VMware ESXi server I have created a virtual appliance that allows you to get up and running quickly too. Don’t have VMware at home? Well then an AWS instance might be great for you, here is how to do it in less than 10 minutes!


Instead of creating a virtual appliance that you could use in AWS, we are going to use the standard Ubuntu 16.04 LTS AMI that AWS created, along with a script that will do all the work for you!

So this tutorial will walk you through how to create an AWS instance that runs a startup script. The rest of the Unifi stuff is all installed on first boot, which means you get the latest and greatest right from the start!

The only thing I won’t go through in this post is how to create an AWS account. There are plenty of great posts out there on how to do that part.

Step 1 – Login to AWS and Start New EC2 Instance Wizard

After logging into the AWS console, click on the EC2 service.

Select “EC2” at the AWS homepage.

Next, make sure you are working in the region you prefer, more than likely you will want to select a region close to you. In this screenshot, you can see that “Oregon” is selected, I would want to change this to “Ohio” since it’s closer to me.

In the top right corner make sure you select the proper region.

Ok, the last thing we need to do on the EC2 page is to click on the “Launch Instance” button to start the EC2 Instance wizard.

Click the Launch Instance button to start the ec2 instance wizard.

Step 2 – Select Instance type and size

Now that we are in the EC2 Instance Wizard we want to select the Ubuntu 16.04 LTS image.

Select the Ubuntu 16.04 LTS AMI Image.

On the next page, we are asked which size of instance we would like. Unifi requirements say 2GB of RAM, and at least 10GB of Hard Drive space, or more depending on how many devices you plan to manage. I would recommend starting with the t2.small, as you can always shut down the machine and make it larger later on.

Select an instance size. T2.Small is the minimum size I would recommend.

After selecting the size you want to, select “Next: Configure Instance Details.”

Step 3 – Config Instance Details and Storage

Ok so on the Instance Details page is where the magic happens. This is the page where we will paste our startup script that installs Unifi.

First, let’s make sure that our instance gets a public IP address, so select Enable. Next, let’s expand the “Advanced” section at the bottom.

Select Enable on Public IP, and then expand the Advanced section at the bottom.

In the Advanced Details section, we need to paste the following script.

sudo apt update
sudo apt upgrade -y
sudo apt-key adv --keyserver --recv 06E85760C0A52C50
sudo add-apt-repository "deb stable ubiquiti"
sudo apt update
sudo apt install unifi -y
sudo apt-get install haveged -y
sudo reboot

It should look something like this when you are done.

Paste in the startup script “as text” and then select “Add Storage”

[stextbox id=’warning’]One tip. Make sure that on line 5 of the script, the one with the quotes, that the last quote on the line matches the one in front of deb. If it doesn’t the script will not run properly.[/stextbox]

On the storage page, change 8GB to 20GB, if you plan to manage more than 50 devices, you may want to add a little more storage as well.

Change 8GB to 10GB

Click the button to continue to the security configuration.

Step 4 – Configure Firewall rules

On the Security page, we will configure the firewall for our instance. We need to allow all the ports that Unifi uses to pass through to the instance. The list of ports required is here, I have copied the chart below we well

Unifi Ports required for firewall

Once you add them all in your security page should look like this, note that I changed the security group name and description as well so it’s easy to understand what it goes to later on:

Completed Security rules page.

Next, click review and Launch.

Step 5 – Launch Instance

On the review page double check the settings then click Launch. Once you do that you will be asked if we want to use an existing key pair, or create a new key pair. If you have not used AWS before it will require you to create a new key pair. Give it a name, then click Download. Once you have downloaded the PEM file, the Launch Instance button will turn blue and you can click to launch your Unifi Controller.

If you don’t already have a key, click Create New and name the key, then download it.

The controller will take approximately 5 minutes to provision and run the boot script. Click on the instance ID on the summary page to go back to the EC2 dashboard and monitor the instances progress.

Click the Instance ID to go to the EC2 Monitoring dashboard

Step 6 – Connect and Configure Unifi

The last step is to figure out what our instance’s IP address is and connect to it so it can be configured.

To find the IP address locate your Unifi Controller instance and click once to highlight it. Now you have two options scroll to the right to see the Public IP column, or look in the lower section and

Two places to find the public IP address for your instance.

Once you have the IP address, you can connect to your new controller by typing https://<your public ip>:8443 in your browser.

You should get a security warning from your browser, for Chrome click Advanced then Proceed to continue past the warning.

Click Advanced and Proceed to pass the security warning page.

Finally, you are at the configure page for your new controller. You can configure it just like any other Unifi Controller.

Unifi Controller ready to configure!

All done!

At this point, you should be able to connect to the Unifi web interface via the IP address that AWS has assigned. Once you do that you can set up your devices to connect to a remote Unifi controller.

Ubiquiti has a great how-to on doing this. Check it out here:

If you found this useful, leave a comment and let me know that you were able to create your controller with these steps… or share the post on social media so someone else can use it too!


Share This Post

10 Responses to "How to Create a UniFi Server on AWS in 6 Easy Steps"

  1. What about running the controller behind a load balancer on AWS? I could see if someone was running it in a docker container in a cluster where that would be beneficial.

  2. Followed steps. Double-checked 8443 port settings. Verified 8443 outgoing opened. Cannot access using https://:8443 ? While aws looks pretty nice, I guess I will try the ova approach.

Post Comment