Configuration reference
Every environment variable and binding for self-hosted TrayPage, and what each one means.
This is the list of settings for the self-hosted edition. On Docker / VPS you set them in .env (deploy/docker/.env.example); on Cloudflare you set them in vars in wrangler.jsonc and as secrets.
"Required" means TrayPage cannot start, or cannot work correctly, without it.
Basics
| Name | Required | Meaning |
|---|---|---|
APP_ORIGIN | Required in production | The app URL (for example https://traypage.example.com). Write only the origin (a trailing / is fine; a path, query, or user name is a configuration error and the app does not start). Used to build share URLs and sign-in links, and as the allowed origin for authentication. Required for Docker |
VIEWER_ORIGIN | Required in production | The URL of the viewer host that serves page content (for example https://view.traypage.example.com). Write only the origin (a trailing / is fine; a path, query, or user name is a configuration error). With it set, the viewer host only answers for shared page content, robots.txt (which forbids all crawling) and the health check (/health), and page content is served only from the viewer host (not from the app host). In production, use a host name different from APP_ORIGIN (not its www. host either). Sharing the host name and splitting only the port (for example localhost:3000 and localhost:3001) is for local testing only (cookies are not split by port). Internationalized domain names can be written as they are. A value that cannot be read, or that cannot be told apart from APP_ORIGIN (same host name and same port), is a configuration error (Docker does not start; on Cloudflare responses are 500, except public static files such as JS, CSS, and images). Required for Docker |
VIEWER_HOST | Optional (compatibility) | The viewer host is taken from VIEWER_ORIGIN, so you can leave this out. It is accepted for compatibility with older settings; if you write it, use the same host name as VIEWER_ORIGIN (for example view.traypage.example.com; no https://). A different host, or VIEWER_HOST without VIEWER_ORIGIN, is a configuration error |
BETTER_AUTH_SECRET | Required | The key that signs sign-in sessions. Generate one with something like openssl rand -hex 32. Changing it signs everyone out |
VIEWER_TICKET_SECRET | Required on Cloudflare | The key for the short-lived (5 minute) signed tickets handed to the viewer host. On Docker, BETTER_AUTH_SECRET is used if unset. On Cloudflare, use a different value from BETTER_AUTH_SECRET |
TRAYPAGE_EDITION | Optional | self_hosted removes usage limits and trials, and disables operator-only features (including the daily summary notification). It also hides the pages meant for tray.page (hosted): the landing page, pricing, terms, privacy policy, and contact form. / goes to the sign-in screen (or to the app when signed in). The docs (/docs) stay available. The Docker setup sets it automatically and the Cloudflare template already sets it. If unset or unrecognized, behavior is the same as tray.page (hosted) |
TRAYPAGE_LICENSE_KEY | Optional | The Enterprise license key (starts with tp1.). See License and Enterprise features |
ENVIRONMENT | Optional | production keeps the test-only login disabled at all times and ignores the settings that turn off the rate limits (AUTH_RATE_LIMIT, API_RATE_LIMIT). The Docker image, the bundled compose setup, and the AWS and Cloudflare templates already set production |
Database
| Name | Applies to | Meaning |
|---|---|---|
DATABASE_URL | Docker | The Postgres connection string (for example postgres://user:password@host:5432/db?sslmode=require). If unset on Docker, the bundled Postgres is used |
DATABASE_POOL_MAX | Docker | Maximum connection pool size. Defaults to 10 |
POSTGRES_PASSWORD | Docker (compose) | Password of the bundled Postgres. Decide it before the first start |
HYPERDRIVE | Cloudflare | The Hyperdrive binding. You pick an existing configuration in the button flow |
The app creates tables automatically on startup (on Cloudflare, on the first access).
Page content storage
| Name | Applies to | Meaning |
|---|---|---|
PAGE_BUCKET | Cloudflare | The R2 bucket binding. Created automatically by the button |
S3_ENDPOINT | Docker | Endpoint of the S3-compatible storage. If unset on Docker, the bundled SeaweedFS is used |
S3_BUCKET | Docker | Bucket name. Defaults to traypage-pages |
S3_ACCESS_KEY_ID | Docker | Access key ID |
S3_SECRET_ACCESS_KEY | Docker | Secret access key |
S3_REGION | Docker | Region. The AWS region for AWS S3, or auto for R2 |
S3_ADDRESSING_STYLE | Docker | path (default) or virtual |
On Cloudflare, PAGE_BUCKET is used when present. On Docker, S3-compatible storage is used when the S3_* values are complete.
| Name | Applies to | Meaning |
|---|---|---|
EMAIL_FROM | Both | The sender (for example TrayPage <noreply@example.com>). Required on the self-hosted edition: use an address on a domain your email service can send from. The tray.page sender is never used. If it is unset, Docker does not start when an external SMTP server or Resend is configured (with only the bundled Mailpit, email is sent from TrayPage <noreply@localhost>); on Cloudflare, every email fails and the log shows EMAIL_FROM is required |
RESEND_API_KEY | Both | For compatibility with older versions. Email is sent through Resend only when this is set, and it takes priority over the EMAIL binding and SMTP |
SMTP_HOST | Docker | SMTP server host name. Used when RESEND_API_KEY is not set (the default on Docker) |
SMTP_PORT | Docker | Port. If unset, 465 when SMTP_SECURE is enabled, otherwise 587 |
SMTP_SECURE | Docker | true uses TLS from the start (port 465); otherwise STARTTLS |
SMTP_USER / SMTP_PASSWORD | Docker | SMTP credentials (omit if no authentication is needed) |
MAIL_CATCHER_SMTP_HOST | Docker | Host name of a mail catcher that never delivers to the internet. When SMTP_HOST matches it, email is sent from TrayPage <noreply@localhost> even without EMAIL_FROM. The bundled compose setup sets it to the bundled Mailpit (mailpit); you do not set it yourself |
EMAIL | Cloudflare | The Cloudflare Email Service binding. Included in the template. When present, email is sent through it (the default on Cloudflare; the sender domain must be registered) |
MAILPIT_URL | Development | When no sender is configured, email is sent to this Mailpit API (default http://localhost:8025). The bundled compose setup sends to Mailpit over SMTP by default |
Notification emails
Comments, replies, new versions, and completed reviews are emailed to the people involved. No extra configuration is needed: it works as soon as one of the senders above is configured.
- Emails are not sent one by one. For each recipient, events are combined into a single email 5 minutes after the last event, or 15 minutes after the first one. While a conversation is active, one person gets about one email every 5 minutes.
- Right before sending, TrayPage checks that the recipient can still see the page. People who are no longer in the sharing scope get nothing.
- Recipients can stop the emails under "Email notifications" in their account settings, or with the unsubscribe link in each email.
- Links in the email use
APP_ORIGIN. On Cloudflare, whileAPP_ORIGINis not set, the URL the action came from is used (on Docker, emails cannot be sent without it). SetAPP_ORIGINso that links always use one URL.
How the batching job runs depends on the setup.
| Setup | How it runs |
|---|---|
| Docker / AWS | The server sends every minute. With several servers, two of them never deliver to the same person at the same time |
| Cloudflare | A cron (triggers.crons in wrangler.jsonc, or notification_cron with Terraform) starts the job. The default is every 5 minutes and you can change it (a longer interval delays the emails by that much). If you remove it, notification emails are not sent |
On Cloudflare, each cron run queries the database once even when there is nothing to send. A database that suspends when idle (such as the Neon free tier) stays awake because of this. Use a longer cron interval if you want it to suspend.
Delivery is at least once. In rare cases, for example when the server stops right after the email was accepted, the same notification can arrive twice. A failed send is retried at increasing intervals for about 10 hours. Notifications that stay undeliverable, for example because the sender domain is not registered yet, are deleted after 14 days. If recording a notification fails (for example during a brief database outage), the original action such as the comment still succeeds and only that notification is lost.
Sign-in
| Name | Meaning |
|---|---|
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET | The OAuth client for Google sign-in. The redirect URI is <APP_ORIGIN>/api/auth/callback/google |
NEXT_PUBLIC_GOOGLE_AUTH | Set to 1 to show Google sign-in on the sign-in screen |
OIDC_ISSUER | The issuer of your company IdP (Okta, Keycloak, and so on) for sign-in, e.g. https://example.okta.com. Write it exactly as the issuer in the IdP's discovery document, including any trailing /. The discovery URL (ending in /.well-known/openid-configuration) cannot be used. Use https (http is allowed only for localhost) |
OIDC_CLIENT_ID / OIDC_CLIENT_SECRET | The ID and secret of the client you registered in the IdP. Store the secret as a secret on Cloudflare, or in .env with Docker. The redirect URI to register in the IdP is <APP_ORIGIN>/api/auth/oauth2/callback/oidc |
OIDC_DISPLAY_NAME | The IdP name shown on the sign-in button, e.g. Okta. Defaults to SSO |
OIDC_ASSUME_EMAIL_VERIFIED | Set to 1 to treat email addresses from an IdP that does not send email_verified as verified. Off by default. Use it only if you can guarantee that the IdP confirms who owns each address (not with Microsoft Entra ID). When the IdP sends anything other than true (boolean) or "true" (string), it is never treated as verified |
OIDC_CLIENT_AUTH_METHOD | How the client secret is sent. client_secret_basic (default; in the Authorization header) or client_secret_post (in the request body). Match the client authentication method registered in the IdP |
LOGIN_METHODS | Limits the sign-in methods (comma-separated: magic_link (email link), google, oidc). When unset, every configured method is used. Set oidc to sign in only through your IdP. If none of the listed methods can be used, nobody can sign in (no other method is turned on instead; remove it to sign in with email links) |
IdP sign-in is turned on only when OIDC_ISSUER, OIDC_CLIENT_ID, and OIDC_CLIENT_SECRET are all set. For the steps and what happens on sign-in, see Security notes.
Sign-up restriction
If unset, anyone who can receive a sign-in link can create an account. For how the settings combine and behave, see Security notes. Existing users can always sign in.
| Name | Meaning |
|---|---|
SIGNUP_MODE | open (default) or invite_only. With invite_only, only email addresses that match the allowlist and addresses invited to an organization or a page can sign up. Unset, empty, or whitespace only means open. Any other value lets only allowlisted addresses sign up (not invited ones) and logs signup_policy_invalid |
SIGNUP_ALLOWED_EMAIL_DOMAINS | Email domains allowed to sign up (comma-separated, e.g. example.com,example.org). Exact match, case-insensitive. Setting it with open lets only matching addresses sign up |
SIGNUP_ALLOWED_EMAILS | Email addresses allowed to sign up (comma-separated). With invite_only, put your first administrator here |
The Cloudflare template (wrangler.jsonc) includes the defaults (open and empty allowlists). On AWS, set them with signup_mode, signup_allowed_email_domains, and signup_allowed_emails in Terraform.
Sign-in rate limit
Authentication actions, such as sign-in (sending and opening the email link, passwords) and connecting AI agents (OAuth), are limited per client IP address. Over the limit, requests get "Too many requests" (HTTP 429) for a while, usually about a minute. Counts are stored in the database, so they add up across multiple servers. It is on by default. The bundled Docker image and compose setup and the AWS and Cloudflare templates set ENVIRONMENT=production, so the settings that turn off the limits (AUTH_RATE_LIMIT, API_RATE_LIMIT) have no effect there.
| Name | Applies to | Meaning |
|---|---|---|
TRUSTED_CLIENT_IP_HEADER | Docker | The header to read the client IP address from. The bundled compose setup (behind Caddy) sets x-forwarded-for, and so does the AWS Terraform module (ECS + ALB). For headers that are appended to, such as X-Forwarded-For, the last value (the client as seen by the proxy right in front of the app) is used. If unset, the address connecting to the app is used. Not needed on Cloudflare (the client IP that Cloudflare adds is used) |
- If you put another load balancer or CDN in front of Caddy, everyone is counted as the same IP (the one in front) and hits the limit together. In that case, set
trusted_proxiesin the Caddyfile so Caddy keeps the client IP passed on by the proxy in front (see "認証のレート制限" (auth rate limit) indeploy/docker/README.md). - In the AWS standard setup (ECS + ALB), the ALB appends the client IP to the end of
X-Forwarded-Forand the app uses that last value. The Terraform module setsTRUSTED_CLIENT_IP_HEADER=x-forwarded-for. Without it, everyone is counted as the ALB's IP and hits the limit together. - If you expose the app directly without a proxy, do not set
TRUSTED_CLIENT_IP_HEADER. Clients can write any header they like, which would let them get around the limit.
Rate limits on other actions
Creating pages and adding versions, publishing and widening who can see a page, viewing and exporting pages (HTML, PDF, print), commenting, actions that send email (sharing a page with a person, inviting members), and sending the support form are also limited. This is on by default in the self-hosted edition too.
-
Narrowing who can see a page and revoking share links or individual access are not counted, so you can take back a page you published by mistake right away, regardless of the limits.
-
PDF export is limited to 10 per minute and 60 per hour per person on top of the viewing limit, because each export renders the page in a browser.
-
Signed-in people are counted per person. Actions through access tokens or AI agents (MCP) count toward the token owner.
-
The support form and page views by people who are not signed in are counted per client IP address. The IP address is read the same way as for the sign-in rate limit (
TRUSTED_CLIENT_IP_HEADERabove). -
The limits are set so that normal use (an AI agent creating several pages in a row, leaving comments one after another during a review) does not hit them. For example, creating pages and adding versions allows 30 per minute and 300 per hour per person, comments allow 60 per minute and 600 per hour, and the support form allows 5 per 10 minutes and 20 per day from the same IP address.
-
Over the limit, the app shows how long to wait (for example, "Try again in about 10 minutes"). When both a short and a long limit are reached, the wait covers both. The API returns HTTP 429 with a
Retry-Afterheader (in seconds), and AI agents get a tool error that states the limit that was exceeded and how many seconds to wait. The limit lifts by itself once that time has passed.
Server (Docker)
| Name | Meaning |
|---|---|
PORT | The port the app container listens on. Defaults to 8080. In compose it is not exposed; only Caddy connects to it |
HOST | The address to listen on. Defaults to 0.0.0.0 |
Compose settings (Docker)
| Name | Meaning |
|---|---|
COMPOSE_PROFILES | Which services to start: postgres (bundled Postgres), s3 (bundled SeaweedFS), and mailpit (a local mail catcher), comma-separated |
TRAYPAGE_IMAGE | The image to use. Defaults to ghcr.io/8d-inc/tray-page:latest. In production, pin a version such as :v1.2.3 |
HTTP_PORT / HTTPS_PORT | Ports Caddy listens on. 80 and 443 in production; locally, the same port written in APP_ORIGIN |
MAILPIT_UI_PORT | Port of the Mailpit UI. Defaults to 8025 (exposed only on your own machine) |
Cloudflare bindings
| Name | Meaning |
|---|---|
HYPERDRIVE | Connection to the database (required) |
PAGE_BUCKET | R2 bucket for page content (required) |
EMAIL | Email Service, for sending email |
BROWSER | Browser Run, for faithful PDF export (optional) |
REVIEW_SESSIONS | Durable Objects, used to notify a waiting CLI as soon as a review is finished (optional; without it, the CLI checks every few seconds) |
ASSETS | Static files for the UI (set in the template; no change needed) |
Settings you normally do not set
The following are for operating tray.page (hosted), development, or testing. Do not set them on a self-hosted instance.
| Name | Purpose |
|---|---|
E2E_LOGIN_SECRET | Login for automated tests. Always disabled when ENVIRONMENT=production |
AUTH_RATE_LIMIT | off removes the sign-in rate limit (for development and automated tests). Ignored when ENVIRONMENT=production |
API_RATE_LIMIT | off removes the rate limits on other actions (for development and automated tests). Ignored when ENVIRONMENT=production |
OPERATOR_EMAILS, OPERATOR_SLACK_WEBHOOK_URL, DEFAULT_TRIAL_DAYS | Operator features of the hosted service. Disabled in the self-hosted edition |
SUPPORT_EMAIL, SUPPORT_EMAILS | Contact addresses for the hosted service's support form |
STORAGE_DIR | A local folder used when no storage is configured at all (for tests) |
BETTER_AUTH_URL | On Docker this is set from APP_ORIGIN automatically |
NEXT_PUBLIC_APP_URL | An old setting name that is no longer read. Set APP_ORIGIN instead |
Self-hosting on AWS
The key points of running TrayPage in your own AWS account (Fargate + RDS with Terraform), and what to do if you want a single EC2 instance.
Security notes
What to take care of when self-hosting. Why the viewer host is separate, how to limit who can sign up, and signing in with your company IdP (OIDC).