Files
ryan.mcgeeandClaude Opus 4.7 2250cdd0ec Support hosting at a URL sub-path via OCTOCAM_BASE_PATH
When OCTOCAM_BASE_PATH is set (e.g. /octocam), all routes are served
under that prefix and the bare prefix without trailing slash gets a
301 redirect to the canonical form with trailing slash.

Implementation:
- Config: OCTOCAM_BASE_PATH env var, normalized to ensure leading
  slash and stripped trailing slash
- Server: when base path is set, wrap the existing mux with
  http.StripPrefix and add a redirect handler for the bare prefix.
  All internal routes stay registered at their root paths so the same
  mux works whether the prefix is empty or not.
- Templates: index.html and feed.html receive a BasePath template
  variable used to construct all asset, stream, link, and JS fetch
  URLs. Standalone /raw and /overlay pages prefix StreamURL and
  OtherURL in server.go before rendering.
- Redirect from /overlay (when overlay disabled) now goes to
  BasePath + "/" instead of "/"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 14:52:12 -05:00

34 lines
1.0 KiB
Bash

# OctoCam configuration — copy to /etc/octocam.env (service) or .env (local dev).
# Camera
OCTOCAM_DEVICE=/dev/video0
OCTOCAM_WIDTH=1280
OCTOCAM_HEIGHT=720
OCTOCAM_FPS=15
OCTOCAM_JPEG_QUALITY=85
# HTTP server (web UI + MJPEG streams)
OCTOCAM_HTTP_ADDR=:8080
# URL prefix when hosting behind a reverse proxy at a sub-path (e.g. /octocam).
# Leave empty to serve at the root.
# OCTOCAM_BASE_PATH=/octocam
# MediaMTX RTSP endpoint (must match deploy/mediamtx.yml)
OCTOCAM_MEDIAMTX_RTSP=rtsp://127.0.0.1:8554
# ffmpeg
OCTOCAM_FFMPEG_BIN=ffmpeg
# Encoder: auto (probe hardware), h264_v4l2m2m (Pi), h264_rkmpp (Rockchip), libx264 (software)
OCTOCAM_FFMPEG_HW=auto
# Overlay RTSP framerate — lower = less CPU. Browser always gets the full camera rate.
OCTOCAM_OVERLAY_RTSP_FPS=5
# OctoPrint — REQUIRED
OCTOPRINT_URL=http://localhost:5000
OCTOPRINT_API_KEY=YOUR_API_KEY_HERE
OCTOPRINT_POLL_INTERVAL=2s
# State persistence — RTSP feed enabled/disabled state (survives reboots)
# OCTOCAM_STATE_FILE=/var/lib/octocam/feeds.json