Request to Increase Custom Domain Limit for SaaS Marketplace
rettibeatz
PROOP

a month ago

We are building a multi-tenant SaaS platform using Cloudflare for SaaS Custom Hostnames. Our understanding is that customer-owned domains should be dynamically onboarded through Cloudflare without individually registering every hostname on the origin. However, Railway appears to reject requests for unregistered Host headers and returns "The train has not arrived at the station." Is there an officially supported way to use Railway as the origin for Cloudflare for SaaS without registering every customer domain individually? If not, is there an API for automatically registering customer domains, or is this functionality on the roadmap?

$20 Bounty

5 Replies

Railway
BOT

a month ago

Railway's edge requires every served hostname to be registered on the service, so there is no catch-all mode for unregistered Host headers, which is why you're seeing the "train has not arrived" response. The Pro plan allows 20 custom domains per service, and we don't increase that limit for multi-tenant use cases. There is a public API for managing domains (the customDomainCreate mutation), but it's subject to the same per-service cap. For a Cloudflare for SaaS architecture at scale, the recommended pattern is to have Cloudflare proxy traffic to your Railway service's origin hostname and use a forwarded header (like X-Forwarded-Host) for tenant routing in your application, rather than registering each customer domain on Railway.


Status changed to Awaiting User Response Railway about 1 month ago


Railway

Railway's edge requires every served hostname to be registered on the service, so there is no catch-all mode for unregistered Host headers, which is why you're seeing the "train has not arrived" response. The Pro plan allows 20 custom domains per service, and we don't increase that limit for multi-tenant use cases. There is a [public API for managing domains](https://docs.railway.com/integrations/api/manage-domains) (the `customDomainCreate` mutation), but it's subject to the same per-service cap. For a Cloudflare for SaaS architecture at scale, the recommended pattern is to have Cloudflare proxy traffic to your Railway service's origin hostname and use a forwarded header (like `X-Forwarded-Host`) for tenant routing in your application, rather than registering each customer domain on Railway.

rettibeatz
PROOP

a month ago

I am using Cloudflare for SaaS with Railway as the origin. Railway requires that incoming requests use the origin hostname (for example, customers.beatmantra.com) and recommends routing tenants using X-Forwarded-Host. My middleware already reads X-Forwarded-Host before Host, but Railway still rejects custom domains with "The train has not arrived at the station," which suggests the request is arriving with Host: rettibeatz.com instead of Host: customers.beatmantra.com. How should Cloudflare for SaaS be configured so that the origin request uses the fallback/origin hostname while preserving the customer's hostname in X-Forwarded-Host?


Status changed to Awaiting Railway Response Railway about 1 month ago


Railway
BOT

a month ago

This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.

Status changed to Open Railway about 1 month ago


You can add a wildcard domain (*.beatmantra.com) to your service.


rettibeatz
PROOP

a month ago

I'm building a multi-tenant SaaS marketplace (BeatMantra) using Cloudflare for SaaS and Railway as the origin.

Current setup:

Next.js on Railway

Cloudflare for SaaS (Custom Hostnames)

Fallback origin: fallback.beatmantra.com

CNAME target: customers.beatmantra.com

Middleware routes custom domains using X-Forwarded-Host before Host.

My middleware currently does:

const rawHost =

req.headers.get("x-forwarded-host") ??

req.headers.get("host") ??

"";

The problem is that requests to rettibeatz.com never reach my middleware. Railway returns:

"The train has not arrived at the station."

while Cloudflare reports:

hostname_status = active

ssl_status = pending_validation

My question is:

Has anyone successfully used Cloudflare for SaaS with Railway without registering every customer domain on Railway?

If so:

Does Cloudflare need to rewrite the Host header to the Railway origin (customers.beatmantra.com) while preserving the original hostname in X-Forwarded-Host?

Is there any Railway configuration required to accept Cloudflare SaaS origin requests?

Can anyone share a working Cloudflare for SaaS + Railway architecture?


a month ago

You are correct, you need to have Cloudflare override the host header to a domain that you have added to the target service, not the CNAME we give you.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...