Emulate real inbound referrers in modern browsers — safely and repeatably.
✨ What it does
- 🧭 Maps a referrer host to your machine (
/etc/hosts) - 🔒 Serves a locally trusted HTTPS site (certs via mkcert)
- 🚀 Redirects to your target so the browser sends a real
Referer
Perfect for attribution tests, analytics pipelines, and E2E growth flows.
/etc/hosts, binds 443)
🧑💻 You click the referrer URL
│
▼
/etc/hosts ➜ 127.0.0.1 (spoofs referrer host)
│
▼
🔒 Reflex HTTPS server (mkcert‑trusted)
│ 302 / <meta> / JS → https://your-app.example
▼
🎯 Target site receives Referer: https://news.google.com/
- One‑time — install mkcert local CA (all platforms)
• macOS: brew install mkcert nss && sudo mkcert -install
• Windows: choco install mkcert then mkcert -install (admin PowerShell)
• Linux (also share CA between root and your user so sudo uses the same CA):
sudo mkcert -install # install to system trust store
mkcert -install # install to your user’s Firefox/Chromium trust
sudo mkdir -p /etc/mkcert
sudo cp -a "$(mkcert -CAROOT)/." /etc/mkcert/
sudo chmod 755 /etc/mkcert && sudo chmod 644 /etc/mkcert/*- Run a referrer → target flow
sudo reflex run \
--referrer https://news.google.com \
--target https://your-app.exampleReflex opens your default browser (as your normal user) in a private window and serves a small referrer page using HTTPS with a trusted local cert.
- Download: https://github.com/samfrm/reflex/releases/latest
- Go install (Go 1.21+):
go install github.com/samfrm/reflex/cmd/reflex@latest
- One‑liner (Linux/macOS):
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
curl -L "https://github.com/samfrm/reflex/releases/latest/download/reflex_${OS}_${ARCH}.tar.gz" -o reflex.tgz
tar xzf reflex.tgz && rm reflex.tgz
sudo mv reflex /usr/local/bin/
reflex --version- Windows: Download the latest
reflex_windows_<arch>.tar.gzfrom Releases and placereflex.exeon your PATH.
- 🦫 Go 1.21+
- 🔑
mkcertin PATH - 🏗️ Build:
go build ./cmd/reflex - 📖 Help:
go run ./cmd/reflex --help
▶️ reflex runStart HTTPS server, spoof host, open browser- 🧹
reflex cleanupRemove hosts entry and generated certs (add--allto wipe everything) - 🔍
reflex statusShow current state for a referrer
- 🔗
--referrerReferrer URL or host (required) - 🎯
--targetTarget URL to navigate to (required) - 🔁
--methodRedirect: meta (default), 302, js - 🛡️
--referrer-policyorigin-when-cross-origin(default) orunsafe-urlfor full URL - 🕶️
--privateOpen browser in incognito/private mode (default true) - 🚫
--no-browserDon’t auto‑open a browser
More:
- ⏱️
--delay(meta/js, ms), 🔌--port(default 443, falls back to 8443), 🗂️--keep-certs, 🧪--no-hosts, 🧹--force-unlock
- Validate experiment gating locally (referrer → experiment route):
sudo reflex run \
--referrer https://news.google.com \
--target https://localhost:3000/experiment- Compare redirect methods and observe
document.referrerdifferences:
sudo reflex run --referrer https://news.google.com --target https://localhost:3000 --method meta
sudo reflex run --referrer https://news.google.com --target https://localhost:3000 --method js
sudo reflex run --referrer https://news.google.com --target https://localhost:3000 --method 302- Evaluate
Referrer-Policyeffects (origin vs full URL):
sudo reflex run --referrer https://news.google.com --target https://localhost:3000 --referrer-policy origin-when-cross-origin
sudo reflex run --referrer https://news.google.com --target https://localhost:3000 --referrer-policy unsafe-url- 🥚 Empty
document.referrer?- Use
--method meta(default) or--method js - Try
--referrer-policy unsafe-urlfor full URL referrers
- Use
- 🧪 Linux mkcert warning under sudo (“no Firefox/Chromium DBs”)?
- Complete the one‑time setup above (shared CAROOT in
/etc/mkcert)
- Complete the one‑time setup above (shared CAROOT in
- 🖥️ Browser didn’t open?
- Reflex launches the browser as your non‑root user. If DBus/XDG is missing (headless), copy the printed URL and open manually
- 🌐 Hosts entry not taking effect?
- Check VPNs/enterprise DNS overrides.
sudo reflex status --referrer <host>helps debug
- Check VPNs/enterprise DNS overrides.
- 🏷️ Hosts entries are tagged (
# reflex-managed) for safe removal - 🕰️ A timestamped hosts backup is written before first modification
- 🧽
reflex cleanup --referrer <host>removes the entry and temp certs (unless--keep-certs)
Code map:
- 🧩
cmd/reflexCLI - 🗂️
internal/hostsHosts manager - 🔑
internal/certsmkcert bridge (Linux uses/etc/mkcert) - 🔒
internal/serverHTTPS redirector - 🌐
internal/browserBrowser opener (drops sudo → user, incognito) - 🛠️
internal/utilPort/lock/helpers
🧪 Tests: go test ./... (unit tests generate self‑signed certs; no mkcert required)
If you use Reflex in your work, please cite the archived release:
- Sam (Abbas) Farahmand Pashaki. Reflex — Local HTTPS referrer emulation for reproducible web analytics and experimentation. Zenodo. https://doi.org/10.5281/zenodo.17081049
See also the citation metadata in CITATION.cff.
- 🧭 Optional DNS spoofing mode (no hosts edits)
- 🧷 CAP_NET_BIND_SERVICE on Linux to bind 443 without sudo
- 🖱️ Simple UI control panel / recorder
- 📦 Packages / signed binaries