Skip to content

LinusTrevian/Board

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Warehouse Blog - Cloudflare Frontend + Local C Backend

This repository is a reusable self-hosted template for a split deployment:

  • your-frontend-domain.example: Cloudflare-hosted static frontend
  • your-api-domain.example: local cloudflared tunnel -> local C backend
  • data storage: local SQLite + exported JSON mirror + local avatar files

Security cleanup in this repository

This version has been sanitized for public release:

  • removed project-specific Cloudflare Tunnel UUIDs and hostnames
  • removed personal admin account data and replaced it with template values
  • replaced public API domain examples with placeholders
  • replaced example admin credentials with generic starter values that you should change immediately

Layout

  • web/ static frontend files
  • backend/ C backend (libmicrohttpd + sqlite3 + jansson + curl + openssl)
  • data/warehouse-blog.sqlite3 local SQLite database
  • data/export/site-state.json JSON mirror export
  • data/uploads/avatars/ local avatar files
  • tools/api_health_logger.py helper logger / health checker
  • backend/deploy/cloudflared/config.api.example.yml example tunnel config

Fedora 43 dependencies

sudo dnf install -y gcc make pkgconf-pkg-config unzip curl ca-certificates   libmicrohttpd-devel sqlite-devel jansson-devel libcurl-devel openssl-devel python3

Debian 13 dependencies

sudo apt-get update
sudo apt-get install -y build-essential pkg-config unzip curl ca-certificates   libmicrohttpd-dev libsqlite3-dev libjansson-dev libcurl4-openssl-dev libssl-dev python3

Build

cd backend
make
cd ..

Local backend run

cp ./backend/scripts/server.env.example ./backend/scripts/server.env
set -a
source ./backend/scripts/server.env
set +a
./backend/warehouse-blog-server

Open local test page:

Frontend API configuration

The frontend uses the following API base resolution order:

  1. window.WAREHOUSE_API_BASE
  2. data-api-base on the root HTML element
  3. same-origin for localhost / IP
  4. fallback placeholder: https://your-api-domain.example

Before production deployment, replace the placeholder with your real API origin.

Cloudflare frontend

Upload the contents of web/ to your Cloudflare static hosting project for your own domain.

Local API through Cloudflare Tunnel

  1. Install cloudflared
  2. cloudflared tunnel login
  3. cloudflared tunnel create your-blog-api
  4. Bind your-api-domain.example to that tunnel
  5. Use the example config from backend/deploy/cloudflared/config.api.example.yml

Example:

cloudflared tunnel route dns your-blog-api your-api-domain.example
cloudflared --config ~/.cloudflared/config.yml tunnel run your-blog-api

Cookie / CORS notes

  • For local HTTP testing keep WB_COOKIE_SECURE=0
  • For production HTTPS, change it to WB_COOKIE_SECURE=1
  • Update WB_ALLOWED_ORIGINS so it only contains your real frontend origins
  • Leave WB_COOKIE_DOMAIN='' unless you explicitly want to widen cookie scope

Python helper logger

python3 ./tools/api_health_logger.py   --local http://ip/api/health   --public https://your-api-domain.example/api/health   --profile https://your-api-domain.example/api/site-profile?lang=en

The logger writes to ./logs/api-health.log by default.

About

Personal website source code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors