Deployment guide

LibreTranslate

Overview

LibreTranslate is a free, open-source machine translation API that you run entirely inside your own Azure subscription. It is powered by the offline Argos Translate neural models, so it translates text between languages with no third-party service in the loop and no data leaving your virtual machine. It exposes a REST API and a simple web interface.

This SecureAnyCloud image installs LibreTranslate (verified at 1.9.6) into a dedicated Python virtual environment at /opt/libretranslate/venv. It runs CPU-only as the non-root libretranslate service, bound to loopback 127.0.0.1:5000, behind nginx on port 80. nginx is ready for your TLS certificate.

Offline models are built in. The Argos language models for a subset of common languages are pre-installed, so translation works the moment the machine boots, with no download and no GPU. The bundled languages are Arabic, Chinese, English, French, German, Italian, Portuguese, Russian and Spanish. LibreTranslate pivots pairs that have no direct model through English. You can add more languages at any time (see Step 8).

Secure by default, with no open endpoint. An open translation endpoint is a compute abuse risk, so this image enforces API keys. Every translation request requires a key, including requests from the web interface, where you paste the key once.

A libretranslate-firstboot.service oneshot generates a unique API key on each VM's first boot. It writes the key to a root-only file, resolves the instance URL, writes a root-only info note, and then hands off to the service. No two VMs share a key, and none is baked into the image. Request rate and character limits guard against abuse, and LibreTranslate binds only to loopback, so nginx is the single public listener.

What you get:

  • LibreTranslate (verified at 1.9.6) in a dedicated Python virtual environment, CPU-only
  • libretranslate.service bound to 127.0.0.1:5000, behind nginx on port 80, ready for TLS
  • Offline Argos models for 9 common languages, pre-installed for out-of-the-box translation
  • libretranslate-firstboot.service for the first-boot API key, URL resolution and info note
  • A unique per-VM API key generated on first boot and stored in a root-only 0600 file
  • An Ubuntu 24.04 LTS base, patched at build time, with unattended security upgrades enabled
  • 24/7 SecureAnyCloud support, 24h response SLA

Prerequisites

You need an active Azure subscription, an SSH key pair, and a VNet with a subnet.

LibreTranslate runs on CPU alone, and translation throughput scales with CPU and memory. Use Standard_B2s (2 vCPU, 4 GB RAM) for evaluation and light use. Use Standard_D2s_v5, Standard_F4s_v2 or larger for heavier translation volume.

The models live on the OS disk, so expand the disk before you load many additional languages.

1

Deploy from the Azure Portal

Search the Marketplace for LibreTranslate on Ubuntu 24.04 and choose your VM size.

Attach an NSG that allows TCP 22 (SSH) from your management network. Also allow TCP 80 / 443 (the translation service) from the networks and applications that need to reach it. In production, front port 80 with TLS (see Step 10).

2

Deploy from the Azure CLI

Create the network resources and the VM, and accept the Marketplace terms once per subscription.

RG="libretranslate-prod"; LOCATION="eastus"; VM_NAME="libretranslate-01" IMAGE_URN="sac1647283583153:libretranslate-ubuntu-24-04:default:latest" SSH_KEY="$(cat ~/.ssh/id_rsa.pub)" az group create --name "$RG" --location "$LOCATION" az network vnet create -g "$RG" --name lt-vnet --address-prefix 10.90.0.0/16 --subnet-name lt-subnet --subnet-prefix 10.90.1.0/24 az network nsg create -g "$RG" --name lt-nsg az network nsg rule create -g "$RG" --nsg-name lt-nsg --name allow-ssh --priority 100 \
  --source-address-prefixes "<your-mgmt-cidr>" --destination-port-ranges 22 --access Allow --protocol Tcp az network nsg rule create -g "$RG" --nsg-name lt-nsg --name allow-web --priority 110 \
  --source-address-prefixes "<your-mgmt-cidr>" --destination-port-ranges 80 443 --access Allow --protocol Tcp
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:libretranslate-ubuntu-24-04:default:latest
az vm create -g "$RG" --name "$VM_NAME" --image "$IMAGE_URN" \
  --size Standard_B2s --storage-sku StandardSSD_LRS \
  --admin-username azureuser --ssh-key-values "$SSH_KEY" \
  --vnet-name lt-vnet --subnet lt-subnet --nsg lt-nsg --public-ip-sku Standard
3

Connect over SSH

Connect to the VM as azureuser.

ssh azureuser@<vm-ip>
4

Verify the services

LibreTranslate and nginx start automatically after the first-boot service has generated the per-VM key. Confirm that the stack is healthy:

systemctl is-active libretranslate.service nginx.service ss -tlnp | grep -E ':80 |:5000 '

