banner

Summary

WIP setup notes from turning my old mac into a usable server.

prerequisites

  • 1x mac, on power adapter
  • new email address

basic setup

  1. Create a new local user on the Mac.
  2. Create a new iCloud account. This should also enable imessage.
  3. Make the Mac never sleep.
    1. In Settings, select the option “prevent automatic sleeping on power adapter when the display is off”
    2. Ensure “wake for network access” is set to “always”
    3. Go to Users & Groups select account as the “automatically login as” account
      1. First need to disable FileVault for the account
    4. Set up caffeinate on startup (thx gemini !)
        1. Open Automator: Press Cmd + Space and type “Automator”.
      1. Create Application: Select New Document, then choose Application.
      2. Add Shell Script: Search for “Run Shell Script” in the actions library and drag it to the workflow area.
      3. Enter Command: Replace cat in the shell script box with caffeinate -sid
      4. Save App: Go to File > Save, name it “KeepAwake”, and save it to your Applications folder.
      5. Add to Login Items:
        • Go to System Settings > Users & Groups.
        • Select your user, click Login Items, and click the + button.
        • Select the “KeepAwake” app created in step 5.
  4. Enable SSH access
    • Turn on “remote login” in settings
    • Select “allow full disk access for remote users”
  5. Install tailscale
    1. Ensure “launch tailscale at login” is selected
  6. Test SSH access via tailscale
    1. ssh user@hostname should work on another tailscale-enabled device.
    2. Alternatively, ssh-keygen then ssh-copy-id user@hostname to save your public key
  7. Make terminal nice
    1. new mac setup for instructions
  8. Install docker
    1. Enable “start docker desktop when you sign in”
    2. Increase ram/disk/cpu limits as fit
    3. Ensure you can docker ps successfully over SSH
  9. Ensure server is accessible after a reboot (sudo reboot then re-SSH)

applications

  1. Set up cloudflared: https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/as-a-service/macos/
    1. brew install cloudflared
    2. sudo cloudflared service install
    3. sudo launchctl start com.cloudflare.cloudflared <TOKEN> (fetch token once the tunnel is created)
    4. Start a local process at port
      1. Make sure it’s serving on host 0.0.0.0 and the subdomain is included in allowedHosts etc. based on framework
      2. Make sure to give it access to the directory!
    5. In the console, create a route from subdomain.domain.tld to http://localhost:port
      1. Should be http instead of https
  2. Set up uptime-kuma:
    1. Enable cloudflared integration: https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy-with-Cloudflare-Tunnel
    2. Restore from a previous instance / upgrade from v1 to v2: https://github.com/louislam/uptime-kuma/wiki/Migration-From-v1-To-v2
      1. scp host@ip:/path/to/kuma.db ~/Downloads/kuma.db
      2. Replace the current kuma.db with the backed up version.
      3. Wait for the migration to complete (~10min). Monitor via /migrate-status endpoint

redirects

With cloudflared, redirects are created as follows:

  • Create an A record in DNS and make it point to 192.0.2.1. Make sure it is proxied through cloudflare.
  • Go to the ‘rules’ page and create a new redirectg rule for that subdomain.