
Langfuse is an open-source observability platform for applications powered by Large Language Models (LLMs). It traces prompts and responses, monitors token usage and costs, and provides analytics for debugging AI workflows in production. Langfuse helps developers optimize LLM application performance and control operational expenses.
This article explains how to deploy Langfuse on a Linux server using Docker Compose with Object Storage for trace data persistence and a Traefik reverse proxy that provisions an HTTPS certificate through Let's Encrypt.
Before you begin, you need to:
langfuse.example.com).Langfuse requires environment variables for domain configuration, database credentials, encryption keys, and Object Storage access.
Create the project directory with subdirectories for persistent data.
letsencrypt: Stores SSL/TLS certificates.postgres: Persists PostgreSQL database files.clickhouse-data: Persists ClickHouse analytics data.clickhouse-logs: Stores ClickHouse server logs.redis: Persists Redis data.Navigate to the project directory.
ClickHouse runs as UID 101 inside the container. Set matching ownership on its host directories so the container can write to them.
Generate secure secrets for the application. Run this command six times and save each output for use in the environment file.
The first three values are for SALT, ENCRYPTION_KEY, and NEXTAUTH_SECRET. The remaining three are for POSTGRES_PASSWORD, CLICKHOUSE_PASSWORD, and REDIS_AUTH.
Create an .env file to store configuration values.
Add the following environment variables and replace:
langfuse.example.com with your domain name.admin@example.com with your email address.GENERATED_SECRET_* placeholder with the corresponding secret generated in the previous step.DATABASE_URL with the same PostgreSQL password specified in POSTGRES_PASSWORD.The TELEMETRY_ENABLED=true setting allows Langfuse to send anonymous usage statistics to help improve Langfuse. No sensitive data, prompts, or trace content is transmitted. Set this to false if your organization has strict data retention policies or compliance requirements.
Save and close the file.
The deployment stack runs six containerized services that work together to provide the complete Langfuse observability platform. Traefik handles HTTPS and automatic certificate provisioning through Let's Encrypt, while PostgreSQL, ClickHouse, and Redis provide data persistence, analytics, and caching. Langfuse consists of two services: the web application and a background worker for asynchronous processing. Object Storage handles trace data, media uploads, and batch exports. This configuration is based on the official Langfuse Docker Compose examples.
Create the Docker Compose manifest file.
Add the following contents:
Save and close the file.
In the above manifest:
services: Launches six containers managed by Docker Compose:traefik: Serves as the reverse proxy and TLS termination point with automatic Let's Encrypt certificate provisioning.postgres: Stores Langfuse metadata including users, projects, and trace information in a persistent database.clickhouse: Provides the analytics database for time-series trace data and metrics queries.redis: Handles caching and background job queue management.langfuse-worker: Processes trace data asynchronously and manages batch exports to Object Storage.langfuse-web: Runs the main web application and API interface.environment: Configures database credentials, encryption keys, and Object Storage settings. The LANGFUSE_S3_* variables connect Langfuse to Object Storage for storing trace events, media uploads, and batch exports.depends_on: Ensures Langfuse services start only after database containers become healthy.labels (langfuse-web): Registers the web service with Traefik for HTTPS routing on the configured domain.expose (langfuse-web): Makes port 3000 reachable to Traefik on the internal Docker network without publishing it on the host.volumes: Bind-mounted host directories persist data for PostgreSQL, ClickHouse, Redis, and Let's Encrypt certificates across container restarts.restart: unless-stopped: Enables automatic recovery after failures or server reboots.Start the services.
Verify all containers are running.
The output displays six running containers in an Up state, with a healthy status shown for postgres, clickhouse, and redis, because those are the only services with a configured health check.
View the service logs to confirm all components started successfully.
For more information on managing a Docker Compose stack, see the How to Use Docker Compose article.
Langfuse provides a web-based dashboard for managing projects, viewing traces, and generating API keys.
Open a web browser and navigate to https://langfuse.example.com, replacing langfuse.example.com with your configured domain.
The Langfuse welcome page displays signup and login options.
On the Langfuse welcome page, click Sign up to create an administrator account.
Enter your email address and password, then click Sign up.
After signing in, create a new organization. Enter your organization name (for example, My Company) and click Create Organization.
Create a new project within the organization. Enter your project name (for example, Production LLM) and click Create Project.
Langfuse displays a setup wizard for your new project. Click Create API keys to generate authentication credentials.
Copy and securely store both the Secret Key (starting with sk-lf-) and Public Key (starting with pk-lf-). The secret key is only displayed once and cannot be retrieved later.
Your Langfuse instance is now configured and ready to receive trace data from your applications.
Langfuse tracks LLM interactions by logging prompts, responses, and metadata to the server. The following example demonstrates sending a test trace to verify the deployment.
Install the Python virtual environment package.
Create a virtual environment.
Activate the virtual environment.
Install the required Python packages.
Create a test script.
Add the following code. Replace YOUR_LLM_API_KEY with an API key from your LLM provider. This example uses Groq's API endpoint. For other providers, adjust the base_url parameter.
Save and close the file.
Set environment variables for Langfuse authentication. Replace YOUR_SECRET_KEY, YOUR_PUBLIC_KEY, and langfuse.example.com with your actual API keys and domain name.
Run the test script.
The script sends a request to the LLM provider, and the Langfuse SDK automatically captures and forwards the trace to your Langfuse instance.
Open the Langfuse web interface at your configured domain and navigate to the Traces page in your project.
The Traces page displays captured traces. Click the trace to view detailed information.
The trace details show model name, token usage, latency, cost estimate, and the full request/response conversation.
You have successfully deployed Langfuse on a Linux server using Docker Compose with Object Storage for trace data persistence and Traefik providing automatic HTTPS through Let's Encrypt. The deployment provides a fully functional LLM observability platform accessible securely over a custom domain with persistent storage for PostgreSQL, ClickHouse, and Redis data. You can now integrate Langfuse with your production LLM applications to monitor prompts, responses, token usage, and costs. For more information on advanced features and integrations, refer to the official Langfuse documentation.
0 Comments
Be the first to comment and share your perspective with the community.