Step 4: Configure Nginx using Ajenti

Warning

We saw how to configure an Nginx site using the command line. Now, you will create and enable an Nginx site using a GUI. We became aware of this method from a blog post called The Perfect Reverse Proxy (NGINX, SSL, WebUI Management).

You can try to install Ajenti if you are interested in trying this method.

Note: These instructions use example.com. Use your own domain name.

For this step:

  • We will create a new sub-domain name for our service called cloud.example.com.

    • Refer to the previous lab for specific instructions.

  • We will configure Nginx to watch for cloud.example.com and then direct that traffic to localhost:20850.

Installing Ajenti

Note

Installing and using Ajenti is not required.

You can manage Nginx and your server without the need of a web administration panel. However, it is an easier option for those who struggle with modifying configurations using a command line tool or forget the syntax for ln.

Unfortunately, we removed the instructions for installing Ajenti because the installer did not work reliably on all VPSs.

Using Ajenti

  1. Navigate to your IP address and port that you used when you set up Ajenti.

  2. Enter your username (root) and your password.

    ../../_images/ajenti1.png
  3. The dashboard shows information about your VPS.

    • Add more widgets, such as Disk space or traffic

    • Drag the widgets to organize them

    • Remove widgets, such as Welcome to Ajenti or Swap usage

    ../../_images/ajenti2.png

Configure Nginx Using Ajenti

  1. Click the Nginx icon in the left menu, under the group Software.

    • You will see a list of the available sites.

    • A checked box indicates the site is enabled.

    ../../_images/ajenti3.png
  2. Click on Add to create a new empty site.

  3. Open the site by clicking on untitled

    ../../_images/ajenti4.png
  4. Configure and save your site

    • Call your site cloud.example.com

    • Click the checkbox to enable the config

    • Add the config. Don’t forget to modify server_name.

    • Click the save button to save your config

    File Contents
    server {
        listen 80;
    
        server_name cloud.example.com;
    
        location / {
            proxy_pass http://localhost:20850;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    
    ../../_images/ajenti5.png
  5. Restart Nginx

    • Click the Restart button to apply the config

    • Note. We did not test this config. We do not know if Nginx restarted successfully.

    ../../_images/ajenti6.png
  6. You can run a command using Ajenti to verify the config. The process is a bit slow, but it works

    • Click on Terminal in the menu. It under Tools.

    • Click the + New button to start a new terminal, then click on the terminal icon to open it.

    • Enter command nginx -t once the terminal initializes

    ../../_images/ajenti7.png
  7. Verify that it works by opening the URL in your browser

  8. Install an SSL cert from Let’s Encrypt using certbot so you can access your Nextcloud site through a secure connection.

Disable a Site

  1. You can disable the site in the future by unchecking the Enable site box.

    • Save and then restart Nginx

    ../../_images/ajenti8.png

    The star (asterisk) means that the config has been modified

    ../../_images/ajenti9.png
  2. Save and restart for the changes to take effect.