Skip to main content
This tutorial will guide you through setting up a production-ready Meilisearch instance on Google Cloud Platform (GCP) using a Compute Engine virtual machine.
Meilisearch Cloud is the recommended way to run Meilisearch in production environments.

Prerequisites

  • A Google Cloud account with billing enabled
  • A Compute Engine VM running Debian 12 or Ubuntu 22.04 LTS
  • An SSH key pair or access via Google Cloud Console SSH
  • Firewall rules allowing inbound traffic on ports 22 (SSH), 80 (HTTP), and 443 (HTTPS)
Google Cloud has extensive documentation on creating VM instances and connecting via SSH.

Step 1: Install Meilisearch

Connect to your VM via SSH (using the Google Cloud Console or gcloud CLI) and update the system:
Download and run the Meilisearch installer:
Move the binary to make it accessible system-wide:

Step 2: Create system user

Create a dedicated user for running Meilisearch:
Give the new user ownership of the Meilisearch binary:

Step 3: Create a configuration file

Create data directories for Meilisearch:
For production workloads, consider attaching a persistent disk for data storage. This allows for easy snapshots and disk resizing independent of the VM.
Download the default configuration file:
Edit /etc/meilisearch.toml and update these settings, replacing MASTER_KEY with a secure 16-byte string:
Remember to choose a safe master key.

Step 4: Run Meilisearch as a service

Create a systemd service file:
Reload systemd, then enable and start the service:
Verify the service is running:

Step 5: Secure and finish your setup

5.1. Configure firewall rules

In the Google Cloud Console, navigate to VPC Network > Firewall and ensure you have rules allowing:
  • Port 22 for SSH access
  • Port 80 for HTTP traffic
  • Port 443 for HTTPS traffic
You can also use gcloud CLI:

5.2. Set up a reverse proxy with Nginx

Install Nginx:
Remove the default configuration and create one for Meilisearch:
Replace your_domain with your actual domain name (or use _ as a catch-all if you don’t have one yet). Restart Nginx:

5.3. Enable HTTPS with Let’s Encrypt

Before enabling HTTPS, ensure you have a domain name pointing to your VM’s external IP address. You can reserve a static IP in Google Cloud Console under VPC Network > External IP addresses.
Install certbot:
Run certbot to obtain and configure your SSL certificate:
Follow the prompts to enter your email, agree to the Terms of Service, and select your domain. Choose to redirect HTTP traffic to HTTPS when prompted. Verify automatic renewal is configured:

Conclusion

Your Meilisearch instance is now running on Google Cloud with:
  • A dedicated system user for security
  • Automatic restart via systemd
  • Nginx reverse proxy
  • HTTPS encryption via Let’s Encrypt
For high-availability setups, consider using a managed instance group with a Cloud Load Balancer.