diff --git a/Caddyfile b/Caddyfile
new file mode 100644
index 0000000..bc7a5f8
--- /dev/null
+++ b/Caddyfile
@@ -0,0 +1,24 @@
+# Caddyfile
+# Use the domain name passed from docker-compose environment
+{$DOMAIN_NAME} {
+ # Enable compression
+ encode zstd gzip
+
+ # Proxy API requests to the backend service
+ handle_path /api/* {
+ reverse_proxy backend:3001
+ }
+
+ # Proxy all other requests to the client service
+ handle {
+ reverse_proxy client:3002
+ }
+
+ # Optional: Add security headers (example)
+ # header {
+ # Strict-Transport-Security max-age=31536000;
+ # X-Content-Type-Options nosniff
+ # X-Frame-Options DENY
+ # Referrer-Policy strict-origin-when-cross-origin
+ # }
+}
\ No newline at end of file
diff --git a/client/Dockerfile b/client/Dockerfile
index 49ff948..e666336 100644
--- a/client/Dockerfile
+++ b/client/Dockerfile
@@ -17,7 +17,6 @@ COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
-# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
ARG NEXT_PUBLIC_BACKEND_URL
ENV NEXT_PUBLIC_BACKEND_URL=${NEXT_PUBLIC_BACKEND_URL}
diff --git a/client/src/app/login/page.tsx b/client/src/app/login/page.tsx
index 2821319..66c98ed 100644
--- a/client/src/app/login/page.tsx
+++ b/client/src/app/login/page.tsx
@@ -147,14 +147,12 @@ export default function Page() {
)}
- {IS_CLOUD && (
-
- Don't have an account?{" "}
-
- Sign up
-
-
- )}
+
+ Don't have an account?{" "}
+
+ Sign up
+
+
diff --git a/docker-compose.yml b/docker-compose.yml
index 07ea8f6..03a9132 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,24 @@
-version: '3.8'
-
services:
+ caddy:
+ image: caddy:latest
+ container_name: caddy
+ restart: unless-stopped
+ ports:
+ - "80:80"
+ - "443:443"
+ - "443:443/udp" # Needed for HTTP/3
+ volumes:
+ - ./Caddyfile:/etc/caddy/Caddyfile # Mount Caddy config file
+ - caddy_data:/data # Mount persistent data volume for certs etc.
+ - caddy_config:/config # Mount persistent config volume
+ environment:
+ # Pass domain name for use in Caddyfile
+ # Email is configured via Caddyfile global options
+ - DOMAIN_NAME=${DOMAIN_NAME}
+ depends_on:
+ - backend
+ - client
+
clickhouse:
container_name: clickhouse
image: clickhouse/clickhouse-server:latest
@@ -19,6 +37,7 @@ services:
timeout: 5s
retries: 5
start_period: 10s
+ restart: unless-stopped
postgres:
image: postgres:latest
@@ -27,18 +46,15 @@ services:
POSTGRES_USER: frog
POSTGRES_PASSWORD: frog
POSTGRES_DB: analytics
- ports:
- - "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
+ restart: unless-stopped
backend:
container_name: backend
build:
context: ./server
dockerfile: Dockerfile
- ports:
- - "3001:3001"
environment:
- NODE_ENV=production
- CLICKHOUSE_HOST=http://clickhouse:8123
@@ -59,6 +75,7 @@ services:
condition: service_healthy
postgres:
condition: service_started
+ restart: unless-stopped
client:
container_name: client
@@ -67,15 +84,16 @@ services:
dockerfile: Dockerfile
args:
NEXT_PUBLIC_BACKEND_URL: ${BASE_URL}
- ports:
- - "3002:3002"
environment:
- NODE_ENV=production
- NEXT_PUBLIC_BACKEND_URL=${BASE_URL}
- CLOUD=${CLOUD}
depends_on:
- backend
+ restart: unless-stopped
volumes:
clickhouse-data:
postgres-data:
+ caddy_data: # Persistent volume for Caddy's certificates and state
+ caddy_config: # Persistent volume for Caddy's configuration cache (optional but good practice)
diff --git a/docs/src/content/self-hosting.mdx b/docs/src/content/self-hosting.mdx
index 754119e..0b05b48 100644
--- a/docs/src/content/self-hosting.mdx
+++ b/docs/src/content/self-hosting.mdx
@@ -1,105 +1,68 @@
import { Steps } from 'nextra/components'
+import { Callout } from 'nextra/components'
-# Self Hosting
+# Self Hosting Frogstats
-You can self-host Frogstats by following the steps below.
+This guide will walk you through setting up your own instance of Frogstats.
+## Prerequisites
-## Create manually
+Before you begin, ensure you have the following:
-Nextra works like a Next.js plugin, and it accepts a theme config (layout) to
-render the page. To start: [^3]
+- **A Linux VPS:** We use [Hetzner Cloud](https://hetzner.cloud/?ref=QEdVqVpTLBDP) for everything (referral link - but Hetzner is legitimately the best value). CX11 for ~$4/month will be fine for small-medium sized projects.
+- **A Domain Name:** You'll need a domain or subdomain (e.g., `tracking.yourdomain.com`) pointed to your VPS's IP address. HTTPS is required because browsers block tracking scripts served over insecure HTTP.
+- **Docker Engine:** Docker is used to run the application stack. Installation instructions are in Step 1.
+- **Git:** Needed to clone the repository.
+
+
+ This guide has been tested on Ubuntu 24 LTS. While it should work on other distributions, your mileage may vary.
+
+
+## Setup Steps
-### Install Next.js, Nextra and React [^1]
+### 1. Install Docker and Git
-{/* ```sh npm2yarn
-npm i react react-dom next nextra
-``` */}
+First, connect to your VPS via SSH.
-### Install the docs theme [^2]
+**Install Docker Engine:** Follow the official instructions for your Linux distribution:
+[https://docs.docker.com/engine/install/](https://docs.docker.com/engine/install/)
-```sh npm2yarn
-npm i nextra-theme-docs
+Make sure to complete the [post-installation steps for Linux](https://docs.docker.com/engine/install/linux-postinstall/) as well, particularly adding your user to the `docker` group so you don't have to use `sudo` for every Docker command.
+
+**Install Git:** If Git is not already installed, install it using your distribution's package manager. For Debian/Ubuntu:
+```bash
+sudo apt update && sudo apt install -y git
```
-### Create the following Next.js config and theme config under the root directory
+### 2. Clone the Frogstats Repository
-```js filename="next.config.mjs"
-import nextra from 'nextra'
-
-const withNextra = nextra({
- theme: 'nextra-theme-blog',
- themeConfig: './theme.config.js'
-})
-export default withNextra()
+Clone the project repository from GitHub:
+```bash
+git clone https://github.com/goldflag/frogstats.git
+cd frogstats
```
-### Create a `theme.config.js` file for the docs theme
+### 3. Run the Setup Script
-```js filename="theme.config.js"
-export default {
- project: {
- link: 'https://github.com/shuding/nextra' // GitHub link in the navbar
- },
- docsRepositoryBase: 'https://github.com/shuding/nextra/blob/master', // base URL for the docs repository
- getNextSeoProps: () => ({ titleTemplate: '%s – Nextra' }),
- navigation: true,
- darkMode: true,
- footer: {
- text: `MIT ${new Date().getFullYear()} © Shu Ding.`
- },
- editLink: {
- text: 'Edit this page on GitHub'
- },
- logo: (
- <>
-
- Next.js Static Site Generator
- >
- ),
- head: (
- <>
-
-
-
- >
- ),
- primaryHue: {
- dark: 204,
- light: 212
- }
-}
+The repository includes a setup script that configures the necessary environment variables (including generating a secure secret) and starts the application using Docker Compose.
+
+Run the script, replacing `your.domain.name` with the domain or subdomain you configured in the prerequisites:
+```bash
+chmod +x setup.sh
+./setup.sh your.domain.name
```
-> [!NOTE]
->
-> More configuration options for the docs theme can be found
-> [here](/themes/docs/configuration).
+The script will create a `.env` file and then build and start the containers. This might take a few minutes the first time.
-### You are good to go! Run `next dev` to start
+### 4. Sign Up
+
+Once the services are running, Caddy (the webserver) will automatically obtain an SSL certificate for your domain.
+
+Open your browser and navigate to `https://your.domain.name/signup` (using the domain you provided to the setup script).
+
+Create your admin account. You can then log in and start adding your websites!
----
-
-
-
-> [!NOTE]
->
-> Any `.md` or `.mdx` file will turn into a doc page and be displayed in
-> sidebar. You can also create a `_meta.js` file to customize the page order and
-> title.
Check the source code: https://github.com/shuding/nextra for
-> more information.
-
-> [!TIP]
->
-> You can also use
-> [`