Skip to content

Deploying Fusio

Introduction

Fusio is an open-source API management platform that helps developers quickly build, document, and monetize REST APIs. Unlike traditional API gateways that simply proxy requests, Fusio provides a complete backend solution with an integrated admin interface, automatic OpenAPI documentation generation, built-in authentication and rate limiting, SDK generation for multiple languages, and a powerful visual flow editor for creating API logic without writing code.

At its core, Fusio transforms API development from a time-consuming, error-prone process into a streamlined workflow. You define your API endpoints through an intuitive web interface, connect them to backend actions (database queries, HTTP requests, transformations), configure authentication schemes (OAuth2, JWT, API keys), set up rate limits per plan, and Fusio automatically generates comprehensive documentation, client SDKs, and even handles monetization through subscription plans and payment processing.

Fusio shines in scenarios where you need to rapidly prototype APIs, build data integration layers, create custom backends for mobile or web applications, monetize data through API subscriptions, or consolidate multiple backend services behind a unified API gateway. It supports complex workflows through its action system—chain database operations, external API calls, data transformations, and custom PHP logic into sophisticated API endpoints without managing separate microservices.

Deploying Fusio on Klutch.sh gives you a production-ready API platform with automatic HTTPS for secure communication, persistent storage for configuration and data, straightforward database connectivity, and the flexibility to scale resources as your API traffic grows—all without wrestling with server provisioning, load balancers, or certificate management.

This guide walks you through deploying Fusio on Klutch.sh using Docker, connecting to a MySQL or MariaDB database, configuring the platform, creating your first API endpoints, setting up authentication, implementing rate limiting, and following production-ready best practices for security, monitoring, and maintenance.


Why Deploy Fusio on Klutch.sh?

  • Rapid API Development: Build and deploy REST APIs in minutes, not days
  • Automatic HTTPS: Secure API endpoints with automatic SSL certificates
  • Persistent Storage: Reliable volume storage for uploads, cache, and logs
  • Database Integration: Easy connection to MySQL, MariaDB, or PostgreSQL
  • Scalable Infrastructure: Adjust CPU and RAM as API traffic grows
  • Built-in Documentation: Automatic OpenAPI/Swagger documentation generation
  • No Server Management: Focus on API logic, not infrastructure
  • Cost-Effective: Pay only for resources used, no licensing fees
  • GitHub Integration: Version-controlled deployment and configuration
  • Quick Updates: Deploy new Fusio versions with zero downtime

Prerequisites

Before you begin, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your deployment
  • Basic understanding of REST APIs and HTTP concepts
  • Familiarity with SQL databases (MySQL/MariaDB/PostgreSQL)

Technical Requirements:

Fusio is a PHP application with moderate resource needs:

  • Minimum 1GB RAM (2GB+ recommended for production)
  • At least 5GB persistent storage for uploads and cache
  • MySQL 5.7+, MariaDB 10.2+, or PostgreSQL 9.6+ database
  • PHP 8.1+ with required extensions (included in Docker image)

Required Dependencies:

Fusio requires a database. You’ll need to deploy either:

  • MySQL - see our MySQL deployment guide
  • MariaDB - see our MariaDB deployment guide (recommended)
  • PostgreSQL - see our PostgreSQL deployment guide

Understanding Fusio Architecture

Fusio is built as a comprehensive API management system:

Core Components:

  • Admin Interface: Web-based UI for managing APIs, schemas, and users
  • Developer Portal: Self-service portal for API consumers to register apps and get credentials
  • API Gateway: Request routing, authentication, rate limiting, and logging
  • Action System: Backend logic for API endpoints (database, HTTP, transformations)
  • Schema System: JSON Schema validation for request/response payloads
  • Event System: Webhook triggers for API events
  • Marketplace: Optional monetization through subscription plans

Request Flow:

  1. Client sends request to Fusio API endpoint
  2. Fusio validates authentication (OAuth2, JWT, API key)
  3. Rate limiting checks applied based on plan
  4. Request validated against JSON schema
  5. Action chain executes (database queries, HTTP calls, transformations)
  6. Response validated against schema
  7. Response returned to client
  8. Event triggers fire (webhooks, logging)

Data Storage:

  • Database: API configuration, users, apps, tokens, logs
  • Filesystem: Uploaded files, generated SDKs, cache
  • Cache: Optional Redis/Memcached for performance

Preparing Your Repository

Step 1: Create Project Directory

Create a new directory for your Fusio deployment:

Terminal window
mkdir fusio-api
cd fusio-api

Step 2: Create Dockerfile

Create a Dockerfile for your Fusio deployment:

FROM fusio/fusio:latest
# Fusio latest includes:
# - PHP 8.2 with all required extensions
# - Nginx web server
# - Fusio application and dependencies
# - Composer for package management
# Install additional PHP extensions if needed
RUN apk add --no-cache \
php82-redis \
php82-memcached
# Set working directory
WORKDIR /var/www/html
# Configuration will be set via environment variables
# Database credentials passed at runtime
# Expose HTTP port
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s \
CMD curl -f http://localhost/health || exit 1
# Start Fusio (inherited from base image)

Alternative: Custom Build with Extensions

For specific requirements or custom extensions:

FROM php:8.2-fpm-alpine
# Install system dependencies
RUN apk add --no-cache \
nginx \
curl \
git \
zip \
unzip \
libzip-dev \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
icu-dev \
libxml2-dev \
oniguruma-dev
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install -j$(nproc) \
pdo_mysql \
mysqli \
zip \
gd \
intl \
xml \
mbstring \
opcache
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create application directory
RUN mkdir -p /var/www/html
WORKDIR /var/www/html
# Install Fusio
RUN composer create-project fusio/fusio . && \
composer install --no-dev --optimize-autoloader
# Configure PHP-FPM
RUN echo "php_admin_value[error_log] = /var/log/php-fpm.log" >> /usr/local/etc/php-fpm.d/www.conf && \
echo "php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
# Configure Nginx
COPY nginx.conf /etc/nginx/nginx.conf
# Set permissions
RUN chown -R www-data:www-data /var/www/html && \
chmod -R 755 /var/www/html
EXPOSE 80
CMD ["sh", "-c", "php-fpm -D && nginx -g 'daemon off;'"]

Step 3: Create Nginx Configuration

Create nginx.conf for the custom build:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name _;
root /var/www/html/public;
index index.php;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
}

Step 4: Create Environment Configuration

Create a .env.example file for documentation:

# Database Configuration
FUSIO_DB_HOST=mysql-app.klutch.sh
FUSIO_DB_PORT=8000
FUSIO_DB_NAME=fusio
FUSIO_DB_USER=fusio
FUSIO_DB_PASSWORD=your-secure-database-password
# Fusio Configuration
FUSIO_ENV=prod
FUSIO_URL=https://example-app.klutch.sh
FUSIO_SECRET=your-generated-secret-key
# Admin User (created on first deployment)
FUSIO_ADMIN_EMAIL=admin@example.com
FUSIO_ADMIN_PASSWORD=your-secure-admin-password
FUSIO_ADMIN_POINTS=100
# CORS Configuration
FUSIO_CORS=*
# Mail Configuration (optional)
FUSIO_MAILER_DSN=smtp://user:pass@smtp.example.com:587
# Payment Configuration (optional)
# FUSIO_STRIPE_SECRET_KEY=sk_test_xxx
# FUSIO_STRIPE_WEBHOOK_SECRET=whsec_xxx
# FUSIO_PAYPAL_CLIENT_ID=xxx
# FUSIO_PAYPAL_CLIENT_SECRET=xxx
# Cache Configuration (optional)
# FUSIO_CACHE=redis
# FUSIO_CACHE_HOST=redis-app.klutch.sh
# FUSIO_CACHE_PORT=8000

Step 5: Create .gitignore

Create a .gitignore file to exclude sensitive data:

# Environment files
.env
.env.local
.env.production
# Fusio data
/cache/
/public/apps/
/public/projects/
# Logs
*.log
/logs/
# Temporary files
/temp/
# Vendor
/vendor/
# System files
.DS_Store
Thumbs.db

Step 6: Create README.md

Document your deployment:

