Self-hosted Sharetribe Go Community Edition on Ubuntu - II

Sangram RathSangram Rath
2 min read

This article is a continuation of Part 1 of this article here. In this article we will cover the following aspects of the self-hosted installation in production:

  • Changing the domain (optional)

  • Securing the installation using SSL/TLS

Changing the marketplace domain

Changing your marketplace URL to a top domain e.g. something like example.com instead of buynsell.example.com requires connecting to the database and making a few changes in the production database. This step is not required if you wish to continue using the subdomain.

Before continuing ensure the IP of the VM/VPS/Server points to the domain i.e. example.com.

Start by stopping the rails server (press Cntrl + C).

In the following steps you are doing the following: Login to MySQL, then switch to the production database i.e. sharetribe_production. Next, you will run two UPDATE commands that will set the domain and force the use of this domain. You will finally exit MySQL.

  •   # Login to MySQL
      mysql -uroot -p
    
  •   # Select the production database
      use sharetribe_production;
    
  •   # Update the communities.domain value
      UPDATE communities SET domain="example.com";
    
  •   # Update the communities.use_domain boolean value
      UPDATE communities SET use_domain="1";
    
  •   # Exit out of MySQL
      exit
    

Restart the rails server

bundle exec rails server -e production

You can now access the marketplace with the domain i.e. example.com.

Secure Sharetribe with SSL/TLS

A production instance must be secure using an SSL/TLS certificate. While there are many ways of doing this, we will use certbot to quickly and automatically assign our marketplace a certificate.

Before continuing make sure you have decided whether to use a subdomain or the domain for the URL. The certificate will be issued based on what's provided as the domain. Also, ensure port 443 is allowed in your OS & platform firewall settings.

Install certbot

We will install certbot using Snap, which is a packaging and deployment tool by Canonical. Read more about it here if interested. Snap is usually pre-installed on Ubuntu systems from 16.04 and later.

Start by updating snap.

sudo snap install core; sudo snap refresh core

Next, install certbot using snap.

sudo snap install --classic certbot

Get a certificate for your domain/subdomain

Run the following command which gets a certificate for your domain i.e. either buynsell.example.com or example.com and also configures NGINX.

This will prompt for your email address (provide a valid one) and ask you to agree to Terms of Service (must enter Y)and your consent to share your email with EFF (optional).

sudo certbot --nginx -d buynsell.example.com

Access your marketplace which now should redirect to HTTPS.

0
Subscribe to my newsletter

Read articles from Sangram Rath directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sangram Rath
Sangram Rath