
front-proxy
io.github.gutomezenciov0.8.2更新于 Oct 8, 2026
Map local domains (and HTTPS) to apps on local ports, OS-wide, via /etc/hosts and a reverse proxy.
概览
让助手把本地域名映射到本地应用端口,并管理覆盖整个操作系统的 HTTP/HTTPS 反向代理。
- 功能
- 该 MCP 服务器提供工具来列出、添加、修改和删除域名到端口的映射,用 mkcert 生成 HTTPS 证书,查看代理状态,并把已保存的配置应用到正在运行的代理。代理本身会把域名写入 /etc/hosts 指向 127.0.0.1,并按 Host 请求头把请求转发到映射的本地端口,因此 3000 之类的端口可以通过看起来真实的域名在所有浏览器和命令行工具中访问。
- 适用场景
- 当本地应用需要通过看起来真实的域名而不是 localhost 访问时适用,例如只接受域名白名单的服务、以 CORS 阻止 localhost 的 API,或需要正式主机名的无头浏览器测试。适合希望该映射对整个机器生效、而不只是某一个浏览器的开发者。
- 运行要求
- 需要 Node.js 22.12 或更高版本;需要 macOS 或 Linux,因为它会修改 /etc/hosts 并使用 sudo。代理会占用 80 和 443 端口,启动和停止时需要用户通过 sudo 输入密码,密码不会被保存。HTTPS 需要 mkcert,并先在终端执行一次 mkcert -install。配置和证书存放在 ~/.front-proxy,可用环境变量 FRONT_PROXY_HOME 更改位置。
安装
在 SourceWeft 中
- 打开 控制台中的 front-proxy,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
[图片] front-proxy
[npm] [coverage] [audit] [OpenSSF Scorecard] [Socket Badge]
Reach apps on local ports, like localhost:3000, through real-looking domains, like local-dev.mylivedomain.com, over HTTP or HTTPS.
While it runs, front-proxy adds your domains to /etc/hosts, pointing them at 127.0.0.1, and runs a reverse proxy on ports 80 and 443. When it stops, it removes them. The proxy reads the Host header of each request and forwards it to the port you mapped to that domain. HTTPS uses locally trusted certificates from mkcert. Because the mapping lives in the OS, it works in every browser and tool on your machine, not just one.
Why
Some third-party services only accept requests from an allowlist of domains (Stripe and Google Tag Manager, for example), and some APIs block localhost with CORS. Browser extensions can fake a domain for one browser. front-proxy works for the whole OS, so it also covers other browsers, CLI tools and headless Playwright runs with no extra configuration.
Requirements
- Node.js 22.12 or newer
- macOS or Linux (it edits
/etc/hostsand usessudo) - mkcert, only for HTTPS (
brew install mkcerton macOS)
Installation
The front-proxy command is now available in your terminal.
If npm install -g fails with EACCES, your npm global folder is owned by root. That's common with the system Node on Linux or the official macOS installer. Use a Node installed with nvm or Homebrew, or run sudo npm install -g front-proxy.
To update:
Your domains and certificates live in ~/.front-proxy (see Configuration), so updates and reinstalls keep them.
To run it from a clone instead, see Development.
Usage
Then open http://local-dev.livedomain.com (or https:// once you've set up certificates).
Only starting the proxy asks for your password through sudo, because it binds ports 80/443 and edits /etc/hosts. The password isn't stored.
The domains go into a single block in /etc/hosts:
Stopping the proxy (Ctrl+C) removes the block, unless you started it with --persist-hosts. If the proxy didn't stop cleanly (it crashed or was killed), the block stays until the next start. Each start replaces any block it finds with a fresh one. add and remove only change the config, so restart the proxy to apply them.
Requests for a domain that isn't configured get a 502 response.
Hosts must be valid hostnames (letters, digits, hyphens and dots, like myapp.local). IP addresses, localhost, front-proxy.localhost and ports 80/443 (the proxy's own) are rejected. Entries in proxyHosts.json that don't pass these checks are skipped with a warning.
Admin page
While the proxy runs, open http://front-proxy.localhost to manage your domains in the browser. The page:
- lists the configured domains, with a dot showing whether something is listening on each port
- adds and removes domains, and changes a domain's port
- shows which certificate each domain uses, with the
generate-certscommand to copy when it has none - links to each active domain over HTTP (and HTTPS when it's on)
Changes are saved to proxyHosts.json right away, like the CLI commands. The page then shows a banner until they're active: click Apply now to reload the routes, certificates and /etc/hosts block without restarting, or restart front-proxy.
The proxy runs as root, so the page only accepts:
- requests from this machine (
127.0.0.1/::1), with thefront-proxy.localhosthost, which blocks LAN clients and DNS rebinding - changes sent from the page itself: its
Origin, a JSON body and a random token generated each time the proxy starts
Its responses use a strict Content Security Policy and can't be framed. To turn the page off, start with front-proxy --no-admin.
For HTTPS on the admin page, the default certificate must include front-proxy.localhost. generate-certs adds it when it creates the default certificate. If yours was created by an older version, delete ~/.front-proxy/keys/_private-default-*.pem and run front-proxy generate-certs again.
MCP server
front-proxy mcp runs a Model Context Protocol server on stdio, so code assistants (Claude Code, Cursor, VS Code, Codex, Windsurf…) can manage your domains for you. For example, they can map the app they just started to a domain and check that it answers. It's listed in the MCP Registry as io.github.gutomezencio/front-proxy.
[Add to Cursor] [Install in VS Code] [Download for Claude Desktop]
Claude Code: install the plugin, which adds the MCP server and a skill that tells Claude when front-proxy helps (allowlisted domains, CORS, cookies, local HTTPS):
Or add only the MCP server: claude mcp add front-proxy -- npx -y front-proxy mcp.
Claude Desktop: download front-proxy.mcpb from the latest release and open it.
Codex: codex mcp add front-proxy -- npx -y front-proxy mcp.
Other clients take the same command in their MCP config:
If you installed front-proxy globally, front-proxy mcp works too. Both share the config in ~/.front-proxy, but the proxy itself still runs from the global install (see below).
The MCP server runs as you, without sudo, like add and remove. Its changes are saved to proxyHosts.json. To apply them, it calls the running proxy's admin API from 127.0.0.1 with the same per-run token and Origin as the admin page. Some things are left to you:
- Starting and stopping the proxy needs your password, so the assistant asks you to run
front-proxy. apply_configneeds the admin page on (the default). With--no-admin, restart the proxy to apply changes.generate_certscan't type your password, so runmkcert -installonce in a terminal before using it.
HTTPS
HTTPS on port 443 needs locally trusted certificates, which front-proxy creates with mkcert:
The first run installs mkcert's local CA so browsers trust the certificates. It also creates a default certificate for localhost and front-proxy.localhost. Each domain then gets its own certificate, which the proxy serves through SNI. Domains without their own certificate fall back to the default one. If there's no default certificate, the proxy starts with HTTP only.
If Chrome still says "Not secure" for a domain after its certificate was created and applied, fully quit Chrome (Cmd+Q on macOS) and open it again. Chrome remembers a certificate error it saw before, or one you clicked through, until it restarts. Firefox only trusts mkcert's CA when nss is installed (brew install nss) before running generate-certs.
HTTPS responses include an HSTS header (includeSubDomains, preload), so browsers remember to use HTTPS for those domains.
Custom certificates
To use your own certificate (a wildcard, for example), save it in ~/.front-proxy/keys/ as _private-<name>-cert.pem and _private-<name>-key.pem, then set "cert": "<name>" on each domain that should use it:
Configuration
Domains are stored in ~/.front-proxy/proxyHosts.json and certificates in ~/.front-proxy/keys/. The folder is created on the first run. To keep it somewhere else, set the FRONT_PROXY_HOME environment variable.
The commands above manage the config, but you can also edit it by hand:
Keys starting with $ (like the $comment the CLI writes) are ignored.
Uninstalling
Stop the proxy first (Ctrl+C), so its block is removed from /etc/hosts. If you used --persist-hosts, or if an older version added your domains, start the proxy once without the flag and stop it to clean them up:
Development
To use front-proxy from a clone, or to work on it:
If you installed the npm package before, run npm uninstall -g front-proxy first so the two don't clash. npm link links the global command to the clone's dist/, so keep the folder in place and run git pull and npm run build to update. npm unlink -g front-proxy removes the link. The clone uses the same ~/.front-proxy config as the npm package.
The code is TypeScript (strict, native ES modules) with zod schemas for everything it validates. tsc compiles it to dist/, and npm pack/npm publish build it first (the prepack script). Only dist/, README.md, LICENSE and package.json are published (the files field in package.json).
License
MIT
来源:README.md,提交 8d31f14
工具
0版本历史
1- v0.8.2最新Oct 8, 2026