Both services should report active. nginx listens on port 80 for external traffic. LibreTranslate listens only on 127.0.0.1:5000 and is never exposed directly.

5

Retrieve your per-VM API key

Every translation request needs the API key that was generated for this VM on its first boot. The key is stored in a root-only file:

sudo cat /root/libretranslate-info.txt

The LIBRETRANSLATE_API_KEY value is unique to your VM. No other VM has it, and it is not present in the Marketplace image. Keep it secret. LIBRETRANSLATE_URL is the address of your instance.

6

Translate from the web interface

Open http://<vm-ip>/ in a browser. The LibreTranslate interface loads immediately.

The service is secured, so select the key icon (Set API Key) in the top navigation bar. Paste the LIBRETRANSLATE_API_KEY from Step 5. The browser stores your key and sends it with every translation.

Pick your languages and type into the left pane. The translation appears on the right. For example, English to Spanish returns "Hola mundo".

The same interface handles every bundled language. A full sentence, for example, can be translated from English into French entirely offline on the VM.

7

Translate through the REST API

The same translation is available over HTTP. First confirm that the endpoint is closed without a key, which is the secure default. Then send an authenticated request that reads the per-VM key from the info file:

# Without a key: the request is rejected (no open translation endpoint)
curl -s -X POST http://127.0.0.1/translate \
  --data 'q=Hello world&source=en&target=es&format=text' | jq .
# With your per-VM key: a real offline translation
API_KEY=$(sudo grep '^LIBRETRANSLATE_API_KEY=' /root/libretranslate-info.txt | cut -d= -f2-)
curl -s -X POST http://127.0.0.1/translate \
  --data "q=Hello world&source=en&target=es&format=text&api_key=$API_KEY" | jq .

The unauthenticated call returns {"error": "Please contact the server operator to get an API key"}. The authenticated call returns {"translatedText": "Hola mundo"}.

From your own application, send the key as the api_key field. Replace <your-api-key> with the value from Step 5:

curl -s -X POST http://<vm-ip>/translate \
  --data 'q=Good morning&source=en&target=fr&format=text&api_key=<your-api-key>' | jq -r '.translatedText'
8

List the bundled languages and add more

List the languages that are loaded and ready to translate offline. The keyRequired flag in the frontend settings confirms that the service is secured:

curl -s http://127.0.0.1/languages | jq -r '.[] | .code + " " + .name'
curl -s http://127.0.0.1/frontend/settings | jq '{apiKeys, keyRequired, charLimit}'

To add another language, install its Argos model as the libretranslate service user and widen the service's --load-only list. This example adds Japanese (ja):

# Install the model (installs into the service's offline model store)
sudo -u libretranslate env HOME=/var/lib/libretranslate \
  ARGOS_PACKAGES_DIR=/var/lib/libretranslate/argos-packages \
  /opt/libretranslate/venv/bin/python -c \
  "from argostranslate import package; package.update_package_index(); \
  p=[x for x in package.get_available_packages() if x.from_code in ('en','ja') and x.to_code in ('en','ja')]; \
  [package.install_from_path(x.download()) for x in p]"
# Add ja to the --load-only list in the service unit, then restart
sudo sed -i 's/--load-only ar,de,en,es,fr,it,pt,ru,zh/--load-only ar,de,en,es,fr,it,ja,pt,ru,zh/' \
  /etc/systemd/system/libretranslate.service
sudo systemctl daemon-reload && sudo systemctl restart libretranslate.service

Removing a language from --load-only unloads it without deleting the model. This lowers memory use.

9

Explore the built-in API documentation

Open /docs for the interactive REST API documentation. It covers /translate, /detect, /languages and file translation, with request and response schemas.

10

Enable HTTPS

nginx fronts LibreTranslate on port 80 and is ready for your TLS certificate. For a public hostname, install a Let's Encrypt certificate with certbot:

sudo apt-get update && sudo apt-get install -y certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.example.com

certbot obtains the certificate, rewrites the nginx server block for TLS, and sets up automatic renewal. Point port 443 at your management and application networks in the NSG, and restrict port 80 to the redirect.

Managing the service

systemctl status libretranslate.service
# service health
sudo journalctl -u libretranslate.service -f
# live logs
sudo systemctl restart libretranslate.service

Configuration lives in the systemd unit /etc/systemd/system/libretranslate.service (host, port, --load-only, --req-limit, --char-limit). The API keys database is /var/lib/libretranslate/api_keys.db.

Support

This image is backed by 24/7 SecureAnyCloud support with a 24 hour response SLA. LibreTranslate is licensed under the GNU AGPL-3.0. For product questions, consult the LibreTranslate documentation.

Deploy on Azure

Launch LibreTranslate on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure