Most self-hosted apps assume they own a hostname. Give them pay.example.com, let them get their own certificate, and everything is simple. But sometimes you already have a box running nginx for example.com, with TLS sorted, an auth layer in front of your other admin pages, and no appetite for yet another subdomain and certificate to look after.
Coldtill, the self-hosted crypto payment gateway I work on, has supported running under a path like /coldtill since v1.2.1 in October. This post is the setup in full, the two mistakes that break it, and the reason I'd still tell most people to use a subdomain. That last part is at the end, and it matters.
How path-prefixed apps usually go wrong
There are two common ways to put an app under a prefix, and they fail in opposite directions.
- The proxy strips the prefix. nginx turns
/coldtill/pay/abcinto/pay/abcbefore passing it on. The app never knows it lives under a path, so every link it generates points at/assets/…or/api/…, which land on your main app. - The app knows the prefix, and the proxy passes it through. The app generates links with the prefix and removes it from incoming requests itself.
Coldtill does the second. You put the path in the site URL, and it serves everything under that path: the dashboard, the login page, the checkout, the merchant API, scripts and logos. It also scopes its session cookie to the path. The part that trips people up is this: a request without the prefix is served as if there were no path at all. So if your proxy strips it, nothing errors out. Pages load, then fetch their assets from the wrong app.
The server side
On a fresh server, give the installer the full URL with its path:
curl -fsSL https://coldtill.com/install.sh | sudo bash -s -- --edition free \ --mode mainnet --site-url https://example.com/coldtill The docs show this with a Pro token, but the flags are the same. (On mainnet you also need SMTP settings for payout approval emails, so read the install guide before taking real money.)
When the site URL has a path, coldtill init sets up the bundled Caddy differently. It listens on plain HTTP on 127.0.0.1:8080 instead of taking ports 80 and 443, so it doesn't fight nginx. To move an existing install, set these in deploy/.env (that's /opt/coldtill/.env on a one-line install) and run docker compose up -d:
COLDTILL_SITE_URL=https://example.com/coldtill COLDTILL_CADDY_ADDRESS=http://:80 COLDTILL_HTTP_PORT=127.0.0.1:8080 COLDTILL_HTTPS_PORT=127.0.0.1:8443 COLDTILL_SITE_URL does more than set links. Coldtill uses it for checkout links, cookies and the CSRF origin check, so it has to be exactly the public URL people type, with https://.
The nginx side
This goes inside the server block that already serves example.com on 443:
location = /coldtill { return 301 /coldtill/; } location /coldtill/ { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 4m; } Three details are worth slowing down for.
No trailing slash on proxy_pass. In nginx, proxy_pass http://127.0.0.1:8080; passes the request URI through unchanged, while proxy_pass http://127.0.0.1:8080/; replaces the matched /coldtill/ with /. That one character is mistake number one from the list above. A rewrite that strips the prefix does the same damage.
One value in X-Forwarded-For. It's tempting to use $proxy_add_x_forwarded_for out of habit. The docs deliberately set it to $remote_addr, the single address nginx saw. Coldtill only trusts the rightmost X-Forwarded-For hop, and by default its Caddy only believes forwarded headers from private address ranges, which is where nginx connects from. That matters because the rate limits work per client IP: login is limited to 10 attempts a minute per IP and per email, and the merchant API to 600 requests a minute per IP. If every request looks like it comes from 127.0.0.1, your customers and your attackers share one bucket.
If something else sits in front of nginx, such as a CDN, $remote_addr will be the CDN's address, not the visitor's. Fix that in nginx with its real IP module before it gets passed on, so the one value you forward is the real one.
client_max_body_size 4m. The Caddy config in Coldtill's docs caps request bodies at 4 MB too, so this just keeps the two layers agreeing on the limit.
The paths that must stay open
Your customers need the checkout, and your shop's server needs the merchant API. Everything else under the prefix is the dashboard. Here's what has to be reachable without your admin login:
| Path | Used by |
|---|---|
/coldtill/pay/ | The checkout page |
/coldtill/api/checkout/ | The checkout page's own API calls |
/coldtill/api/v1/ | Your shop's server (merchant API) |
/coldtill/assets/, /coldtill/branding/, /coldtill/favicon.svg | Scripts, styles and logos for the checkout |
Miss /api/checkout/ and the checkout page will load but can't fetch the payment it's meant to show. Miss /branding/ and the customer sees a checkout without your logo. Both look like bugs in the gateway when they're actually in the proxy config.
Put the dashboard behind your own login
This is the main reason to run under a path at all: you already protect /admin or similar with something, and you want the payment dashboard behind the same thing. Protect the whole prefix, then carve out the open paths with a regex location:
location /coldtill/ { auth_request /your-admin-auth; # whatever already guards your admin pages proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 4m; } location ~ ^/coldtill/(pay/|api/checkout/|api/v1/|assets/|branding/|favicon\.svg$) { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 4m; } This works because of how nginx picks a location. It finds the longest matching prefix location, then checks regex locations in order, and a matching regex wins unless the prefix location was marked ^~. So don't add ^~ to the /coldtill/ block, or the open paths will quietly start demanding a login and your checkout will break for every customer.
Your layer sits in front of Coldtill's own, not instead of it. Login still needs the password and the two-factor code, and anything that moves money still asks for a fresh code.
Cookies and the Origin check
Two things the docs spell out, and that are easy to break with a "helpful" proxy setting.
The session cookie is scoped to the prefix. Signing in at /coldtill/ sets coldtill_session with Path=/coldtill, HttpOnly, SameSite=Strict, and Secure on https. Your main app never receives it. Coldtill does receive your main app's cookies that are set with Path=/, and ignores them.
Every dashboard request that changes something must be JSON and carry an Origin header whose host matches the site URL's host. So keep proxy_set_header Host $host;, and don't let nginx rewrite Origin. If saving a setting in the dashboard fails while everything else works, check this first.
What doesn't move
A few things stay where they were, which is worth knowing before you go looking for them under the prefix:
- Checkout domains. If a project has its own checkout domain, such as
pay.shop-two.com, it serves its checkout and merchant API at the root of that host. The path only applies to the site URL. - The health check. The container health check calls
/healthzat the root. From the server itself,curl -s http://127.0.0.1:8080/healthzshould printok. - Webhooks. Coldtill sends them to whatever URL you set for the project, wherever Coldtill itself runs.
On the shop side, the base URL now includes the path. With the TypeScript SDK:
import { Coldtill } from '@coldtill/sdk' const ct = new Coldtill({ baseUrl: 'https://example.com/coldtill', apiKey: process.env.COLDTILL_API_KEY!, }) const { url, reference_id } = await ct.createPayment({ customerID: '42', amountInUSD: 25, invoiceID: 'INV-1001', }) // url looks like https://example.com/coldtill/pay/<reference_id> A quick smoke test once it's up: create a test payment and check that the returned url contains /coldtill/pay/. Open it in a private window, where you're not signed in to your admin layer. The checkout should load with your logo. Then open https://example.com/coldtill/ in the same window. It should hit your auth layer, not the Coldtill login page.
Why I'd still pick a subdomain
Here's the part I promised. A path is not a security boundary.
Browsers isolate by origin, meaning scheme, host and port. example.com/coldtill and example.com/blog are the same origin. If your main app has a cross-site scripting bug, script running on any page of example.com counts as same-origin to Coldtill. While an admin is signed in, it can read Coldtill's pages and call the dashboard API. Cookie paths don't stop that; they were never designed to.
What limits the damage is the design underneath. A two-factor code is still needed before payouts, API keys and other sensitive actions. API payouts only go to address-book entries. And customer deposits sit in contracts that can only send to your cold wallet, so even full control of the server can't redirect them. But "the blast radius is limited" isn't the same as "it's fine".
So the rule from the docs is the one I'd follow: run Coldtill under a path only beside an app you trust as much as Coldtill itself. A static site you control, sure. A big plugin-heavy CMS with a dozen third-party scripts on every page, no. Give it its own subdomain, which the browser keeps separate, and protect the dashboard with Tailscale or a Cloudflare rule instead.
If you want to try this on a spare box, the free edition, install script and checksums are in the self-hosted gateway repo on GitHub. The "Run Coldtill under a path" section of the domains guide on coldtill.com has the same config with a bit more context. I'd do a testnet install first: get the nginx side right while nothing real is at stake.



