Table of Contents
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

How to Build an Example Vultr Marketplace Application

Last Updated: Tue, May 25, 2021
Vultr Marketplace


This tutorial walks through the Vultr Marketplace build process to illustrate the critical points of a Vultr Marketplace application. The completed application uses Marketplace variables to generate unique Nginx and MariaDB passwords for each deployment.

Create an Application Profile

Follow these steps to create your vendor account and application profile.

  1. Edit your vendor settings.
  2. Create a new application profile.
  3. Edit the general information.
  4. Edit the support information.

Publish the Application Instructions

  1. When a customer deploys your application, the Marketplace provides them with the IP address and root password. In addition to these values, you can create custom application variables. For this tutorial, please create the variables db_pass and web_pass. See our guide Vultr Marketplace Application Variables for more details.
  2. Next, publish the instructions for the customer deployment page, and include your application variables. See our guide Vultr Marketplace Application Instructions for details.
  3. Add your application's gallery images. Your public landing page uses these images to showcase your application.

Build the Application

Now that the application profile and variables are defined, it's time to create the actual application.

Deploy a Server

  1. First, deploy a small Ubuntu server.

    • Select Ubuntu 20.04 as the operating system.
    • Choose a small 10 GB SSD subscription. The Marketplace can expand your snapshot onto a larger server, but it cannot shrink your snapshot. Choose the smallest server possible for your app.

    There's no need to add IPv6, SSH key, or other features because customers can add those when they deploy the finished Marketplace app.

  2. Choose a hostname. The name isn't critical; it will be reset by cloud-init when the customer deploys your finished app.

  3. Click Deploy Now to launch your prototype server.

After deployment finishes, SSH to the server as root and update the server.

Configure the Provisioning Scripts

  1. Install the Marketplace required software.
  2. Create the cloud-init per-instance script directory.

    # mkdir -p /var/lib/cloud/scripts/per-instance/
  3. Create a provisioning script for cloud-init.

    # nano /var/lib/cloud/scripts/per-instance/

    Paste the following to

    ## Report the deployment to a logfile.
    echo $(date -u) ": System provisioning started." >> /var/log/per-instance.log
    ## Capture the Marketplace Password Variables.
    DB_PASS=$(curl -H "METADATA-TOKEN: vultr"
    WEB_PASS=$(curl -H "METADATA-TOKEN: vultr"
    ## Create an example database.
    mysql -u root -e "CREATE DATABASE example_db;";
    ## Create an example user and set the password to Marketplace Password Variable $DB_PASS.
    mysql -u root -e "GRANT ALL ON example_db.* TO 'example_user'@'localhost' IDENTIFIED BY '$DB_PASS' WITH GRANT OPTION;";
    ## Create a username/password for Nginx with the Marketplace Password Variable $WEB_PASS.
    htpasswd -cb /etc/nginx/.htpasswd example_user $WEB_PASS
    ## Report the to a logfile.
    echo $(date -u) ": System provisioning script is complete." >> /var/log/per-instance.log

    Make the script executable.

    # chmod +x /var/lib/cloud/scripts/per-instance/

This script executes when the customer deploys the server. It runs only one time; it will not run at each reboot. When the script runs, it:

  • Logs the start date/time.
  • Captures the marketplace variables db_pass and web_pass.
  • Creates a database.
  • Adds example_user to the database with the db_pass password.
  • Creates an Nginx password for example_user with the web_pass password.
  • Logs the end date/time.

Notice the lines that capture the Marketplace Password Variables. They use curl to retrieve variables you'll define later in this guide. The URL endpoint names are based on the variable names you defined earlier in the format:{variable_name}

For example, you'll retrieve a variable named web_pass at this endpoint:

See our guide to learn more about Vultr Marketplace Variables and provisioning scripts.

Install Nginx and MariaDB

  1. Install Nginx, MariaDB, and the htpassword utility, which is a part of apache2-utils.

    # apt install -y nginx mariadb-server apache2-utils
  2. Configure Nginx with basic authentication. Edit /etc/nginx/sites-enabled/default

    # nano /etc/nginx/sites-enabled/default

    Locate this section:

    server_name _;
    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;

    Add the two auth_basic lines, so it looks like this:

    server_name _;
    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
  3. Save and exit the file.

    There's no need to create the /etc/nginx/.htpasswd file now. The provisioning script populates it with the generated value of web_pass when the app is deployed.

Assign the Live Image

Now it's time to prepare the system and take a snapshot. After the snapshot is ready, assign the snapshot as the live image.

Test the Application

Your application is ready to make public, but you should test it before the final publication step.

  1. Deploy your Marketplace application from the Marketplace Builds tab. Use the Deploy Image option.

    Screenshot of deploy image menu

    You'll be directed to the server deployment page of the Vultr customer portal, and your Marketplace image is automatically selected as the Server Type.

  2. After the app deploys, SSH to the instance as root. You'll find the root password on the server information page.

  3. Check the cloud-init provision script log. You should see entries with a recent date and time.

    # cat  /var/log/per-instance.log
    Mon 22 Mar 2021 07:46:04 PM UTC : System provisioning started.
    Mon 22 Mar 2021 07:46:04 PM UTC : System provisioning script is complete.
  4. Verify the Nginx password file exists, and the provisioning script created a password hash.

    # cat /etc/nginx/.htpasswd
  5. Look up the website password on the server information page.

  6. Navigate to the website. The website will prompt you for a username and password. Enter the username example_user and the webserver basic authentication password shown on the server information page.

  7. Log into the database as example_user with the database password shown on the server information page.

    # mysql -u example_user -p
  8. Show the database list and verify the example_db exists.

    MariaDB [(none)]> SHOW DATABASES;
    | Database           |
    | example_db         |
    | information_schema |
    2 rows in set (0.000 sec)


If you can complete the tests, you are ready to publish the application. See the Vultr Marketplace Publication Settings guide to set your URL slug and mark the application public.

More Information

This guide is part of the Vultr Marketplace documentation. Please see the documentation overview for more information.

Want to contribute?

You could earn up to $300 by adding new articles