Platforms
Standalone server
The standalone server runs Runlight as its own app for any number of sites, with a sign-in, short links on your own domains, and email reports.
The standalone server is Runlight packaged as an app of its own. It suits a site whose app cannot run Runlight, and it gives several sites one dashboard. It runs the same code as the library, so reports, goals, short links, and email reports all work the same way.
This page covers the Node server. Python, Ruby, Go, Java, and .NET each have a server of their own that works the same way, and on hosting that runs PHP without Node, the PHP drop-in does the same job.
Start it
With Docker, run this.
bash
docker run -d --name runlight -p 3000:3000 -v runlight:/data ghcr.io/runlightsh/runlightWhen a proxy on the same machine adds HTTPS, as in Put it on the internet, publish the port on the loopback address only, with -p 127.0.0.1:3000:3000. Docker opens a published port past firewalls such as ufw, and a client that reaches the plain port directly can name any host and send a false forwarded address.
With Node 22 or later, run this instead.
bash
npx @runlight/serverThe server listens on port 3000. It keeps its data in a folder called runlight-data in the directory you start it from, or in /data inside Docker.
Make your account
On its first start the server prints a setup link with a one-time code in its log. Open that link and enter your email address and a password of at least ten characters, typed twice so a slip of the finger cannot lock you out.
The link only works while the server has no account, so nobody who finds a new server first can claim it.
In Docker, the log is where to look.
bash
docker logs runlightThe link starts with http://localhost:3000. When the server runs somewhere else, keep everything from /setup on and put the server’s own address in front, such as https://stats.example.com/setup?code=.... Each start makes a new code, so after a restart use the link from the newest log lines.
The person who sets up the server is its owner. The owner and admins invite people in Settings, Team Members. Invitations default to the selected site, as a member or viewer. Invite to all sites is unchecked by default. Check it to give access to every site or invite an admin. Existing accounts keep their access. An account kept to one site sees no mail service fields and cannot change the site’s hostnames, though it can rename the site.
| Role | What they can do |
|---|---|
| Owner | Everything. Nobody else can change the owner’s role or remove them. |
| Admin | Everything the owner can, including managing people, apart from changing or removing the owner. |
| Member | Change goals, funnels, short links, link domains, share links, email reports, and settings for the sites they can access. Members with access to all sites can also import data and make API tokens. Members cannot manage team members, set up the mail service or the assistant, or delete a site. |
| Viewer | Read the stats of the sites they can access without changing anything. |
The owner can hand ownership to an admin with Make owner in Settings, Team Members, after entering their password and confirming that ownership of every site will transfer. The old owner becomes an admin.
The invite goes out by email when the server has a mail service (set in Settings, Email service), and the dashboard always shows the link too, so you can send it another way. The person opens it, chooses a password, and is signed in. A link works once, for seven days, and Send again makes a new one.
Everyone can change their password later under Account at the bottom of the dashboard. Setup, invitation, and password-change forms show a strength indicator. Passwords must still contain at least ten characters. A server from before these roles keeps its first owner as the owner, and any other owners become admins. Removing someone, or making them a viewer, also deletes the API tokens they made and the apps they connected, such as Claude or a hub. Tokens made with RUNLIGHT_TOKEN, or before this version, have no maker on record, so after removing someone, check Settings, MCP & API for those. The sign-in, setup, two-factor, reset, and invitation pages, and the page where an app asks for permission, show in the browser’s language when the dashboard has it, and in English otherwise.
Two-factor sign-in
Anyone can turn on two-factor sign-in under Account at the bottom of the dashboard. Confirm your password, scan the QR code with an authenticator app such as 1Password, Google Authenticator, or Authy, and enter the code it shows. Signing in then asks for a fresh code after the password. You also get ten recovery codes, shown once, and each signs you in once if your phone is gone.
The owner or an admin can reset someone else’s two-factor in Settings, Team Members, after entering their own password, though only the owner can change the owner’s. Turning two-factor on or off signs you out of every other browser, and the one you are using stays signed in.
Sign-in limits
One address gets ten wrong passwords for an account every fifteen minutes, and the account gets fifty from anywhere. Each try is counted as it arrives, so a burst of guesses sent at once gets no further.
When the account is at its limit, a browser that has signed in to it before still gets in, and every other try gets the same answer whether the password was right or not, from every account and from an address with no account. When the server has a mail service, a right password then emails you a link to sign in, which leads to the code step when two-factor sign-in is on. Otherwise the account waits fifteen minutes. The link works once, for fifteen minutes, and using it withdraws any link sent before it.
The code step allows five wrong codes, then locks for fifteen minutes. Each time the tries run out again the lock doubles, to thirty minutes, then an hour, and so on up to a day. Once the lock has reached a day, someone guessing gets five tries a day. A browser that has signed in to the account before has tries of its own, so others’ guesses never hold up its owner. Confirming a new two-factor set-up allows five wrong codes before it has to start again. The counts are kept in memory, with addresses and email addresses hashed by a key made at each start.
A sign-in, account, or OAuth request over 64 KB is refused, and so is an MCP request over 1 MB.
Forgotten passwords
If someone is locked out, run the password command on the server to give the account a new password, which it prints. It also turns off two-factor sign-in for that account, since anyone who can run it on the server is already trusted. The same command makes a new account, which is the owner on a server with nobody yet and an admin otherwise.
bash
npx @runlight/server password someone@example.comIn Docker, run the same command inside the container.
bash
docker exec runlight node node_modules/.bin/runlight.sh password someone@example.comAdd your sites
After you sign in, the dashboard asks for your first site’s domain. The next screen gives you the script tag for that site’s pages, with the server’s address and the site’s id filled in.
html
<script defer src="https://stats.example.com/s.js?site=example.com" data-site="example.com"></script>Add more sites from the menu beside the site’s name. In Settings, General, you can change a site’s domains, name, and timezone, or delete the site along with everything recorded for it. Deleting asks for your current password and an explicit confirmation, and also removes the accounts and invitations kept to that site. This cannot be undone.
Connect sites that count themselves
A site with Runlight inside its own app can join this server too, so every site is in one dashboard.
Choose Add a site, Connect another Runlight, and enter the app’s Runlight address, such as https://example.com/runlight. Your browser opens that app’s Runlight, where you sign in if you need to, pick the site, and choose Allow. You land back here with the site added.
The site’s numbers stay in the app’s own database. This server reads them through the app’s API each time you look, so they are always current.
Its goals, funnels, short links, link domains, email reports, share links, and how long it keeps visits can all be changed from here, and each change is saved in the app. People, tokens, imports, and the app’s mail service stay with the app.
All sites in the site menu lines every site up side by side for the dates you pick.
The app keeps the permission as a token in its Settings, MCP & API, limited to the one site. Deleting it there disconnects this server at once.
A site connected with a read-only token before this option existed shows Allow changes in its settings, which runs the same steps. If the app deletes that token, Connect again in the site’s settings makes a new one, and disconnecting a site here deletes its token there.
If the app runs an older version of Runlight, connect it with a token instead. Make one in the app’s Settings, MCP & API, then choose Use an API token instead when you connect. A read token shows the site’s numbers here, and its settings stay on the app.
Put it on the internet
The server speaks plain HTTP, so run it behind a proxy that adds HTTPS. With Caddy, the whole setup for a server at stats.example.com is this.
Caddyfile
stats.example.com {
reverse_proxy localhost:3000
}Set RUNLIGHT_URL to the server’s public address, such as https://stats.example.com. Short links can then never take over that name, and invite and report emails link to it whatever Host header a request names. A connected hub adds link domains and email reports only once it is set.
By default Runlight believes forwarding headers only on a connection from this computer or a private network, where a proxy like this one connects from, and reads each visitor’s address from the last X-Forwarded-For entry, the one your proxy adds. A visitor who reaches the server straight from the internet cannot send a false address. Behind a CDN that connects from public addresses, such as Cloudflare with nothing between it and the server, set TRUST_PROXY to cf-connecting-ip or true, or every visitor shows the CDN’s address and no location. Set TRUST_PROXY to x-forwarded-for, x-real-ip, or cf-connecting-ip to read the address from only that header, such as cf-connecting-ip behind Cloudflare and another proxy.
Short links on your own domains
Any domain pointed at the server can serve short links at its root, with nothing else to install. Point the domain at the server with a CNAME record, have your proxy accept it with HTTPS, and then add it in Settings, Custom domains. In Caddy that means listing the domain beside the server’s own.
Caddyfile
stats.example.com, go.example.com {
reverse_proxy localhost:3000
}Every link also answers at /go/your-slug on the server’s own domain. The server’s own pages answer as the server on a link domain too, and their names are kept from links. Those names are login, logout, setup, invite, api, mcp, e, embed, healthz, and pick-return, along with cronwatch when CronWatch is on. A link cannot be made or renamed with one of them as its slug, and a link that had one before keeps it and works only at /go/.
A link domain can never be the server’s public address or a name the owner or an admin has signed in from, and if one was added that way before, signing in at /login still opens the dashboard so you can remove it. The server remembers the first 20 names they sign in from, so set RUNLIGHT_URL if it answers on more.
Locations
Behind Cloudflare, once Runlight believes its headers as above, Runlight takes each visitor’s country, region, and city from the headers Cloudflare adds. Without them, the server downloads the free DB-IP city database into its data folder on the first start and fetches each month’s new release.
The file is about 130 MB and the server keeps it in memory. DB-IP’s license asks for credit, so the dashboard’s footer names it.
Before it uses a download, the server checks it against the SHA-1 checksum DB-IP publishes for each release, which it reads from a page on db-ip.com, and checks that it is a DB-IP database of the right kind, no older than the one in use. A download that does not match, redirects, or is too large, too small, or damaged is thrown away, and the database in use stays. If the checksum page cannot be read, the download is accepted on the other checks and the server logs a warning. On a network that limits where the server may connect, allow db-ip.com as well as download.db-ip.com. A download that keeps failing is tried less and less often, up to every six hours.
Set RUNLIGHT_GEO=country to use DB-IP’s smaller country database, which is about 8 MB and has no regions or cities. Set it to off to look nothing up, or to the path of an MMDB file of your own, such as MaxMind’s GeoLite2 City.
Settings
The server reads its settings from environment variables.
| Variable | What it does |
|---|---|
PORT |
The port to listen on. The default is 3000. |
HOST |
The address to listen on. The default is 0.0.0.0. |
DATA_DIR |
The folder for the SQLite file, the secret, and the location data. The default is ./runlight-data, or /data in Docker. |
DATABASE_URL |
A postgres:// address keeps the data in Postgres instead of SQLite, and a mysql:// or mariadb:// address keeps it in MySQL or MariaDB. |
CLICKHOUSE_URL |
An http:// or https:// address with a user, password, and database keeps the visits and events in ClickHouse, and everything else where it was. |
RUNLIGHT_SECRET |
The key that signs sign-ins and encrypts saved keys, for mail, the AI Assistant, connected installs, and two-factor sign-in. Without it, the server makes one and keeps it in DATA_DIR. |
RUNLIGHT_URL |
The server’s public address, such as https://stats.example.com, which can never become a link domain. Invite and report emails link to it. |
RUNLIGHT_TOKEN |
A token that scripts can send as a bearer, in addition to the API tokens made in the dashboard. |
RUNLIGHT_OBSERVE_KEY |
One key a WordPress, Drupal, or Craft site can use to report AI agents, for any site. Each site also has its own agents key, shown under Settings, Install and limited to that site, which is the better choice. The agents command reads its key from it too. |
TRUST_PROXY |
Which forwarding headers to believe, for each visitor’s address and the host’s location headers. Unset, they count only on a connection from this computer or a private network. true (or 1, yes, on) believes them from anywhere, for a CDN that connects from public addresses, and false (or 0, no, off) never does. x-forwarded-for, x-real-ip, or cf-connecting-ip reads the address from only that header. Any other value is refused. |
RUNLIGHT_GEO |
Where locations come from when no header gives them. It is city by default, and can be country, off, or a path to an MMDB file. |
RUNLIGHT_AGENT_RANGES |
on by default, which downloads the address lists AI companies publish once a day, to check AI agent fetches. Set it to off to use the copy that came with the release. |
Email reports and the scheduled check
The server runs Runlight’s scheduled check itself every five minutes, so it needs no cron. Set up a mail service in Settings, Email service, add who gets reports in Settings, Email reports, and reports go out on their own.
Backups and upgrades
Back up the data folder. It holds the SQLite file and the secret file, and without the secret the saved keys cannot be read and everyone has to sign in again. Those are the keys for the mail service, the AI Assistant, and connected installs, and everyone’s two-factor secrets, so two-factor sign-in has to be set up again too.
To upgrade, pull the new image or run npx @runlight/server@latest, and the database updates itself on start.
Running more than one copy
Several copies of the server can share one Postgres, MySQL, or MariaDB database, and one ClickHouse when there is one, for example behind a load balancer. Each copy rereads the list of sites and connected installs every five minutes, so one added on any copy appears on the others within five minutes. Everything else, from visits to goals and links, is shared at once.
AI agents from a log
AI agents such as GPTBot and ClaudeBot fetch pages without running JavaScript, so the script tag never sees them. On a site with Runlight inside the app, or with a WordPress, Drupal, or Craft plugin, they are counted where the page is served. For any other site you host yourself, the web server’s access log has them, and the agents command reads it.
bash
RUNLIGHT_OBSERVE_KEY=rlo_... npx @runlight/server agents --log /var/log/nginx/access.log --to https://stats.example.com --site https://example.com --followThe key is the site’s agents key, shown in Runlight under Settings, Install, and it can only report fetches for that site. Pass it in RUNLIGHT_OBSERVE_KEY rather than --key, since other people on the computer can see a command’s arguments. --site is the site’s address, for logs in nginx or Apache’s usual format, which leave the host out. Caddy’s JSON logs carry the host, so it is not needed there.
With --follow the command keeps running, sends fetches as they happen, and carries on when the log is rotated, finishing the old file before it moves to the new one. A systemd service or a process manager keeps it going. Add --state ./agents.json so a restart picks up where it stopped.
Without --follow it reads the log once and stops, and with --state the next run starts where the last one finished, which suits cron. Only one run at a time can use a state file. It holds a lock beside the file (agents.json.lock), so a second run, such as a cron job that starts while the last one is still sending, stops with a message and sends nothing twice. A lock left by a run that crashed is taken over. Fetches more than a week old are dropped, so a first run over an old log does not land as one spike on today.
Only successful page fetches from known AI agents leave the machine, each with the page’s address, the agent’s user agent, and when it was served. The agent’s IP address goes with each one, and Runlight checks it against the agent’s published list and then drops it. Visitors’ addresses and everything else in the log stay where they are.
The log has to record the agent’s real address, or every fetch shows as claimed. The command takes it from the client field of nginx and Apache’s combined format ($remote_addr in nginx, %h in Apache), after a leading host column if there is one, and from client_ip, then remote_ip, in Caddy’s JSON. Behind a CDN or another reverse proxy that field holds the proxy’s address, so have the web server put the agent’s address there first: set_real_ip_from and real_ip_header in nginx, mod_remoteip in Apache, or trusted_proxies in Caddy.
CronWatch
The standalone server can watch its own scheduled checks with CronWatch, open source monitoring for cron and scheduled jobs that runs inside the app.
Set CRONWATCH_MAIL_TO to the address that should receive scheduled-job alerts after configuring Runlight’s mail service. CronWatch uses that service’s saved credentials and verified sender. Owners and administrators can open /cronwatch after signing in. Members and viewers cannot access it, and no separate token is needed.
Maintenance and automatic location-data checks keep their existing five-minute schedule. CronWatch checks for missed and stuck runs every minute and stores its history in DATA_DIR/cronwatch.db. Failed reports, unavailable or stale location data, slow runs, and unexpected metric changes can trigger alerts. A check that sends no reports or needs no database download can be normal.
This optional SQLite setup is for one standalone server. Keep its database with the installation’s persistent data. Monitoring inside the process cannot alert while the entire server is stopped.