# Fusio API Platform on Klutch.sh
Open-source API management and monetization platform.
## Quick Start
1. Deploy MySQL/MariaDB database on Klutch.sh
2. Push this repository to GitHub
3. Deploy Fusio on Klutch.sh with HTTP traffic
4. Access admin interface at your assigned URL
5. Create your first API endpoint
## Features
- Visual API Designer
- Automatic OpenAPI Documentation
- OAuth2, JWT, API Key Authentication
- Rate Limiting & Quotas
- SDK Generation
- Developer Portal
- Monetization & Billing
## Configuration
See Klutch.sh dashboard for environment variables and database configuration.
## Documentation
- [Fusio Documentation](https://fusio-project.org/documentation)
- [API Development Guide](https://fusio-project.org/documentation/development)

Step 7: Push to GitHub

Initialize git and push your repository:

Terminal window
git init
git add Dockerfile nginx.conf .env.example .gitignore README.md
git commit -m "Initial Fusio API platform deployment setup"
git branch -M main
git remote add origin https://github.com/your-username/fusio-api.git
git push -u origin main

Deploying the Database

Fusio requires a MySQL, MariaDB, or PostgreSQL database. Deploy the database first before deploying Fusio.

    1. Follow our MariaDB deployment guide to set up a database server

    2. Configure the MariaDB deployment with:

      • TCP Traffic on port 8000
      • Persistent Volume: /var/lib/mysql with at least 5GB
      • Environment Variables:
        • MYSQL_ROOT_PASSWORD: Strong root password
        • MYSQL_DATABASE: fusio
        • MYSQL_USER: fusio
        • MYSQL_PASSWORD: Strong user password
    3. Note the connection details:

      • Host: your-mariadb-app.klutch.sh
      • Port: 8000
      • Database: fusio
      • Username: fusio
      • Password: Your configured password

Option 2: Deploy MySQL on Klutch.sh

    1. Follow our MySQL deployment guide to set up a database server

    2. Configure with similar settings as MariaDB above

Option 3: Use External Managed Database

You can also use external managed database services:


Deploying Fusio on Klutch.sh

Step 1: Create New App

    1. Log in to the Klutch.sh dashboard

    2. Create a new project or select an existing one

    3. Create a new app and configure it:

      • Repository: Select your Fusio GitHub repository
      • Branch: Choose the branch to deploy (e.g., main or production)
      • Traffic Type: Select HTTP (Fusio runs as a web application)
      • Internal Port: Set to 80 (Fusio’s Nginx server listens on port 80)

Step 2: Configure Persistent Volumes

Fusio requires persistent storage for uploads, cache, and generated files.

    1. In your app settings, navigate to the Volumes section

    2. Add a volume for Fusio application data:

      • Mount Path: /var/www/html/cache
      • Size: 5GB (adjust based on expected cache and file upload needs)
    3. (Optional) Add a volume for logs:

      • Mount Path: /var/www/html/logs
      • Size: 2GB

Step 3: Configure Environment Variables

Set essential environment variables for your Fusio deployment:

    1. In your app settings, navigate to the Environment Variables section

    2. Add the following variables (mark sensitive values as secrets):

      Database Configuration:

      Terminal window
      FUSIO_DB_HOST=your-mariadb-app.klutch.sh
      FUSIO_DB_PORT=8000
      FUSIO_DB_NAME=fusio
      FUSIO_DB_USER=fusio
      FUSIO_DB_PASSWORD=your-database-password

      Fusio Configuration:

      Terminal window
      FUSIO_ENV=prod
      FUSIO_URL=https://example-app.klutch.sh
      FUSIO_SECRET=your-generated-secret-key-minimum-32-chars

      Admin User:

      Terminal window
      FUSIO_ADMIN_EMAIL=admin@example.com
      FUSIO_ADMIN_PASSWORD=your-secure-admin-password
      FUSIO_ADMIN_POINTS=100

      CORS Configuration:

      Terminal window
      FUSIO_CORS=*

Important: Generate a strong secret key for FUSIO_SECRET. You can use:

Terminal window
openssl rand -base64 32

Step 4: Deploy Your Application

    1. Click Deploy to start the build process

    2. Klutch.sh will:

      • Pull your GitHub repository
      • Detect the Dockerfile automatically
      • Build the Fusio container image
      • Deploy it with your configured volumes and environment variables
    3. Monitor the build logs for any errors

    4. Once deployed, your Fusio API platform will be available at https://example-app.klutch.sh

    5. Initial deployment may take 3-5 minutes as Fusio initializes the database and creates tables


Initial Setup and Configuration

After deployment, complete the Fusio initial setup:

Step 1: Access Admin Interface

    1. Navigate to https://example-app.klutch.sh/fusio in your browser

    2. You should see the Fusio login page

    3. Log in with the admin credentials you configured:

      • Email: admin@example.com
      • Password: Your configured admin password

Step 2: Complete Initial Configuration

    1. After logging in, you’ll see the Fusio admin dashboard

    2. Navigate to SystemSettings to review configuration:

      • Base URL: Verify it matches your Klutch.sh URL
      • Admin Email: Confirm admin contact email
      • Points per Month: Set default API credits for new users
    3. Click Save if you made any changes

Step 3: Generate API Documentation

    1. Navigate to SystemOpenAPI

    2. Click Generate to create OpenAPI documentation

    3. Access your API documentation at: https://example-app.klutch.sh/documentation


Creating Your First API

Let’s create a simple “Hello World” API endpoint to verify everything works:

Step 1: Create a Schema

Schemas define the structure of your API requests and responses:

    1. Navigate to Schema in the admin interface

    2. Click Create to add a new schema

    3. Configure the response schema:

      • Name: Hello_Response
      • Schema:
      {
      "type": "object",
      "properties": {
      "message": {
      "type": "string"
      },
      "timestamp": {
      "type": "string",
      "format": "date-time"
      }
      },
      "required": ["message"]
      }
    4. Click Create to save the schema

Step 2: Create an Action

Actions define the backend logic for your API:

    1. Navigate to Action in the admin interface

    2. Click Create to add a new action

    3. Configure the action:

      • Name: Hello_World
      • Class: Select PHP-Sandbox
      • Code:
      <?php
      return [
      'message' => 'Hello, World! Welcome to Fusio API.',
      'timestamp' => date('c')
      ];
    4. Click Create to save the action

Step 3: Create a Route

Routes define your API endpoints:

    1. Navigate to Routes in the admin interface

    2. Click Create to add a new route

    3. Configure the route:

      • Path: /hello
      • Public: Enable (no authentication required)
      • Methods: Enable GET
    4. Configure the GET method:

      • Status: Active
      • Response: 200 → Select Hello_Response schema
      • Action: Select Hello_World action
    5. Click Create to save the route

Step 4: Test Your API

    1. Test the endpoint using curl:

      Terminal window
      curl https://example-app.klutch.sh/hello
    2. You should receive a response:

      {
      "message": "Hello, World! Welcome to Fusio API.",
      "timestamp": "2024-01-15T10:30:00+00:00"
      }
    3. View the request in LogSystem to see details


Database-Connected API

Let’s create an API that interacts with the database:

Step 1: Create a Database Table

    1. Connect to your MySQL/MariaDB database

    2. Create a sample table:

      CREATE TABLE products (
      id INT AUTO_INCREMENT PRIMARY KEY,
      name VARCHAR(255) NOT NULL,
      description TEXT,
      price DECIMAL(10, 2) NOT NULL,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
      );
      INSERT INTO products (name, description, price) VALUES
      ('Widget', 'A useful widget', 19.99),
      ('Gadget', 'An amazing gadget', 29.99),
      ('Tool', 'A handy tool', 39.99);

Step 2: Create Connection

    1. Navigate to Connection in Fusio admin

    2. Click Create to add a database connection

    3. Configure the connection:

      • Name: Default-Connection
      • Class: Select SQL
      • Config:
      {
      "type": "pdo_mysql",
      "host": "your-mariadb-app.klutch.sh",
      "port": 8000,
      "username": "fusio",
      "password": "your-database-password",
      "database": "fusio"
      }
    4. Click Create and then Test to verify connection

Step 3: Create Schema for Products

    1. Navigate to Schema

    2. Create a schema for the product list:

      • Name: Product_Collection
      • Schema:
      {
      "type": "object",
      "properties": {
      "items": {
      "type": "array",
      "items": {
      "type": "object",
      "properties": {
      "id": {"type": "integer"},
      "name": {"type": "string"},
      "description": {"type": "string"},
      "price": {"type": "number"}
      }
      }
      },
      "totalResults": {"type": "integer"}
      }
      }

Step 4: Create Action for Products

    1. Navigate to Action

    2. Create a new action:

      • Name: Get_Products
      • Class: Select SQL-Query-All
      • Config:
      {
      "connection": "Default-Connection",
      "sql": "SELECT id, name, description, price FROM products ORDER BY created_at DESC"
      }
    3. Click Create

Step 5: Create Route for Products

    1. Navigate to Routes

    2. Create a new route:

      • Path: /products
      • Public: Enable
      • Methods: Enable GET
    3. Configure GET method:

      • Status: Active
      • Response: 200 → Select Product_Collection schema
      • Action: Select Get_Products action
    4. Click Create

Step 6: Test Products API

Terminal window
curl https://example-app.klutch.sh/products

Response:

{
"items": [
{
"id": 1,
"name": "Widget",
"description": "A useful widget",
"price": 19.99
},
{
"id": 2,
"name": "Gadget",
"description": "An amazing gadget",
"price": 29.99
},
{
"id": 3,
"name": "Tool",
"description": "A handy tool",
"price": 39.99
}
],
"totalResults": 3
}

Authentication and Security

Setting Up OAuth2 Authentication

    1. Navigate to AppDeveloper Apps

    2. Click Create to register a new application

    3. Configure the app:

      • Name: Test Client
      • URL: https://example.com
      • Status: Active
      • Scopes: Select available scopes
    4. Note the generated App Key and App Secret

    5. Get an access token:

      Terminal window
      curl -X POST https://example-app.klutch.sh/authorization/token \
      -H "Content-Type: application/json" \
      -d '{
      "grant_type": "client_credentials",
      "client_id": "your-app-key",
      "client_secret": "your-app-secret"
      }'
    6. Use the token to access protected endpoints:

      Terminal window
      curl https://example-app.klutch.sh/protected-endpoint \
      -H "Authorization: Bearer your-access-token"

Setting Up API Key Authentication

    1. Navigate to UserUsers

    2. Select a user or create a new one

    3. Navigate to the Tokens tab

    4. Click Generate to create an API token

    5. Use the token in API requests:

      Terminal window
      curl https://example-app.klutch.sh/products \
      -H "Authorization: Bearer your-api-token"

Protecting Routes

    1. Navigate to Routes

    2. Select a route to protect

    3. Edit the route and disable Public access

    4. Save the route

    5. Access now requires authentication:

      Terminal window
      # Without token - 401 Unauthorized
      curl https://example-app.klutch.sh/products
      # With token - Success
      curl https://example-app.klutch.sh/products \
      -H "Authorization: Bearer your-token"

Rate Limiting and Plans

Creating Rate Limit Plans

    1. Navigate to PlanPlans

    2. Click Create to add a new plan

    3. Configure the plan:

      • Name: Free Plan
      • Price: 0.00
      • Points: 1000 (API credits per period)
      • Period: monthly
    4. Create additional plans:

      • Basic Plan: 10,000 points/month, $9.99
      • Pro Plan: 100,000 points/month, $49.99
      • Enterprise Plan: 1,000,000 points/month, $199.99
    5. Click Create for each plan

Assigning Plans to Users

    1. Navigate to UserUsers

    2. Select a user

    3. In the Plan section, assign a plan

    4. Set the expiration date

    5. Save changes

Configuring Route Costs

    1. Navigate to Routes

    2. Select a route to configure

    3. In the route configuration, set Costs: Number of points required per request

    4. Save the route

    5. Requests will now consume points from the user’s plan


Developer Portal

The Developer Portal allows API consumers to register, get credentials, and access documentation:

Enabling the Developer Portal

    1. Navigate to SystemSettings

    2. Enable Developer Portal

    3. Configure portal settings:

      • Registration: Enable/disable user registration
      • Approval: Require admin approval for new apps
      • Plans: Default plan for new users
    4. Save settings

Accessing the Developer Portal

    1. Navigate to https://example-app.klutch.sh/developer

    2. Users can:

      • Register for an account
      • Create applications
      • Generate API credentials
      • View documentation
      • Monitor usage and quotas

Advanced Features

Action Chaining

Chain multiple actions together for complex workflows:

    1. Navigate to Action

    2. Create a new action with Action-Chain class

    3. Configure the chain:

      {
      "actions": [
      {
      "action": "Get_User_Data",
      "on": "response"
      },
      {
      "action": "Transform_Data",
      "on": "response"
      },
      {
      "action": "Send_Notification",
      "on": "response"
      }
      ]
      }
    4. Each action receives output from the previous action

HTTP Proxy Actions

Create API endpoints that proxy to external services:

    1. Navigate to Action

    2. Create action with HTTP-Request class

    3. Configure the proxy:

      {
      "url": "https://api.external-service.com/endpoint",
      "method": "GET",
      "headers": {
      "Authorization": "Bearer external-api-token"
      }
      }
    4. Attach to a route to expose the proxied endpoint

Data Transformation

Transform API responses with custom logic:

    1. Create action with PHP-Sandbox class

    2. Write transformation logic:

      <?php
      $input = $request->getBody();
      // Transform data
      $output = array_map(function($item) {
      return [
      'id' => $item['id'],
      'name' => strtoupper($item['name']),
      'price' => '$' . number_format($item['price'], 2)
      ];
      }, $input['items']);
      return ['items' => $output];

Event Triggers

Trigger webhooks or actions based on API events:

    1. Navigate to EventSubscriptions

    2. Create a new subscription

    3. Configure:

      • Event: Select event type (route executed, user created, etc.)
      • Endpoint: Webhook URL to notify
      • Status: Active
    4. Events will trigger HTTP POST requests to your webhook


SDK Generation

Fusio can generate client SDKs in multiple languages:

Generating SDKs

    1. Navigate to SystemSDK

    2. Select language:

      • JavaScript/TypeScript
      • PHP
      • Python
      • Java
      • C#
      • Go
      • Ruby
    3. Click Generate

    4. Download the generated SDK package

    5. Distribute to API consumers

Using Generated SDK (JavaScript Example)

import FusioClient from './fusio-sdk';
const client = new FusioClient('https://example-app.klutch.sh', {
clientId: 'your-app-key',
clientSecret: 'your-app-secret'
});
// Authenticate
await client.authenticate();
// Call API
const products = await client.get('/products');
console.log(products);
// Create resource
const newProduct = await client.post('/products', {
name: 'New Product',
price: 49.99
});

Monetization

Setting Up Payment Processing

    1. Navigate to SystemSettings

    2. Configure payment provider:

      Stripe:

      Terminal window
      FUSIO_STRIPE_SECRET_KEY=sk_live_xxx
      FUSIO_STRIPE_WEBHOOK_SECRET=whsec_xxx

      PayPal:

      Terminal window
      FUSIO_PAYPAL_CLIENT_ID=xxx
      FUSIO_PAYPAL_CLIENT_SECRET=xxx
    3. Create paid plans with pricing

    4. Users can subscribe via the Developer Portal

Webhook Handling

    1. Configure webhook endpoints in payment provider dashboard

    2. Set webhook URL: https://example-app.klutch.sh/payment/webhook/{provider}

    3. Fusio automatically processes:

      • Payment confirmations
      • Subscription renewals
      • Payment failures
      • Cancellations

Custom Domains

For production use, configure a custom domain:

Step 1: Configure Domain in Klutch.sh

    1. In the Klutch.sh dashboard, navigate to your app settings

    2. Go to the Domains section

    3. Add your custom domain (e.g., api.yourdomain.com)

    4. Klutch.sh will provide DNS records to configure

Step 2: Update DNS Records

    1. Log in to your domain registrar

    2. Add the DNS records provided by Klutch.sh:

      • CNAME record pointing to your Klutch.sh app
      • Wait for DNS propagation (up to 48 hours)
    3. Klutch.sh will automatically provision SSL certificates

Step 3: Update Fusio Configuration

    1. Update the FUSIO_URL environment variable to your custom domain

    2. Redeploy the application

    3. Update OAuth redirect URIs if using OAuth2

    4. Regenerate OpenAPI documentation with new base URL


Performance Optimization

Enable Caching

    1. Deploy Redis on Klutch.sh (see Redis guide)

    2. Configure Fusio to use Redis:

      Terminal window
      FUSIO_CACHE=redis
      FUSIO_CACHE_HOST=redis-app.klutch.sh
      FUSIO_CACHE_PORT=8000
    3. Restart Fusio to apply caching

Database Optimization

    1. Enable Query Caching:

      • Cache frequently accessed data
      • Use Redis for session storage
    2. Optimize Queries:

      • Add indexes to frequently queried columns
      • Use pagination for large datasets
      • Limit result sets
    3. Connection Pooling:

      • Fusio manages connections automatically
      • Scale database resources as needed

HTTP Caching

    1. Configure route caching:

      • Navigate to Routes
      • Edit route
      • Set Cache time in seconds
      • Save route
    2. Fusio will return cached responses for the specified duration


Security Best Practices

Authentication and Authorization

    1. Use Strong Secrets:

      • Generate strong FUSIO_SECRET (32+ characters)
      • Rotate secrets periodically
      • Store securely in Klutch.sh environment variables
    2. Implement OAuth2:

      • Use OAuth2 for third-party integrations
      • Implement proper scope restrictions
      • Validate redirect URIs
    3. API Key Management:

      • Generate unique keys per application
      • Implement key rotation
      • Revoke compromised keys immediately
    4. Rate Limiting:

      • Implement per-user rate limits
      • Set different limits per plan
      • Monitor for abuse

Input Validation

    1. Use JSON Schema:

      • Define strict schemas for all routes
      • Validate all inputs
      • Reject malformed requests
    2. Sanitize Data:

      • Escape SQL queries (Fusio does this automatically)
      • Validate data types
      • Check for injection attempts
    3. Limit Payload Sizes:

      • Configure max request body size in Nginx
      • Prevent memory exhaustion attacks

HTTPS and CORS

    1. HTTPS Only:

      • Klutch.sh provides automatic HTTPS
      • Never expose APIs over HTTP
      • Use secure cookies for sessions
    2. Configure CORS:

      • Set specific allowed origins (avoid * in production)
      • Configure allowed methods and headers
      • Use credentials flag appropriately
    3. Security Headers:

      • Configure in Nginx:
      add_header X-Frame-Options "SAMEORIGIN";
      add_header X-Content-Type-Options "nosniff";
      add_header X-XSS-Protection "1; mode=block";
      add_header Referrer-Policy "strict-origin-when-cross-origin";

Monitoring and Logging

Access Logs

    1. Navigate to LogSystem in Fusio admin

    2. View API request logs:

      • Request method and path
      • Response status
      • Response time
      • IP address
      • User agent
    3. Filter logs by:

      • Date range
      • Route
      • Status code
      • User

Error Monitoring

    1. Navigate to LogErrors

    2. View application errors:

      • Error messages
      • Stack traces
      • Request context
    3. Configure error notifications:

      • Set up email alerts
      • Integrate with error tracking services (Sentry, Bugsnag)

Performance Monitoring

    1. Monitor Response Times:

      • View average response times per route
      • Identify slow endpoints
      • Optimize actions and queries
    2. Track Usage:

      • Monitor API calls per user
      • Track plan consumption
      • Identify popular endpoints
    3. Resource Monitoring:

      • Monitor CPU and RAM in Klutch.sh dashboard
      • Track database query performance
      • Monitor cache hit rates

Backup and Maintenance

Database Backup

    1. Automated Backups:

      • Configure database backups in your database deployment
      • Export database regularly:
      Terminal window
      mysqldump -h mariadb-app.klutch.sh -P 8000 -u fusio -p fusio > fusio-backup.sql
    2. Configuration Backup:

      • Store configuration in version control
      • Export route configurations
      • Backup schemas and actions

Updates and Maintenance

    1. Update Fusio:

      • Update Dockerfile to new version
      • Push changes to GitHub
      • Deploy updated version from Klutch.sh
    2. Database Migration:

      • Fusio automatically runs migrations
      • Review migration logs
      • Test in staging before production
    3. Regular Maintenance:

      • Review and optimize slow queries
      • Clean up old logs
      • Audit user permissions
      • Review API usage patterns

Troubleshooting Common Issues

Fusio Won’t Start

    1. Check Database Connection:

      • Verify database is running
      • Test connection credentials
      • Check firewall rules
    2. Review Logs:

      • View application logs in Klutch.sh dashboard
      • Look for initialization errors
      • Check for missing environment variables
    3. Verify Configuration:

      • Ensure all required environment variables are set
      • Validate FUSIO_URL matches deployment URL
      • Check FUSIO_SECRET is at least 32 characters

Database Connection Errors

    1. Verify Credentials:

      • Check FUSIO_DB_HOST, FUSIO_DB_PORT
      • Verify FUSIO_DB_USER and FUSIO_DB_PASSWORD
      • Ensure database name exists
    2. Test Connection:

      Terminal window
      mysql -h mariadb-app.klutch.sh -P 8000 -u fusio -p
    3. Check Network:

      • Ensure database accepts external connections
      • Verify TCP traffic enabled on database deployment

API Returns 500 Errors

    1. Check Action Configuration:

      • Review action code for syntax errors
      • Verify connection configurations
      • Test SQL queries manually
    2. Review Error Logs:

      • Navigate to LogErrors in admin
      • Check stack traces
      • Look for PHP errors
    3. Validate Schema:

      • Ensure response matches schema
      • Check for missing required fields
      • Verify data types

Authentication Issues

    1. Verify Credentials:

      • Check app key and secret
      • Verify token hasn’t expired
      • Ensure scopes are correct
    2. Check Route Configuration:

      • Verify route is not set to public
      • Ensure authentication is enabled
      • Check required scopes
    3. Test Token Generation:

      Terminal window
      curl -X POST https://example-app.klutch.sh/authorization/token \
      -H "Content-Type: application/json" \
      -d '{"grant_type": "client_credentials", "client_id": "key", "client_secret": "secret"}'

Production Deployment Checklist

Before going live with Fusio:

  • Database deployed and accessible
  • Persistent volumes configured (minimum 5GB for /var/www/html/cache)
  • All environment variables set correctly
  • Strong FUSIO_SECRET generated (32+ characters)
  • Admin account created with strong password
  • HTTPS working correctly (automatic via Klutch.sh)
  • Custom domain configured (optional)
  • Database backups scheduled
  • API routes created and tested
  • Authentication configured (OAuth2, JWT, or API keys)
  • Rate limiting enabled
  • Plans configured for API monetization
  • Developer portal configured
  • OpenAPI documentation generated
  • Error logging and monitoring set up
  • CORS configured appropriately
  • Security headers configured
  • Performance monitoring enabled
  • Cache configured (Redis recommended)
  • Webhook endpoints configured (if using payments)
  • SDK generated for client applications
  • Load testing completed
  • Documentation updated for API consumers

Resources and Further Reading


Conclusion

Deploying Fusio on Klutch.sh provides a powerful, production-ready platform for building, managing, and monetizing REST APIs. With automatic HTTPS, persistent storage, straightforward database connectivity, and the flexibility to scale resources as needed, you can focus on creating great APIs rather than managing infrastructure.

This guide covered everything from initial deployment to advanced features like authentication, rate limiting, SDK generation, payment integration, and production best practices. Whether you’re building a simple data API, creating a backend for a mobile app, or launching an API-as-a-Service business, Fusio on Klutch.sh provides the tools and reliability you need.

Remember to keep your system updated, monitor API usage, implement proper authentication and rate limiting, and follow security best practices to protect your APIs and data. For additional help or questions, refer to the resources above or engage with the Fusio community.

Happy API building!