dockdv/webnote

By dockdv

Updated 4 months ago

Self-hosted notepad web server built with Node.js. Create, edit, delete notes via a web interface.

Image
Content Management System
Databases & Storage

48

Notepad Web Application

A lightweight notepad web server built with Node.js, allowing users to create, view, edit, delete, and rename notes via a web interface. The application can be easily deployed using Docker and Docker Compose. This project is ideal for users who need a simple and persistent note-taking application that can be run in a local network or across multiple machines.

The notepad is useful for collaborative note-taking, personal reminders, or managing quick notes across multiple devices without needing a third-party service. By using this application, users can maintain their own self-hosted notepad with full control over data storage and network configuration.

Features

  • Add, view, edit, rename, and delete text-based notes.
  • Responsive user interface with buttons aligned for easy navigation.
  • Pages automatically open in new browser tabs.
  • Dockerized for easy deployment and portability.
  • Supports HTTP, HTTPS, or both modes via environment variables.
  • SSL certificates can be mounted via Docker volumes.
  • Configurable for local networks or specific IP addresses using Docker Compose.

Table of Contents

What Is It For?

The Notepad Web Application is a simple, self-hosted note-taking service that can be deployed in a local network. This is particularly useful in environments where you want a shared notepad accessible over a local network, such as:

  • Personal use in your home network.
  • Collaborative work in a small office.
  • Temporary note storage for shared devices without relying on cloud-based services.
  • A lightweight solution for quick note management with the flexibility of Docker.

Docker Setup

Use Pre-Built Image from Docker Hub

The source code for this project is available on GitHub. However, if you want to use the pre-built Docker image hosted on Docker Hub without building the image locally, follow these steps:

  1. Update compose.yml:

    Modify your docker-compose.yml file to use the pre-built image from Docker Hub:

    services:
      webnote:
        image: dockdv/webnote:latest  # Use pre-built image from Docker Hub
        container_name: webnote
        environment:
          - MODE=http    # Choose between 'http', 'https', or 'both'
          - HTTP_PORT=80
          - HTTPS_PORT=443
          - SSL_KEY_PATH=/certs/ssl.key
          - SSL_CERT_PATH=/certs/ssl.cert
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - ./data:/app/data
          - ./certs:/certs:ro
        networks:
          xlan:
            ipv4_address: 192.168.1.10  # Update with your preferred IP address
    
    networks:
      xlan:
        external: true
    
  2. Pull the Pre-Built Image:

    You can directly pull the image from Docker Hub by running:

    docker compose pull
    
  3. Start the Application:

    After pulling the image, start the application with:

    docker compose up
    

    The application will now run using the pre-built image from Docker Hub without needing to build it locally.

Network Configuration

The Docker Compose file is configured to use an external network named xlan. This allows the notepad server to be reachable from other devices on the same network. By default, it uses the IP address 192.168.1.10, but this can be customized in the compose.yml file.

Certificate Setup

To enable HTTPS for your Notepad Web Application, you will need to configure SSL certificates. Follow the steps below to set up SSL for secure connections:

  1. Obtain SSL Certificates:

    You can obtain SSL certificates using services like Let's Encrypt or by purchasing certificates from a Certificate Authority (CA). Once you have the necessary certificates, you should have two files:

    • SSL Key File (e.g., ssl.key)
    • SSL Certificate File (e.g., ssl.cert)
  2. Mount SSL Certificates:

    The Docker Compose file should be updated to mount the SSL certificates into the Docker container. Modify the compose.yml file as shown below to include volumes that point to your certificate paths:

    services:
      webnote:
        environment:
          - MODE=https    # Enable HTTPS mode
          - HTTPS_PORT=443
          - SSL_KEY_PATH=/certs/ssl.key
          - SSL_CERT_PATH=/certs/ssl.cert
        ports:
          - "443:443"
        volumes:
          - ./certs:/certs:ro   # Mount the SSL certificates into the container
    

    Ensure that the ./certs directory contains your ssl.key and ssl.cert files. These files will be mounted into the /certs directory within the container.

  3. Start the Container with HTTPS:

    Once the certificates are properly mounted and the Docker Compose configuration is updated, start the container:

    docker compose up
    

    Your application will now be accessible over HTTPS at the IP address you configured (e.g., https://192.168.1.10).

Self-Generated Certificates

If you don't want to use an external Certificate Authority (CA) and would prefer to generate self-signed certificates for testing or internal use, follow the steps below:

  1. Generate Self-Signed Certificates:

    You can generate self-signed SSL certificates using the openssl command. Run the following command in your terminal:

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout certs/ssl.key -out certs/ssl.cert
    

    This command will generate a private key (ssl.key) and a self-signed certificate (ssl.cert) valid for 365 days. During the process, you will be prompted to enter information such as your country, state, and organization.

  2. Mount Self-Signed Certificates:

    After generating the self-signed certificates, place them in the certs directory and update your docker-compose.yml file to mount the certificates as shown in the previous section.

  3. Start the Application with Self-Signed Certificates:

    Once your self-signed certificates are in place, start the application with Docker Compose:

    docker compose up
    

    Your application will now be accessible over HTTPS with the self-signed certificates. Note that self-signed certificates will display a browser warning since they are not issued by a trusted CA.

Configuration

The application can be configured using the following environment variables:

  • MODE: Set the mode of the server (http, https, or both).
  • HTTP_PORT: Port for the HTTP server (default is 80).
  • HTTPS_PORT: Port for the HTTPS server (default is 443).
  • SSL_KEY_PATH: Path to the SSL private key file.
  • SSL_CERT_PATH: Path to the SSL certificate file.
Accessing the Application

After running the Docker container, the application will be available at the IP address specified in the compose.yml file. By default, it is set to:

  • HTTP: http://192.168.1.10
  • HTTPS: https://192.168.1.10

You can access the application by entering this IP address in your web browser. If you need to change the IP address, update the compose.yml file and restart the container.

Docker Compose Commands
  • To Run the Application:

    docker compose up
    

Source Code

If you are interested in the source code or want to contribute to the project, please visit the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Docker Pull Command

docker pull dockdv/webnote