Solution for a unique problem
Having developed guest portal solutions for UniFi networks for many years now, we are happy to announce a solution to a seemingly difficult problem. In the end the solution was quite simple, but it was something that we had put off as there were easy workarounds.
That was ok, until Ubiquiti started to push their new UniFi OS platform, with a focus on the UniFi controller being hosted on site, typically in the form of the UDM or UDM Pro console and the Cloud Key Gen 2 hardware. This strategy is obviously a direction that Ubiquiti will continue to follow, and so we need to continue to make our guest portal solution as seamless as possible within the UniFi ecosystem.
The actual issue in this instance is related to the config file and the UniFi controller url value. The url path typically contains a unique site ID for each site, known as the “siteid” when using parser language. This is used in the controller address where there are multiple sites on a single UniFi controller and it serves as a way to uniquely identify the sites in the data structure
UniFi Guest Portal Solutions
The UniFi controller parameters and the configuration store all the admin site data in the Mongo DB that accompanies the controller software by default. Every controller will start off with only one site, be it either a virtual machine or a cloud key. This one site will always have the siteid value of default.
When further sites are added they get a new unique site identifier, written to to the database and visible in the controller url string, following the site section of the url, like in the example below:
Where the site ID is default, it will be displayed like the example below
Controller Hostname Service
If you do not have a controller hostname set up already, you can use a new service from MyPlace Connect where you can get a hostname with an SSL cert. All you need to do is put a port forward in place on port 443 or port 8443.
If you are using the UniFi Dream Machine (UDM) or Cloud Key Gen 2, then the controller port to use is 443. If you are using any other host then the controller port is 8443
This does not get around the siteID default issue, however if you would like to capture guest email on the UniFi portal then using the controller hostname service with MyPlace is one option
MyPlace has integrated UUID (Universally unique identifier) into is code base to specifically get around this default site ID issue
Other SiteID Default UniFi Workarounds
There are times when having the site ID as default is not going to work for you or your clients. Primarily this becomes an issue when you are utilizing the UniFi API or any other script that engages the controller address via url
The first process is to create a new site within the same controller. Copy the network configuration or settings from the original site to the new site and move all the devices across one by one. It is inconvenient but relatively easy to do.
Once this is done the venue will have a unique siteID and will no longer have the siteid default. The API requests can then use this code as a unique identifier
Another option, is one that requires a lot more work, specifically in the code base of the app that is communicating with the controller. You will need to add in a UUID (Universally unique identifier) or something similar
With the UUID in place the process is much easier from a network perspective and you will not need to switch from a siteid with default to a new unique ID. Creating a new venue in the controller will not be required and the siteid can remain as default
Controller Address Considerations
The controller address, where the site id as default will work fine where there are not multiple sites involved or where you do not need to use the API for any reason. The version of the UniFi controller is not really relevant in regard to the default username issue
Where the UniFi controller version is important, is the more recent file change for the new UniFi OS. Previously the default unifi port for access to the controller was 8443, but with the new data file structure change, the port for UDM and cloud key gen 2 is now 443
This allows clients communicate over https securely in a more user friendly way. The library version would need to be updated for this to work effectively for your sites.
UniFi Controller Password
The UniFi Controller password is passed along with API via https and uses the same method if there is one site on the default id or multiple sites. The password is encrypted, and gets passed along with other details, like the version, username, mac address, firmware version, IP address among others
It is not possible to delete the site that is named as default, and while you can add more sites (version dependent) you can not delete the original default site. This is certainly the case for the default ID in virtual machine install environments.
MyPlace Solution for Site ID
Default File Configuration
UniFi stores user data and site data in a Mongo database (MongoDB) and the database can be access of you have the correct access (password, admin username etc) If you explore the MongoDB you will be able to find where the site is referenced with the default identification
While you will be able to access the file here, it is not advisable to make any changes to it. Each controller version is different the default mode may change in importance from version to version
Default site ID identification summary
This is a recent change from Ubiquiti, and it is very much aligned to their move to the UniFi OS cloud first platform. They are targeting the SMB business client who has a need for networks and camera systems all on one network
They are also providing talk (voip) and door access applications that will also work by default on the UniFi OS platform. The username or profile to access the various apps will be linked back to the main UniFi cloud platform
The user will be able to access various sites through the centralized cloud platform, with the controller being hosted on each site, in the form of a UDM or Cloud key gen2 or whatever version UniFi brings out next
UniFi library and methods are always subject to change and we look forward to seeing what future versions bring