Skip to content

Instantly share code, notes, and snippets.

@keilmillerjr
Last active October 21, 2020 08:20
Show Gist options
  • Select an option

  • Save keilmillerjr/eb54fbfa846f29e303a54cf6a13cbe5e to your computer and use it in GitHub Desktop.

Select an option

Save keilmillerjr/eb54fbfa846f29e303a54cf6a13cbe5e to your computer and use it in GitHub Desktop.

Revisions

  1. keilmillerjr revised this gist Oct 21, 2020. 1 changed file with 14 additions and 14 deletions.
    28 changes: 14 additions & 14 deletions Create_Remote_UniFi_SDN_Controller.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ Directions are loose. Follow on screen directions appropriately.
    3. Copy public key results
    4. Add SSH Key from local computer
    1. Label > `id_rsa`
    2. SSH Public Key > <paste public key results>
    2. SSH Public Key > `<paste public key results>`
    5. Create

    ## SSH into your Linode
    @@ -54,17 +54,17 @@ The default port for UniFi is 8443. You can use a web broser and navigate to `ht

    #### Add Domain

    1. https://cloud.linode.com/domains > Add a Domain
    1. [https://cloud.linode.com/domains](https://cloud.linode.com/domains) > Add a Domain
    2. Select Master
    3. Domain > <yourdomain.com>
    4. SOA Email Address > <youremail@mail.com>
    3. Domain > `<yourdomain.com>`
    4. SOA Email Address > `<youremail@mail.com>`
    5. Insert Default Records > Insert default records from one of my Linodes.
    6. Linode > <your linode>
    6. Linode > `<your linode>`
    7. Create

    #### Edit Domain

    1. https://cloud.linode.com/domains > Edit DNS Records
    1. [https://cloud.linode.com/domains](https://cloud.linode.com/domains) > Edit DNS Records
    2. Remove instances of mail server. They are not needed for unifi.


    @@ -166,20 +166,20 @@ The Discover Device feature is only compatible with the Chrome web browser.
    3. Toggle Discover Device ON.
    * Install Ubiquiti Device Discovery Tool Extension when prompted.
    4. Click Adopt on device row.
    5. Controller > <your controller>
    5. Controller > `<your controller>`
    6. Adopt

    Device will be adopted to the default site of your controller.

    1. Launch your controller
    * [UniFi Network Portal](https://network.unifi.ui.com/#/controllers/) Controllers > <your controller> > launch
    * https://mydomain.com
    * 192.168.1.1:8443
    * [UniFi Network Portal](https://network.unifi.ui.com/#/controllers/) Controllers > `<your controller>` > launch
    * `https://mydomain.com`
    * `192.168.1.1:8443`
    2. Create a new site
    1. Current Site > Add new site > <your site> > submit
    1. Current Site > Add new site > `<your site>` > submit
    2. Settings > WiFi Networks Create New Wireless Network
    4. Move device to your site
    1. Current Site > Default
    2. Devices > <device> > Config > Manage Device > Move this device to > <your site> > confirm
    3. Current Site > <your site>
    4. Devices > <device>
    2. Devices > `<device>` > Config > Manage Device > Move this device to > `<your site>` > confirm
    3. Current Site > `<your site>`
    4. Devices > `<device>`
  2. keilmillerjr revised this gist Oct 21, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Create_Remote_UniFi_SDN_Controller.md
    Original file line number Diff line number Diff line change
    @@ -173,7 +173,7 @@ Device will be adopted to the default site of your controller.

    1. Launch your controller
    * [UniFi Network Portal](https://network.unifi.ui.com/#/controllers/) Controllers > <your controller> > launch
    * <my domain>
    * https://mydomain.com
    * 192.168.1.1:8443
    2. Create a new site
    1. Current Site > Add new site > <your site> > submit
  3. keilmillerjr revised this gist Oct 21, 2020. 1 changed file with 27 additions and 0 deletions.
    27 changes: 27 additions & 0 deletions Create_Remote_UniFi_SDN_Controller.md
    Original file line number Diff line number Diff line change
    @@ -156,3 +156,30 @@ $ sudo systemctl restart nginx
    ```

    You should now be able to browse to `https://mydomain.com` and see the UniFi SDM Controller login page.

    ## Adopt A Device

    The Discover Device feature is only compatible with the Chrome web browser.

    1. Connect device to a router with internet access. Reset if necessary by holding the reset button for 10 seconds.
    2. [UniFi Network Portal](https://network.unifi.ui.com/#/devices) Devices
    3. Toggle Discover Device ON.
    * Install Ubiquiti Device Discovery Tool Extension when prompted.
    4. Click Adopt on device row.
    5. Controller > <your controller>
    6. Adopt

    Device will be adopted to the default site of your controller.

    1. Launch your controller
    * [UniFi Network Portal](https://network.unifi.ui.com/#/controllers/) Controllers > <your controller> > launch
    * <my domain>
    * 192.168.1.1:8443
    2. Create a new site
    1. Current Site > Add new site > <your site> > submit
    2. Settings > WiFi Networks Create New Wireless Network
    4. Move device to your site
    1. Current Site > Default
    2. Devices > <device> > Config > Manage Device > Move this device to > <your site> > confirm
    3. Current Site > <your site>
    4. Devices > <device>
  4. keilmillerjr revised this gist Oct 21, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Create_Remote_UniFi_SDN_Controller.md
    Original file line number Diff line number Diff line change
    @@ -119,6 +119,8 @@ server {
    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;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass https://192.168.1.1:8443/$request_uri;
    proxy_read_timeout 90;
  5. keilmillerjr revised this gist Oct 21, 2020. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions Create_Remote_UniFi_SDN_Controller.md
    Original file line number Diff line number Diff line change
    @@ -113,9 +113,17 @@ server {
    ssl on;
    ssl_certificate /root/certs/MyCertificate.crt;
    ssl_certificate_key /root/certs/MyKey.key;
    location / {
    proxy_pass https://192.168.1.1:8443/$request_uri;
    proxy_set_header Host $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;
    proxy_pass https://192.168.1.1:8443/$request_uri;
    proxy_read_timeout 90;
    proxy_redirect https://192.168.1.1:8443 https://mydomain.com;
    }
    }
    ```
  6. keilmillerjr revised this gist Oct 21, 2020. 1 changed file with 31 additions and 8 deletions.
    39 changes: 31 additions & 8 deletions Create_Remote_UniFi_SDN_Controller.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ The default port for UniFi is 8443. You can use a web broser and navigate to `ht

    ## Adding a Domain Name

    ### Add Domain
    #### Add Domain

    1. https://cloud.linode.com/domains > Add a Domain
    2. Select Master
    @@ -62,25 +62,35 @@ The default port for UniFi is 8443. You can use a web broser and navigate to `ht
    6. Linode > <your linode>
    7. Create

    ### Edit Domain
    #### Edit Domain

    1. https://cloud.linode.com/domains > Edit DNS Records
    2. Remove instances of mail server. They are not needed for unifi.

    ### Install Nginx

    1. SSH into your Linode as root.
    #### Generate SSL Certificate

    SSH into your Linode as root. Fill out the questionair presented by openssl.

    ```
    $ mkdir /root/certs && cd /root/certs
    $ openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out MyCertificate.crt -keyout MyKey.key
    ```

    #### Install Nginx

    SSH into your Linode as root.

    ```
    $ sudo apt update
    $ sudo apt install nginx
    ```

    ### Configure Nginx
    #### Configure Nginx

    By default on Debian systems, Nginx server blocks configuration files are stored in `/etc/nginx/sites-available` directory, which are enabled through symbolic links to the `/etc/nginx/sites-enabled/` directory.

    SSH into your Linode as root and create a Nginx configuration file.
    SSH into your Linode as root and create a Nginx configuration file. Port 80 is pointed towards port 443 (SSL).

    ```
    $ nano /etc/nginx/sites-available/unifi.conf
    @@ -89,10 +99,23 @@ server {
    listen 80;
    listen [::]:80;
    server_name yourdomain.com;
    server_name mydomain.com www.mydomain.com;
    return 301 https://mydomain.com/$request_uri;
    }
    server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name mydomain.com www.mydomain.com;
    ssl on;
    ssl_certificate /root/certs/MyCertificate.crt;
    ssl_certificate_key /root/certs/MyKey.key;
    location / {
    proxy_pass https://192.168.1.1:8443/;
    proxy_pass https://192.168.1.1:8443/$request_uri;
    }
    }
    ```
  7. keilmillerjr created this gist Oct 21, 2020.
    125 changes: 125 additions & 0 deletions Create_Remote_UniFi_SDN_Controller.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,125 @@
    # Create Remote UniFi SDN Controller

    ## Create A New Linode

    Directions are loose. Follow on screen directions appropriately.

    1. https://cloud.linode.com/linodes > Add a Linode
    2. Choose a Distribution > Images > Debian 10
    3. Generate an SSH Key if not present
    1. `$ ssh-keygen`
    2. `~ cat ~/.ssh/id_rsa.pub`
    3. Copy public key results
    4. Add SSH Key from local computer
    1. Label > `id_rsa`
    2. SSH Public Key > <paste public key results>
    5. Create

    ## SSH into your Linode

    The public IP Address of your linode can be found [here](https://cloud.linode.com/linodes).

    ```
    # Replace IP Address with IP Address of Linode
    $ ssh root@192.168.1.1
    ```

    ## Unifi Installation Script

    [UniFi Installation Scripts | UniFi Easy Update Script | UniFi Let's Encrypt | Ubuntu 16.04, 18.04, 18.10, 19.04, 19.10, 20.04 and 20.10 | Debian 8, 9, 10 and 11](https://community.ui.com/questions/UniFi-Installation-Scripts-or-UniFi-Easy-Update-Script-or-UniFi-Lets-Encrypt-or-Ubuntu-16-04-18-04-/ccbc7530-dd61-40a7-82ec-22b17f027776)

    1. SSH into your Linode as root.

    ```
    $ apt-get update; apt-get install ca-certificates wget -y
    $ rm unifi-latest.sh &> /dev/null; wget https://get.glennr.nl/unifi/install/install_latest/unifi-latest.sh && bash unifi-latest.sh
    ```

    ## Controller Status

    1. SSH into your Linode as root.

    ```
    $ sudo service unifi restart
    $ sudo service unifi status
    $ sudo service unifi start
    $ sudo service unifi stop
    ```

    ## Browse to Controller

    The default port for UniFi is 8443. You can use a web broser and navigate to `https://ip.of.your.server:8443` or `https://mydomain.com:8443`

    ## Adding a Domain Name

    ### Add Domain

    1. https://cloud.linode.com/domains > Add a Domain
    2. Select Master
    3. Domain > <yourdomain.com>
    4. SOA Email Address > <youremail@mail.com>
    5. Insert Default Records > Insert default records from one of my Linodes.
    6. Linode > <your linode>
    7. Create

    ### Edit Domain

    1. https://cloud.linode.com/domains > Edit DNS Records
    2. Remove instances of mail server. They are not needed for unifi.

    ### Install Nginx

    1. SSH into your Linode as root.

    ```
    $ sudo apt update
    $ sudo apt install nginx
    ```

    ### Configure Nginx

    By default on Debian systems, Nginx server blocks configuration files are stored in `/etc/nginx/sites-available` directory, which are enabled through symbolic links to the `/etc/nginx/sites-enabled/` directory.

    SSH into your Linode as root and create a Nginx configuration file.

    ```
    $ nano /etc/nginx/sites-available/unifi.conf
    --------------------
    server {
    listen 80;
    listen [::]:80;
    server_name yourdomain.com;
    location / {
    proxy_pass https://192.168.1.1:8443/;
    }
    }
    ```

    Create a symbolic link.

    ```
    $ ln -s /etc/nginx/sites-available/unifi.conf /etc/nginx/sites-enabled/
    ```

    Test the configuration.

    ```
    $ sudo nginx -t
    ```

    If there are no errors, the output will look like this:

    ```
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    ```

    Restart Nginx.

    ```
    $ sudo systemctl restart nginx
    ```

    You should now be able to browse to `https://mydomain.com` and see the UniFi SDM Controller login page.