Tips and tricks

How to Host FE + BE on a Mac Mini with Caddy (Auto SSL)

Here is your content formatted cleanly for a WordPress Gutenberg post (with headings, code blocks, and proper formatting):


πŸš€ How to Host FE + BE on a Mac Mini with Caddy (Auto SSL)

This setup will:

  • Route zoomitthemes.go.ro/api/* β†’ Backend (port 5437)
  • Route zoomitthemes.go.ro/* β†’ Frontend (port 3000)
  • Automatically generate Let’s Encrypt SSL certificates

1️⃣ Install Caddy on the Mac Mini

Add a Code block in Gutenberg:

brew install caddy

2️⃣ Create the Caddyfile

Create the file:

/opt/homebrew/etc/Caddyfile

Add this configuration:

zoomitthemes.go.ro {
handle /api/* {
reverse_proxy localhost:5437
} handle {
reverse_proxy localhost:3000
}
}
πŸ” What This Does
  • zoomitthemes.go.ro/api/* β†’ Backend on port 5437
  • zoomitthemes.go.ro/* β†’ Frontend on port 3000

3️⃣ Port Forward on Your Router

Forward the following ports (TCP) to your Mac Mini local IP address:

  • 80
  • 443

This allows Caddy to:

  • Receive public traffic
  • Automatically generate SSL certificates

4️⃣ Start Caddy

Option A β€” Run Manually
sudo caddy run --config /opt/homebrew/etc/Caddyfile
Option B β€” Run as a Service (Recommended)
brew services start caddy

5️⃣ Run Your Applications

πŸ–₯ Terminal 1 – Backend
cd yourname-be
npm start
🌐 Terminal 2 – Frontend
cd yourname-fe
npm start

πŸ” Automatic SSL

Caddy will automatically request and install Let’s Encrypt SSL certificates the first time someone accesses your domain.

No manual certificate configuration required.


⚠️ Important: Handle the /api Prefix

Your backend must either:

Option A β€” Handle /api routes directly

OR

Option B β€” Strip /api in Caddy (Recommended)

Update your Caddyfile like this:

zoomitthemes.go.ro {    handle /api/* {
uri strip_prefix /api
reverse_proxy localhost:5437
} handle {
reverse_proxy localhost:3000
}
}
βœ” Result
  • Public request: https://zoomitthemes.go.ro/api/agents
  • Internally becomes: http://localhost:5437/agents

Cleaner backend routes, no /api prefix needed in your Node app.


βœ… Final Architecture

Internet
↓
Caddy (Mac Mini)
↓
β”œβ”€β”€ FE β†’ localhost:3000
└── BE β†’ localhost:5437

Run MySQL on Mac Mini with Docker Compose (Full Stack Setup)

This guide shows how to run MySQL using Docker Compose on your Mac Mini and connect it to your Backend + Frontend stack.


1️⃣ Create docker-compose.yml

In your project root, create a file named:

docker-compose.yml

Add the following configuration:

services:
db:
image: mysql:8
container_name: yourname-db
restart: unless-stopped
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
MYSQL_DATABASE: yourname
MYSQL_USER: yourname
MYSQL_PASSWORD: yourname
volumes:
- mysql_data:/var/lib/mysqlvolumes:
mysql_data:

2️⃣ Start MySQL on Your Mac Mini

Run:

docker compose up -d

This will:

  • Pull MySQL 8 image
  • Start the container
  • Create a persistent Docker volume (mysql_data)
  • Expose MySQL on port 3306

3️⃣ Run Database Migrations

npm run migrate

4️⃣ Start the Backend

npm start

Your backend should now connect to:

localhost:3306

πŸ’Ύ Data Persistence

Your MySQL data is stored inside a Docker volume:

mysql_data

This means:

  • βœ… Data survives container restarts
  • βœ… Data survives system reboots
  • ❌ Data is removed only if you manually delete the volume

🧩 Full Stack Running on Mac Mini

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Service β”‚ Port β”‚ Command β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ MySQL β”‚ 3306 β”‚ docker compose up -d β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ BE β”‚ 5437 β”‚ npm start β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ FE β”‚ 3000 β”‚ npm start (in FE folder) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Caddy β”‚ 80/443 β”‚ brew services start caddy β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Your .env Configuration

Your environment file remains the same:

DATABASE_URL=mysql://yourname:yourname@localhost:3306/yourname

πŸ— Final Architecture on Mac Mini

Internet
↓
Caddy (80/443)
↓
Frontend (3000)
↓
Backend (5437)
↓
MySQL Docker (3306)
↓
Docker Volume (mysql_data)

Leave a comment

Your email address will not be published

{"type":"main_options","images_arr":"'#ffffff'","bg_slideshow_time":"0","site_url":"https:\/\/digitalzoomstudio.net","theme_url":"https:\/\/digitalzoomstudio.net\/wp-content\/themes\/qucreative\/","is_customize_preview":"off","gallery_w_thumbs_autoplay_videos":"off","base_url":"https:\/\/digitalzoomstudio.net"}