### Run Frontend Development Server Source: https://github.com/hhftechnology/middleware-manager/blob/main/README.md To start the frontend development server, change the directory to `ui`, copy the `package.json` file, install dependencies using `npm install`, and then start the development server with `npm start`. ```bash cd ui npm install npm start ``` -------------------------------- ### Start Frontend Development Server (npm) Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe Start the frontend development server to run the UI locally. This command assumes npm is installed and dependencies are already installed. ```bash npm start ``` -------------------------------- ### Full Docker Compose Example Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe A complete Docker Compose setup for Pangolin, Traefik, and Middleware Manager. This example includes service definitions, volumes, environment variables, and network configuration. ```yaml version: '3.8' services: pangolin: image: fosrl/pangolin:1.2.0 container_name: pangolin restart: unless-stopped volumes: - ./config:/app/config healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"] interval: "3s" timeout: "3s" retries: 5 traefik: image: traefik:v3.3.3 container_name: traefik restart: unless-stopped ports: - "80:80" - "443:443" - "8080:8080" depends_on: pangolin: condition: service_healthy command: - --api.insecure=true - --api.dashboard=true - --providers.file.directory=/rules - --providers.file.watch=true - --entrypoints.web.address=:80 - --entrypoints.websecure.address=:443 volumes: - ./config/traefik:/etc/traefik - ./config/letsencrypt:/letsencrypt - ./config/traefik/rules:/rules middleware-manager: image: hhftechnology/middleware-manager:latest container_name: middleware-manager restart: unless-stopped volumes: - ./data:/data - ./config/traefik/rules:/conf - ./config/middleware-manager/templates.yaml:/app/config/templates.yaml - ./config/middleware-manager/config.json:/app/config/config.json environment: - PANGOLIN_API_URL=http://pangolin:3001/api/v1 - TRAEFIK_API_URL=http://traefik:8080 - TRAEFIK_CONF_DIR=/conf - DB_PATH=/data/middleware.db - PORT=3456 ports: - "3456:3456" networks: default: driver: bridge name: pangolin ``` -------------------------------- ### Install Frontend Dependencies (npm) Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe Install the necessary Node.js dependencies for the frontend UI. Ensure Node.js 16+ and npm are installed. ```bash cd ui npm install ``` -------------------------------- ### Run Backend Development Server Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/development/dev-guide.mdx Use this command to start the Go backend development server. ```bash # Backend go run main.go ``` -------------------------------- ### Run Development Server Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/README.md Commands to start the development server using npm, pnpm, or yarn. ```bash npm run dev # or pnpm dev # or yarn dev ``` -------------------------------- ### Install a Traefik Plugin Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Install a Traefik plugin by providing its module name and version. This action writes to the Traefik static configuration file and requires a Traefik restart to take effect. ```bash curl -X POST http://localhost:3456/api/plugins/install \ -H "Content-Type: application/json" \ -d '{ "moduleName": "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin", "version": "v1.4.4" }' ``` -------------------------------- ### Start Middleware Manager Service Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe After configuring the Middleware Manager, use this command to start the service in detached mode. ```bash docker-compose up -d middleware-manager ``` -------------------------------- ### Traefik Full Configuration Example Source: https://github.com/hhftechnology/middleware-manager/blob/main/README.md This is a comprehensive example of a Traefik configuration file. It covers access logging, API settings, certificate resolvers, entry points, experimental plugins, logging, and provider configurations. Ensure sensitive information like email addresses are updated. ```yaml accessLog: bufferingSize: 100 fields: defaultMode: drop headers: defaultMode: drop names: Authorization: redact Content-Type: keep Cookie: redact User-Agent: keep X-Forwarded-For: keep X-Forwarded-Proto: keep X-Real-Ip: keep names: ClientAddr: keep ClientHost: keep DownstreamContentSize: keep DownstreamStatus: keep Duration: keep RequestMethod: keep RequestPath: keep RequestProtocol: keep RetryAttempts: keep ServiceName: keep StartUTC: keep TLSCipher: keep TLSVersion: keep filePath: /var/log/traefik/access.log filters: minDuration: 100ms retryAttempts: true statusCodes: - 200-299 - 400-499 - 500-599 format: json api: dashboard: true insecure: true certificatesResolvers: letsencrypt: acme: caServer: https://acme-v02.api.letsencrypt.org/directory email: your-email@hhf.technology httpChallenge: entryPoint: web storage: /letsencrypt/acme.json entryPoints: tcp-51821: address: :51821/tcp http: middlewares: - crowdsec@file tls: certResolver: letsencrypt transport: respondingTimeouts: readTimeout: 30m udp-51830: address: :51830/udp web: address: :80 websecure: address: :443 http: tls: certResolver: letsencrypt transport: respondingTimeouts: readTimeout: 30m experimental: plugins: badger: moduleName: github.com/fosrl/badger version: v1.2.0 crowdsec: moduleName: github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin version: v1.4.4 mtlswhitelist: moduleName: github.com/smerschjohann/mtlswhitelist version: v0.3.0 log: compress: true filePath: /var/log/traefik/traefik.log format: json level: INFO maxAge: 3 maxBackups: 3 maxSize: 100 ping: entryPoint: web providers: file: filename: "/etc/traefik/dynamic_config.yml" http: endpoint: http://172.17.1.3:3456/api/v1/traefik-config pollInterval: 5s serversTransport: insecureSkipVerify: true ``` -------------------------------- ### Run Frontend Development Server Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/development/dev-guide.mdx Navigate to the UI directory and run this command to start the React frontend development server. ```bash # Frontend cd ui && npm install && npm run dev ``` -------------------------------- ### List Installed Traefik Plugins Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve a list of all plugins currently installed in Traefik, including those from the Traefik API and the local static configuration. ```bash curl http://localhost:3456/api/plugins ``` -------------------------------- ### Run Backend in Development Mode (Go) Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe Execute the backend Go application in development mode. Ensure Go 1.19+ is installed. ```bash go run main.go ``` -------------------------------- ### Run Docs Development Server Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/development/dev-guide.mdx Navigate to the docs directory and run this command to start the Fumadocs documentation development server. ```bash # Docs cd docs/docs && npm install && npm run dev ``` -------------------------------- ### Check mtlswhitelist Plugin Installation Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Verifies if the `mtlswhitelist` Traefik plugin is installed in the static configuration. This is a prerequisite for enabling global mTLS. ```bash curl http://localhost:3456/api/mtls/plugin/check ``` -------------------------------- ### Run Backend Development Server Source: https://github.com/hhftechnology/middleware-manager/blob/main/README.md To start the backend development server, navigate to the project root and execute the `go run main.go` command. For building a production-ready executable, use `go build -o middleware-manager main.go`. ```bash go run main.go # Build: go build -o middleware-manager main.go ``` -------------------------------- ### Standalone Traefik Example (Docker Compose) Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe This Docker Compose configuration sets up Traefik as a standalone reverse proxy without Pangolin. It includes Traefik itself, the middleware-manager service, and an example 'whoami' service for testing. ```yaml version: '3.8' services: traefik: image: traefik:v3.3.3 container_name: traefik restart: unless-stopped ports: - "80:80" - "443:443" - "8080:8080" command: - --api.insecure=true - --api.dashboard=true - --providers.docker=true - --providers.file.directory=/rules - --providers.file.watch=true - --entrypoints.web.address=:80 - --entrypoints.websecure.address=:443 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - ./config/traefik:/etc/traefik - ./config/letsencrypt:/letsencrypt - ./config/traefik/rules:/rules middleware-manager: image: hhftechnology/middleware-manager:latest container_name: middleware-manager restart: unless-stopped volumes: - ./data:/data - ./config/traefik/rules:/conf - ./config/middleware-manager/config.json:/app/config/config.json environment: - TRAEFIK_API_URL=http://traefik:8080 - TRAEFIK_CONF_DIR=/conf - DB_PATH=/data/middleware.db - PORT=3456 - ACTIVE_DATA_SOURCE=traefik ports: - "3456:3456" # Example services to manage with middlewares whoami: image: traefik/whoami labels: - "traefik.enable=true" - "traefik.http.routers.whoami.rule=Host(`whoami.example.com`)" - "traefik.http.routers.whoami.entrypoints=websecure" - "traefik.http.routers.whoami.tls=true" ``` -------------------------------- ### Log Hello World to Console Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/test.mdx A simple JavaScript code block to print 'Hello World' to the console. No specific setup is required. ```javascript console.log('Hello World'); ``` -------------------------------- ### Plugins Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/api/overview.mdx Manage plugins, including listing, catalogue access, usage information, installation, removal, and static configuration. ```APIDOC ## Plugins ### List Plugins - `GET /plugins` ### Get Plugin Catalogue - `GET /plugins/catalogue` ### Get Plugin Usage by Name - `GET /plugins/:name/usage` ### Install Plugin - `POST /plugins/install` ### Remove Plugin - `DELETE /plugins/remove` ### Get/Set Static Config Path - `GET/PUT /plugins/configpath` ``` -------------------------------- ### Service Templates Example Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/configuration/templates.mdx Provide presets for services such as load balancers, weighted splits, mirroring, or failover using YAML. These templates assist in quickly configuring new services. ```yaml - name: lb-default type: loadBalancer config: servers: - url: http://backend:8080 passHostHeader: true ``` -------------------------------- ### Get Single Resource Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve details for a specific resource using its ID. ```bash curl http://localhost:3456/api/resources/my-router-id ``` -------------------------------- ### Get Specific Middleware Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve details for a single middleware by its ID. ```bash curl http://localhost:3456/api/middlewares/abc123 ``` -------------------------------- ### Middleware Templates Example Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/configuration/templates.mdx Define common middleware configurations like security headers or rate limits using YAML. These templates are referenced when creating new middleware in the UI. ```yaml - name: security-headers type: headers config: headers: customResponseHeaders: X-Frame-Options: DENY X-Content-Type-Options: nosniff - name: ratelimit-basic type: ratelimit config: rateLimit: average: 100 burst: 50 ``` -------------------------------- ### Full Stack Development with Docker Compose Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Build and run the entire application stack using Docker Compose. This command starts the UI, API, and other services defined in the docker-compose file. ```bash docker compose up --build ``` -------------------------------- ### Get All Configured Data Sources Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve a list of all configured data sources, including their types and active status. This helps in understanding the current data source landscape. ```bash curl http://localhost:3456/api/datasource ``` -------------------------------- ### Get Traefik Static Configuration Path Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve the absolute path to the Traefik static configuration file. ```bash curl http://localhost:3456/api/plugins/configpath ``` -------------------------------- ### Get Overall Security Configuration Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves the current global security configuration, including settings for TLS hardening and secure response headers. ```bash curl http://localhost:3456/api/security/config ``` -------------------------------- ### Example config.json for Data Source Configuration Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe This JSON configuration defines the active data source and details for connecting to Pangolin and Traefik APIs. It's used to set up the Middleware Manager's data source connections. ```json { "active_data_source": "traefik", "data_sources": { "pangolin": { "type": "pangolin", "url": "http://pangolin:3001/api/v1", "basic_auth": { "username": "", "password": "" } }, "traefik": { "type": "traefik", "url": "http://traefik:8080", "basic_auth": { "username": "", "password": "" } } } } ``` -------------------------------- ### List Traefik Services by Type Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves lists of Traefik services, filterable by protocol type. Use 'all' to get services of all types. ```bash curl http://localhost:3456/api/traefik/services ``` ```bash curl "http://localhost:3456/api/traefik/services?type=all" ``` -------------------------------- ### Get Usage of a Specific Traefik Plugin Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Obtain information about the usage of a particular Traefik plugin by specifying its name. ```bash curl http://localhost:3456/api/plugins/crowdsec/usage ``` -------------------------------- ### Get Traefik Version Information Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Fetches the current version details of the Traefik instance. This is useful for compatibility checks and troubleshooting. ```bash curl http://localhost:3456/api/traefik/version ``` -------------------------------- ### Get Client Certificate Details Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves detailed information about a specific client certificate using its unique ID. This is useful for verifying certificate properties. ```bash curl http://localhost:3456/api/mtls/clients/cert789 ``` -------------------------------- ### Get Global mtlswhitelist Middleware Configuration Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves the current global configuration for the `mtlswhitelist` middleware. This includes settings like rejection messages and status codes. ```bash curl http://localhost:3456/api/mtls/middleware/config ``` -------------------------------- ### Get Merged Traefik Dynamic Configuration Source: https://context7.com/hhftechnology/middleware-manager/llms.txt This endpoint is polled by Traefik to get the merged dynamic configuration. It returns JSON or YAML. The cache can be invalidated on demand. ```bash curl http://localhost:3456/api/v1/traefik-config ``` ```bash # Also available at: /api/traefik-config ``` -------------------------------- ### Build Backend Binary (Go) Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Compile the Go application into an executable binary named 'middleware-manager'. ```bash go build -o middleware-manager main.go ``` -------------------------------- ### Build Backend Application (Go) Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe Compile the backend Go application into an executable binary. The output binary will be named 'middleware-manager'. ```bash go build -o middleware-manager ``` -------------------------------- ### Get a single resource Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves the details of a single resource by its ID. ```APIDOC ## GET /api/resources/{id} ### Description Retrieves the details of a single resource by its ID. ### Method GET ### Endpoint /api/resources/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the resource. ``` -------------------------------- ### Get a specific middleware Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves the details of a specific middleware by its ID. ```APIDOC ## GET /api/middlewares/{id} ### Description Retrieves the details of a specific middleware by its ID. ### Method GET ### Endpoint /api/middlewares/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the middleware. ``` -------------------------------- ### Create Basic Authentication Middleware Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Create a new basic authentication middleware. Requires 'name', 'type' (basicAuth), and 'config' with 'users' and 'realm'. ```bash curl -X POST http://localhost:3456/api/middlewares \ -H "Content-Type: application/json" \ -d '{ \ "name": "admin-auth", \ "type": "basicAuth", \ "config": { \ "users": ["admin:$apr1$...hashed..."], \ "realm": "Admin Area" \ } \ }' ``` -------------------------------- ### Get / Update / Delete a service Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Performs operations on a specific service identified by its ID. ```APIDOC ## Operations on /api/services/{id} ### Description Performs operations on a specific service identified by its ID. ### Methods - **GET**: Retrieves the details of a specific service. - **PUT**: Updates an existing service. - **DELETE**: Deletes a service. This operation will fail if the service is assigned to any resource. ### Endpoint /api/services/{id} ### Parameters #### Path Parameters (for GET, PUT, DELETE) - **id** (string) - Required - The unique identifier of the service. ### Request Body (for PUT) - **name** (string) - Optional - The new name for the service. - **type** (string) - Optional - The new type for the service. - **config** (object) - Optional - The new configuration for the service. ### Response (for DELETE) #### Success Response (200) - **message** (string) - Confirmation message indicating successful deletion. #### Error Response (e.g., 400) - **error** (string) - Message indicating the service is still in use. ``` -------------------------------- ### Get the Active Data Source Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Query the API to determine which data source is currently active. ```bash curl http://localhost:3456/api/datasource/active ``` -------------------------------- ### Run Backend Tests (Go) Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Execute all tests within the Go project. This command runs tests recursively in all subdirectories. ```bash go test ./... ``` -------------------------------- ### Update HTTP Entrypoints for a Resource Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Configure the HTTP entrypoints for a specific resource. Ensure the resource ID is correctly specified. ```bash curl -X PUT http://localhost:3456/api/resources/my-router-id/config/http \ -H "Content-Type: application/json" \ -d '{"entrypoints": "websecure,web"}' ``` -------------------------------- ### List all middlewares Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves a list of all configured middlewares. Supports optional pagination. ```APIDOC ## GET /api/middlewares ### Description Retrieves a list of all configured middlewares. Supports optional pagination. ### Method GET ### Endpoint /api/middlewares ### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **page_size** (integer) - Optional - The number of items per page. ``` -------------------------------- ### Enable Global mTLS Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Enables mTLS globally for the Traefik instance. This action requires the `mtlswhitelist` plugin to be installed and configured. ```bash curl -X PUT http://localhost:3456/api/mtls/enable ``` -------------------------------- ### List Middlewares with Pagination Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve a list of middlewares with support for cursor-based pagination. Specify page number and page size for paginated results. ```bash curl "http://localhost:3456/api/middlewares?page=2&page_size=25" ``` ```json { "data": [...], "pagination": { "page": 2, "page_size": 25, "total": 120, "total_pages": 5, "has_next": true, "has_prev": true } } ``` -------------------------------- ### List Middlewares (Paginated) Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve a list of all configured middlewares. Supports pagination with 'page' and 'page_size' query parameters. ```bash curl http://localhost:3456/api/middlewares curl "http://localhost:3456/api/middlewares?page=1&page_size=20" ``` -------------------------------- ### Create Rate-Limit Middleware Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Create a new rate-limiting middleware. Requires 'name', 'type' (rateLimit), and 'config' with 'average', 'burst', and 'period'. ```bash curl -X POST http://localhost:3456/api/middlewares \ -H "Content-Type: application/json" \ -d '{ \ "name": "rate-limit-100", \ "type": "rateLimit", \ "config": { \ "average": 100, \ "burst": 50, \ "period": "1m" \ } \ }' ``` -------------------------------- ### Get, Update, or Delete Service Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Perform CRUD operations on a specific service using its ID. Deletion fails if the service is assigned to any resource. ```bash curl http://localhost:3456/api/services/svc456 curl -X PUT http://localhost:3456/api/services/svc456 -H "Content-Type: application/json" -d '{...}' curl -X DELETE http://localhost:3456/api/services/svc456 ``` -------------------------------- ### List Traefik Entrypoints Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves a list of all configured entrypoints in Traefik. Entrypoints define the network interfaces Traefik listens on. ```bash curl http://localhost:3456/api/traefik/entrypoints ``` -------------------------------- ### Enable TCP Passthrough for a Resource Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Configure TCP passthrough for a resource, including specifying entrypoints and SNI rules. Global TCP settings might also apply. ```bash curl -X PUT http://localhost:3456/api/resources/my-router-id/config/tcp \ -H "Content-Type: application/json" \ -d '{ "tcp_enabled": true, "tcp_entrypoints": "tcp-51821", "tcp_sni_rule": "HostSNI(`myapp.example.com`)" }' ``` -------------------------------- ### Get Full Traefik Data Dump Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves a comprehensive dump of all routers, services, and middlewares configured in Traefik. This is useful for detailed inspection and debugging. ```bash curl http://localhost:3456/api/traefik/data ``` -------------------------------- ### List All Middlewares Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve the full list of middlewares without pagination. This returns an array of middleware objects. ```bash curl http://localhost:3456/api/middlewares ``` ```json [{"id":"...","name":"..."},...] ``` -------------------------------- ### Custom Middleware Templates Configuration Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe This YAML configuration defines custom middleware templates for the Middleware Manager. It includes examples for security headers and rate limiting. ```yaml middlewares: - id: "security-headers" name: "Strong Security Headers" type: "headers" config: customResponseHeaders: Server: "" X-Powered-By: "" browserXSSFilter: true contentTypeNosniff: true customFrameOptionsValue: "SAMEORIGIN" forceSTSHeader: true stsIncludeSubdomains: true stsSeconds: 63072000 - id: "rate-limit" name: "Standard Rate Limiting" type: "rateLimit" config: average: 100 burst: 50 ``` -------------------------------- ### Test Connection to a Data Source Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Perform a connection test to a specified data source to verify its availability and configuration. This is useful for troubleshooting. ```bash curl -X POST http://localhost:3456/api/datasource/pangolin/test ``` -------------------------------- ### Download Client Certificate (PKCS#12) Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Downloads a client certificate in PKCS#12 (.p12) format, which is commonly used for importing into browsers and other applications. The `-O` flag saves the file, and `-J` suggests a filename. ```bash curl -O -J http://localhost:3456/api/mtls/clients/cert789/download ``` -------------------------------- ### Create Weighted Service Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Create a new weighted service for traffic splitting. Requires 'name', 'type' (weighted), and 'config' with a list of 'services' and their respective 'weight'. ```bash curl -X POST http://localhost:3456/api/services \ -H "Content-Type: application/json" \ -d '{ \ "name": "canary-split", \ "type": "weighted", \ "config": { \ "services": [ \ {"name": "stable@file", "weight": 90}, \ {"name": "canary@file", "weight": 10} \ ] \ } \ }' ``` -------------------------------- ### Get Middleware Manager Container IP Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/getting-started/deploy-pangolin.mdx Use this command to inspect the middleware-manager container and retrieve its IP address, which can be used in the Traefik configuration if hostname resolution fails. ```bash docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' middleware-manager ``` -------------------------------- ### Get Traefik Config Proxy Status Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve the status of the Traefik config proxy, including the active source, upstream URL, last fetch time, and cache age. ```bash curl http://localhost:3456/api/v1/traefik-config/status ``` -------------------------------- ### Get mTLS Configuration and Client Count Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieves the current mTLS configuration settings and the total count of issued client certificates. This endpoint requires the `mtlswhitelist` Traefik plugin. ```bash curl http://localhost:3456/api/mtls/config ``` -------------------------------- ### Configure mTLS Whitelist Plugin Rules for a Resource Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Set up rules for the mTLS whitelist plugin on a per-resource basis, including client identification, request header manipulation, and rejection policies. ```bash curl -X PUT http://localhost:3456/api/resources/my-router-id/config/mtlswhitelist \ -H "Content-Type: application/json" \ -d '{ "rules": [{"cn": "client1", "ou": "engineering"}], "request_headers": {"X-Client-CN": "{{.Subject.CommonName}}"}, "reject_message": "Client certificate required", "reject_code": 403, "refresh_interval": "30s" }' ``` -------------------------------- ### Browse Public Traefik Plugin Catalogue Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Fetch a list of available plugins from the public Traefik plugin catalogue, which is sourced from plugins.traefik.io. ```bash curl http://localhost:3456/api/plugins/catalogue ``` -------------------------------- ### List Traefik Middlewares by Type Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Fetches lists of Traefik middlewares, filterable by protocol type. Use 'all' to retrieve all middleware types. ```bash curl http://localhost:3456/api/traefik/middlewares ``` ```bash curl "http://localhost:3456/api/traefik/middlewares?type=all" ``` -------------------------------- ### Get Traefik Dashboard Overview Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve a summary of Traefik's current state, including counts of routers, services, and middlewares. This provides a quick health check of your Traefik instance. ```bash curl http://localhost:3456/api/traefik/overview ``` -------------------------------- ### Create Certificate Authority (CA) Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Creates a new Certificate Authority (CA) for managing client certificates. This involves specifying details like common name, organization, and validity period. Certificates are stored in SQLite and the CA cert/key are written to disk. ```bash curl -X POST http://localhost:3456/api/mtls/ca \ -H "Content-Type: application/json" \ -d '{ "common_name": "My Internal CA", "organization": "ACME Corp", "country": "US", "valid_days": 3650 }' ``` -------------------------------- ### Add Middleware Manager to Pangolin docker-compose.yml Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe Integrate the Middleware Manager into your existing Pangolin stack by adding this service definition to your docker-compose.yml. Ensure volumes and environment variables are correctly configured for your setup. ```yaml middleware-manager: image: hhftechnology/middleware-manager:latest container_name: middleware-manager restart: unless-stopped volumes: - ./data:/data - ./config/traefik/rules:/conf - ./config/middleware-manager/templates.yaml:/app/config/templates.yaml # Optional for custom templates environment: - PANGOLIN_API_URL=http://pangolin:3001/api/v1 - TRAEFIK_CONF_DIR=/conf - DB_PATH=/data/middleware.db - PORT=3456 ports: - "3456:3456" ``` -------------------------------- ### Middlewares Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/api/overview.mdx Manage middlewares including listing, creating, retrieving, updating, and deleting. ```APIDOC ## Middlewares ### List Middlewares - `GET /middlewares` ### Create Middleware - `POST /middlewares` ### Get Middleware by ID - `GET /middlewares/:id` ### Update Middleware by ID - `PUT /middlewares/:id` ### Delete Middleware by ID - `DELETE /middlewares/:id` ``` -------------------------------- ### Preserve Traefik Logging and Plugins Configuration Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/reverting/revert-traefik.mdx When reverting Traefik's provider, merge and retain your logging and plugin configurations from the static config to prevent data loss. This example shows how to keep custom access log settings and experimental plugin definitions. ```yaml accessLog: bufferingSize: 100 fields: defaultMode: drop headers: defaultMode: drop names: Authorization: redact Content-Type: keep Cookie: redact User-Agent: keep X-Forwarded-For: keep X-Forwarded-Proto: keep X-Real-Ip: keep names: ClientAddr: keep ClientHost: keep DownstreamContentSize: keep DownstreamStatus: keep Duration: keep RequestMethod: keep RequestPath: keep RequestProtocol: keep RetryAttempts: keep ServiceName: keep StartUTC: keep TLSCipher: keep TLSVersion: keep filePath: /var/log/traefik/access.log filters: minDuration: 100ms retryAttempts: true statusCodes: - 200-299 - 400-499 - 500-599 format: json experimental: plugins: badger: moduleName: github.com/fosrl/badger version: v1.2.0 crowdsec: moduleName: github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin version: v1.4.4 mtlswhitelist: moduleName: github.com/smerschjohann/mtlswhitelist version: v0.3.0 ``` -------------------------------- ### mTLS Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/api/overview.mdx Manage mTLS configurations, CA, certificates, and plugin settings. ```APIDOC ## mTLS ### Get mTLS Config - `GET /mtls/config` ### Enable/Disable mTLS - `PUT /mtls/enable` - `PUT /mtls/disable` ### Certificate Authority (CA) - `POST /mtls/ca` - `DELETE /mtls/ca` ### Client Certificates - `GET /mtls/clients` - `POST /mtls/clients` - `GET /mtls/clients/:id` - `GET /mtls/clients/:id/download` - `PUT /mtls/clients/:id/revoke` - `DELETE /mtls/clients/:id` ### Plugin Check/Config - `GET /mtls/plugin/check` - `GET /mtls/middleware/config` - `PUT /mtls/middleware/config` ``` -------------------------------- ### Configure Traefik Plugins Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe Add Traefik plugins to your static configuration. Ensure the moduleName and version are correct for each plugin. ```yaml experimental: plugins: crowdsec: moduleName: github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin version: v1.4.2 geoblock: moduleName: github.com/PascalMinder/geoblock version: v0.3.2 ``` -------------------------------- ### List Services (Active Only) Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve a list of all active services. To view all services regardless of status, use the '?status=all' query parameter. ```bash curl http://localhost:3456/api/services curl "http://localhost:3456/api/services?status=all" ``` -------------------------------- ### List Resources (Active, Paginated) Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Retrieve a list of all active resources. Supports filtering by 'status', 'source_type', and pagination with 'page' and 'page_size'. ```bash curl http://localhost:3456/api/resources curl "http://localhost:3456/api/resources?status=active&source_type=pangolin&page=1&page_size=50" ``` -------------------------------- ### Assign Single Middleware to Resource Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Assign a single middleware to a resource. The 'priority' field determines the order of execution, with 200 being the default. ```bash curl -X POST http://localhost:3456/api/resources/my-router-id/middlewares \ -H "Content-Type: application/json" \ -d '{"middleware_id": "abc123", "priority": 300}' ``` -------------------------------- ### Configure Data Sources in config.json Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/configuration/data-sources.mdx Define Pangolin and Traefik data sources, including their URLs and authentication, within the `config.json` file. Set the `active_data_source` to 'pangolin' or 'traefik'. ```json { "active_data_source": "traefik", "data_sources": { "pangolin": { "type": "pangolin", "url": "http://pangolin:3001/api/v1", "basic_auth": { "username": "", "password": "" } }, "traefik": { "type": "traefik", "url": "http://traefik:8080", "basic_auth": { "username": "", "password": "" } } } } ``` -------------------------------- ### Create Load Balancer Service Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Create a new load balancer service. Requires 'name', 'type' (loadBalancer), and 'config' including 'servers' and optional 'healthCheck'. ```bash curl -X POST http://localhost:3456/api/services \ -H "Content-Type: application/json" \ -d '{ \ "name": "backend-lb", \ "type": "loadBalancer", \ "config": { \ "servers": [ \ {"url": "http://backend1:8080"}, \ {"url": "http://backend2:8080"} \ ], \ "healthCheck": { \ "path": "/health", \ "interval": "10s", \ "timeout": "3s" \ }, \ "passHostHeader": true \ } \ }' ``` -------------------------------- ### Configure Middleware Manager for Standalone Traefik Source: https://github.com/hhftechnology/middleware-manager/wiki/Old_ReadMe Set up the Middleware Manager to connect directly to a standalone Traefik instance. This involves creating a `config.json` file to specify Traefik as the active data source and configuring the `docker-compose.yml` accordingly. ```json { "active_data_source": "traefik", "data_sources": { "traefik": { "type": "traefik", "url": "http://traefik:8080", "basic_auth": { "username": "", "password": "" } } } } ``` ```yaml middleware-manager: image: hhftechnology/middleware-manager:latest container_name: middleware-manager restart: unless-stopped volumes: - ./data:/data - ./config/traefik/rules:/conf - ./config/middleware-manager/config.json:/app/config/config.json environment: - TRAEFIK_API_URL=http://traefik:8080 - TRAEFIK_CONF_DIR=/conf - DB_PATH=/data/middleware.db - PORT=3456 - ACTIVE_DATA_SOURCE=traefik ports: - "3456:3456" ``` -------------------------------- ### Enable mTLS on a Resource Source: https://context7.com/hhftechnology/middleware-manager/llms.txt Enable mutual TLS (mTLS) for a specific resource. Note that global mTLS must be enabled first. ```bash curl -X PUT http://localhost:3456/api/resources/my-router-id/config/mtls \ -H "Content-Type: application/json" \ -d '{"mtls_enabled": true}' ``` -------------------------------- ### File and Folder Structure Representation Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/development/dev-guide.mdx This code snippet uses Fumadocs UI components to visually represent the project's file and folder layout. ```tsx import { File, Folder, Files } from 'fumadocs-ui/components/files'; ``` -------------------------------- ### Middleware Manager Environment Variables Reference Source: https://context7.com/hhftechnology/middleware-manager/llms.txt This is a comprehensive list of environment variables for configuring Middleware Manager. Key variables include data sources, Traefik paths, ports, and debugging options. ```bash # Complete .env reference PORT=3456 # UI + API listen port DB_PATH=/data/middleware.db # SQLite persistence TRAEFIK_CONF_DIR=/conf # Where dynamic config is written TRAEFIK_STATIC_CONFIG_PATH=/etc/traefik/traefik.yml # Static config for plugin installs ACTIVE_DATA_SOURCE=pangolin # "pangolin" or "traefik" PANGOLIN_API_URL=http://pangolin:3001/api/v1 # Pangolin base URL TRAEFIK_API_URL=http://traefik:8080 # Traefik API base URL CHECK_INTERVAL_SECONDS=30 # Resource discovery poll interval SERVICE_INTERVAL_SECONDS=30 # Service poll interval DEBUG=false # Enables Gin request logger ALLOW_CORS=true # Enable CORS CORS_ORIGIN=https://admin.example.com # Restrict CORS origin (empty = all) LOG_LEVEL=info ``` -------------------------------- ### Services Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/api/overview.mdx Manage services including listing, creating, retrieving, updating, and deleting. ```APIDOC ## Services ### List Services - `GET /services` ### Create Service - `POST /services` ### Get Service by ID - `GET /services/:id` ### Update Service by ID - `PUT /services/:id` ### Delete Service by ID - `DELETE /services/:id` ``` -------------------------------- ### Data Source Source: https://github.com/hhftechnology/middleware-manager/blob/main/docs/docs/content/docs/api/overview.mdx Manage data source configurations and status. ```APIDOC ## Data Source ### Get Data Source - `GET /datasource` ### Get Active Data Source - `GET /datasource/active` ### Set Active Data Source - `PUT /datasource/active` ### Update Data Source by Name - `PUT /datasource/:name` ### Test Data Source by Name - `POST /datasource/:name/test` ```