kutt

repository·main·Indexed 27 days ago

https://github.com/thedevs-network/kutt

A modern, self-hostable URL shortener supporting custom domains, link management, and detailed statistics. Version 3.2.6 supports multiple databases (SQLite, Postgres, MySQL/MariaDB), Redis caching, and OIDC authentication. It can be deployed via Node.js or Docker Compose and allows for interface customization through a dedicated /custom directory for CSS, images, and Handlebars views.

Tokens
2.5K
Snippets
5
Records
17
Agent score
95%

What's inside kutt

  1. Customize Kutt themes and styles

    main

    You can customize the Kutt interface by placing files in the /custom directory. This allows you to add custom CSS, replace images, or render custom HTML templates.

    Directory Structure

    custom/
    ├─ css/
    │  ├─ custom1.css
    │  ├─ custom2.css
    │  └─ styles.css (replaces original styles.css)
    ├─ images/
    │  ├─ logo.png (replaces original logo.png)
    │  └─ favicon.ico
    └─ views/
       ├─ partials/
       │  └─ footer.hbs
       └─ 404.hbs

    Customization Details

    • CSS: Files in /custom/css/ are accessible via <your-site.com>/css/<file>.css. Naming a file styles.css will override the default Kutt stylesheet.
    • Images: Place images in /custom/images/ with the same names as those in the /static/images/ directory to replace them. They are accessible via <your-site.com>/images/<image>.<format>.
    • Views: Custom HTML templates in /custom/views/ must follow the same naming and folder structure as the original /server/views/ directory. Note that updates to Kutt may break custom views if file structures change.
  2. Install and Setup Kutt via Node.js

    main

    To run Kutt locally, you need Node.js (version 20 or above). The default database is SQLite, but you can optionally use Postgres, MySQL/MariaDB, or Redis for caching.

    Follow these steps to set up the development environment:

    1. Clone the repository or download the latest zip.
    2. Install dependencies using npm install.
    3. Initialize the database using npm run migrate.
    4. Start the application in development mode with npm run dev or in production mode with npm start.

    Note: When you first start the app, you will be prompted to create an admin account.

    npm install
    npm run migrate
    npm run dev
  3. Run Kutt using Docker Compose

    main

    Kutt can be deployed using Docker Compose. Ensure Docker is installed, then use the appropriate configuration file from the root directory to start the service.

    Available configurations:

    • docker-compose.yml: Default setup using SQLite.
    • docker-compose.sqlite-redis.yml: Uses SQLite and Redis (requires REDIS_ENABLED).
    • docker-compose.postgres.yml: Uses Postgres and Redis (requires REDIS_ENABLED, DB_PASSWORD, DB_NAME, DB_USER).
    • docker-compose.mariadb.yml: Uses MariaDB and Redis (requires REDIS_ENABLED, DB_PASSWORD, DB_NAME, DB_USER, DB_PORT).

    The official image is available on Docker Hub as kutt/kutt.

    docker compose -f <file_name> up
  4. Apply custom themes using Docker

    main

    If you are running Kutt via Docker, you must ensure your /custom folder is accessible to the container.

    1. Official Images: Ensure the /kutt/custom volume is mounted in your Docker configuration.
    2. Copying Files: If you are not using a volume, you can copy your local custom folder into the running container using docker cp.
    3. Restart: You must restart the Kutt server container after copying files or making changes for them to take effect.
  5. Configure Kutt via Environment Variables

    main

    Kutt is configured using environment variables. You can provide them directly or via a .env file. Most variables are optional, except for JWT_SECRET, which is required for production environments.

    To use a file for a specific variable instead of a string, append _FILE to the variable name (e.g., JWT_SECRET_FILE=/path/to/secret_file).

    For a full list of available configuration keys, refer to the .example.env file in the repository.

  6. Customize Static Assets and Views

    main

    Kutt supports custom themes and assets by looking into specific directories. You can override default behavior by placing files in the custom/ directory:

    • Images: /images maps to custom/images
    • CSS: /css maps to custom/css
    • Views: Handlebars templates in custom/views take precedence over default views in views/.
  7. Deploy Kutt using Docker Compose

    main

    You can deploy Kutt using Docker Compose. The setup includes a server service that builds from the local context and exposes port 3000. It uses two persistent volumes: db_data_sqlite for the SQLite database and custom for custom configurations/assets.

    services:
      server:
        build:
          context: .
        volumes:
           - db_data_sqlite:/var/lib/kutt
           - custom:/kutt/custom
        environment:
          DB_FILENAME: "/var/lib/kutt/data.sqlite"
        ports:
          - 3000:3000
    volumes:
      db_data_sqlite:
      custom:
  8. Reference: Mail and OIDC Configuration Variables

    main

    Configure email services for user management and OpenID Connect (OIDC) for authentication.

    | Variable | Description | Default |
    | -------- | ----------- | ------- |
    | `MAIL_ENABLED` | Enable emails (signup, verification, etc.) | `false` |
    | `MAIL_HOST` | Email server host | - |
    | `MAIL_PORT` | Email server port | `587` |
    | `MAIL_USER` | Email server user | - |
    | `MAIL_PASSWORD` | Email server password | - |
    | `MAIL_FROM` | Email address to send the user from | - |
    | `MAIL_SECURE` | Whether to use SSL for email | `false` |
    | `OIDC_ENABLED` | Enable OpenID Connect | `false` |
    | `OIDC_ISSUER` | OIDC issuer URL | - |
    | `OIDC_POMPT` | OIDC prompt | `login` |
    | `OIDC_CLIENT_ID` | OIDC client id | - |
    | `OIDC_CLIENT_SECRET` | OIDC client secret | - |
    | `OIDC_SCOPE` | OIDC Scope | `openid profile email` |
    | `OIDC_EMAIL_CLAIM` | Name of the field to get user's email from | `email` |
    | `OIDC_BUTTON_TEXT` | OIDC login button text | `Log in with OIDC` |