DOCUMENTATION / API & OPERATIONS

Deploy a Mojara application

This guide deploys a compiled Mojara app behind Nginx on Linux.

1. Build the app

On the deployment machine, in your application directory:

mojara build

Compile with the target platform's compatible Mojo toolchain. Provide the app with its configuration and native libraries.

2. Start it locally

mojara start

Your app should listen on a loopback address such as 127.0.0.1:8000. Verify the local URL before opening it to the internet.

3. Configure Nginx

Create an Nginx site for app.example.com:

server {
    listen 80;
    server_name app.example.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Replace app.example.com with your domain and 8000 with your application's port.

4. Enable the site and HTTPS

sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d app.example.com

Configure DNS before requesting the certificate.

5. Keep the app running

A production service manager should restart the Mojara process if it exits and should start it after a reboot. In systemd, set WorkingDirectory to your application directory and ExecStart to the installed Mojara launcher or compiled executable.

6. Check deployment

curl -i https://app.example.com/
curl -i https://app.example.com/api/health

The root route should return the page you created. The health endpoint is available if your application registered it.

7. Production rules

Keep secrets outside source control, serve only over HTTPS, restrict database access, use least-privilege service accounts, and keep private uploads outside the web root. See Observability and Shutdown.