secubox-deb/common/nginx
CyberMind 432f19c2b0
fix(metrics): Make sibling imports work under uvicorn (post-#98 hotfix) (#100)
* fix(metrics): Make sibling imports work under uvicorn (api.main:app)

The aggregator imports `from visitor_origin import VisitorOriginAggregator`
worked in pytest (conftest puts api/ on sys.path) but crashed at module load
under `uvicorn api.main:app` with ModuleNotFoundError. The service entered
a restart loop; the new live-panel endpoints were unreachable.

Fix: insert os.path.dirname(__file__) at the top of sys.path before the
sibling imports, mirroring the test conftest.

Verified live on gk2: secubox-metrics now starts cleanly, all three new
endpoints (visitor-origin / live-hosts / cert-status) respond 200 with the
documented disabled payload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(nginx): Strip upstream CORS headers in /api/v1/* snippet (ref #92)

Several FastAPI services in this repo (including secubox-metrics, with the
new live-panel endpoints from #98) ship their own CORSMiddleware emitting
Access-Control-Allow-Origin: *. The nginx snippet for /api/v1/* also adds
the same header. Browsers receiving both fold them into
"Access-Control-Allow-Origin: *, *" and reject all cross-origin requests,
which broke health-banner.js v1.3.0 when injected on any vhost other than
admin.<host>.secubox.in.

Fix: declare nginx as the sole CORS authority by stripping the upstream
copies with proxy_hide_header before nginx's own add_header fires. The
project standard already had nginx own CORS at the edge; this just plugs
the leak introduced when individual services started emitting their own.

Verified live on gk2: single Access-Control-Allow-Origin: * header now
returned by /api/v1/metrics/* through HAProxy + mitmproxy + nginx.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 16:50:43 +02:00
..
modules.d feat(eye-remote): Add multi-mode display system v1.9.0 2026-04-29 10:24:02 +02:00
secubox-proxy.conf fix(metrics): Make sibling imports work under uvicorn (post-#98 hotfix) (#100) 2026-05-12 16:50:43 +02:00
secubox.conf fix(kiosk): Add HTTP fallback for localhost kiosk mode 2026-04-02 12:13:58 +02:00
webui.conf feat(geoip): Use local MaxMind database for offline GeoIP lookups 2026-05-07 13:56:39 +02:00