Remark42 Documentation

repository·master·Indexed 26 days ago

https://github.com/umputun/remark42

A self-hosted, lightweight, and privacy-focused comment engine for websites. It features multi-level nested comments, Markdown support, social login (Google, Facebook, GitHub, etc.), and a single-file data storage system that requires no external database. The documentation covers server configuration via CLI and environment variables, administrative commands for backup, restore, import, and cleanup, and development setup for the @remark42/api package and site.

Tokens
31.3K
Snippets
62
Records
145
Agent score
88%

What's inside Remark42

  1. Overview of Remark42 features

    master

    Remark42 is a self-hosted, privacy-focused, and lightweight commenting engine designed to be embedded into blogs, articles, or other websites. It supports multi-site mode from a single instance and can be deployed as a Docker container or a self-contained executable for Linux, Windows, and macOS.

    Key features include:

    • Authentication: Social login (Google, Facebook, Microsoft, GitHub, Apple, Yandex, Patreon, Telegram, and custom OAuth2), email login, and optional anonymous access.
    • Comment Management: Multi-level nested comments (tree or plain), voting, pinning, verification, and sorting.
    • Content & Media: Markdown support with a formatter toolbar and drag-and-drop image uploads.
    • Integrations: Import from Disqus and WordPress; RSS feeds for all comments and individual posts; admin notifications via Telegram, Slack, email, and webhooks.
    • Data Management: Export data to JSON with automatic backups; no external databases required (uses a single embedded data file).
    • UI: Customizable lightweight UI with white and dark themes.
  2. Overview of Remark42 comment engine

    master
    Remark42 is a self-hosted, lightweight, and privacy-focused comment engine designed to be embedded into blogs, articles, or other websites. It supports multi-level nested comments, Markdown with a toolbar, and various authentication methods including social logins (Google, Facebook, GitHub, etc.), email, and optional anonymous access. It features a single-file data storage system (no external database required), multi-site mode, and built-in moderation tools.
  3. Manage users and comments via the Admin UI

    master

    Once authenticated as an administrator, you have access to the following management capabilities:

    • Show settings: View lists of blocked and hidden users.
    • Disable comments: Disable comments for a specific post (can be re-enabled at any time).
    • Block users: Block users either permanently or temporarily.
    • Delete comments: Remove specific comments from the system.
  4. Privacy and Data Security in Remark42

    master

    Remark42 is designed to be privacy-sensitive and avoids tracking or third-party analytics.

    Data Handling & Security:

    • Minimal Data Collection: Only user ID, username, and avatar links are kept. IDs and names are hashed, and avatars are proxied to prevent direct exposure.
    • Authentication Security: Uses JWT stored in HttpOnly, secured cookies. A second cookie, XSRF_TOKEN, is used to prevent CSRF attacks.
    • No Cross-Site Tracking: User behavior cannot be analyzed across independent sites running Remark42.
    • Encryption: All potentially sensitive data is hashed and encrypted.
    • User Rights: Users can request an export of all their information (provided as a .gz file) or use the deleteme request to trigger a complete cleanup of their activity data.
    • Session Control: Cookie lifespan can be restricted to session-only.
  5. Restore a Remark42 backup

    master

    The restore command cleans all existing comments on a site before performing a complete import from the specified file.

    For security, the restore functionality is not exposed outside the server by default. The recommended method is to use docker exec to run the command inside the container. Note that ADMIN_PASSWD must be enabled on the server for this to work.

    Use the following command structure: docker exec -it remark42 restore -f {backup-filename.gz} -s {your site ID}

    docker exec -it remark42 restore -f {backup-filename.gz} -s {your site ID}
  6. Configure Trusted Proxies for Client IP accuracy

    master

    Remark42 uses the client IP for rate limiting and vote de-duplication. When running behind a reverse proxy (nginx, Cloudflare, etc.), Remark42 sees the proxy's IP instead of the visitor's.

    To fix this, use --trusted-proxy or TRUSTED_PROXY to provide a comma-separated list of CIDRs or IPs that represent your proxy's network. Remark42 will then honor forwarding headers (X-Real-IP, CF-Connecting-IP, or X-Forwarded-For) only if the request comes from a trusted peer.

    Security Warning: If Remark42 is reachable from the internet, you must set this. If you don't, attackers can spoof headers to bypass rate limits.

    Deployment Examples:

    • nginx in same Docker Compose: Use the Docker network range (e.g., 172.16.0.0/12).
    • Single upstream proxy: Use the proxy's IP (e.g., 10.0.0.5).
    • Directly exposed (no proxy): Use 127.0.0.1/32 to ensure forwarding headers are always ignored.
    # docker-compose: nginx on the same network
    TRUSTED_PROXY=172.16.0.0/12
    
    # a single upstream proxy
    --trusted-proxy=10.0.0.5
    
    # multiple ranges (v4 and v6)
    TRUSTED_PROXY=10.0.0.0/8,fd00::/8
  7. Customize email and error message HTML templates

    master

    Remark42 uses Go templates for emails and error messages. To override the default embedded templates, place files with the same name in the directory containing the Remark42 executable.

    If using Docker Compose, mount the custom templates as read-only volumes:

    volumes:
      - ./customised_templates/email_confirmation_login.html.tmpl:/srv/email_confirmation_login.html.tmpl:ro
      - ./customised_templates/email_confirmation_subscription.html.tmpl:/srv/email_confirmation_subscription.html.tmpl:ro
      - ./customised_templates/email_reply.html.tmpl:/srv/email_reply.html.tmpl:ro
      - ./customised_templates/email_unsubscribe.html.tmpl:/srv/email_unsubscribe.html.tmpl:ro
      - ./customised_templates/error_response.html.tmpl:/srv/error_response.html.tmpl:ro
  8. Migrate Button component to CSS Modules

    master

    To migrate the button component from BEM to CSS Modules, consolidate all existing BEM CSS files into a single button.module.css. In the component file, replace bem-react-helper with clsx and a local styles object. Use lookup objects to map dynamic props like kind, size, and theme to their corresponding CSS module classes.

    Files to modify:

    • frontend/apps/remark42/app/components/button/button.tsx
    • frontend/apps/remark42/app/components/button/index.ts

    Files to create:

    • frontend/apps/remark42/app/components/button/button.module.css
  9. Run Remark42 with the memory_store plugin

    master

    The memory_store package is a sample implementation demonstrating how to create custom storage plugins for Remark42. To run Remark42 using this memory store implementation via Docker Compose, follow these steps:

    1. Copy the provided compose-dev-memstore.yml to your root directory.
    2. Build the containers: docker compose -f compose-dev-memstore.yml build
    3. Start the services: docker compose -f compose-dev-memstore.yml up

    Once running, the demo site will be available at http://127.0.0.1:8080/web/.

    docker compose -f compose-dev-memstore.yml build
    docker compose -f compose-dev-memstore.yml up
  10. Migrate Thread component to CSS Modules

    master

    The thread component migration consolidates BEM files into thread.module.css. The component uses clsx to handle conditional classes for indentation, nesting levels, and theme.

    Implementation details:

    • Use styles.root for the base class.
    • Use styles.indented for margin-left adjustments.
    • Use styles.level6 for specific nesting logic.
    • Toggle between styles.collapse and styles.collapsed based on the component state.

    Files to modify:

    • frontend/apps/remark42/app/components/thread/thread.tsx
    • frontend/apps/remark42/app/components/thread/index.ts

    Files to create:

    • frontend/apps/remark42/app/components/thread/thread.module.css
  11. Import/restore without removing existing comments

    master

    Because the restore command deletes all existing comments on a site, you can preserve them by merging existing data with your new import file.

    Remark42 backups use a plain JSON with EOL (JSON Lines) format. To merge content (for example, from a WordPress export) while avoiding duplicate Remark42 metadata, filter out the Remark42 version lines from the source and append them to your combined file before restoring:

    1. Prepare a combined JSONL file by filtering and appending data.
    2. Run the restore command using the combined file.
    cat wp-export.json | grep -v '{"version":1' >> combined-export.json
    docker exec -it remark42 restore -f combined-export.json -s {your site ID}