Status: [UNTESTED] Endpoints found: https://chat.example.com Source: https://github.com/YaoShenyaoge/ai-gateway # ai-gateway A self-hosted AI gateway that fronts [ChatGPT Next Web](https://github.com/Yidadaa/ChatGPT-Next-Web) (`nextchat`), [chatgpt2api](https://github.com/basketikun/chatgpt2api), [one-api](https://github.com/songquanpeng/one-api) and [Open WebUI](https://github.com/open-webui/open-webui) behind a single nginx entry point, with two small Python services that make the whole setup feel like one product: - **`proxy/nextchat_proxy.py`** — an HTML reverse proxy for NextChat that injects a model whitelist, offloads generated images from `data:` URIs to static files, strips analytics/service-workers, and isolates account traffic. - **`proxy/register_portal.py`** — a launch bridge between one-api and NextChat: it reuses or creates the logged-in user's token and redirects them into the chat UI (and the image workbench) with the token prefilled. This repository contains the exact code and deployment reference that was built and verified in production on an Alibaba Cloud ECS instance. All deployment-specific values (domain names, IPs, tokens) have been replaced with placeholders; nothing sensitive is included. ## Architecture ``` Browser └─ nginx (:443) ├─ / → nextchat_proxy (:3000) → nextchat container (:3002) ├─ /api/ (by URI) → chatgpt2api (:80) or nextchat_proxy (:3000) ├─ /api/auth/, /api/image/, /image, /login │ → chatgpt2api (:80) ├─ /v1/ → chatgpt2api (:80) [OpenAI-compatible API for agents] ├─ /draw, /draw-login → register_portal (:4000) ├─ oneapi.example.com → one-api (:3001) └─ dev.example.com → open-webui (:8080) ``` The nginx routing (`nginx/sites-available/chatgpt-proxy`) is the trickiest part: Next.js static chunks are routed by `Referer`, while `/api/` calls are routed by URI path (browsers omit `Referer` for same-origin requests). ## Components | Path | Wh