Wildcard Domains for Individual Projects
akhil-naidu
PROOP

a year ago

Railway is providing wildcard domains for a single multi-tenant application. But what if I want to have multi-domain setup for all of customers.

Context

I'm using railway in background to provide dedicated resources to my clients, and providing my application as SAAS using railway public api in background.

For each customer, I was able to create create a domain using public API, and I was also able to allow them to attach it to their domain name.

But, I want to generate a domain name for preview purposes which is not of railway.app

One might ask, why is it so important to have a custom preview URL! Me and my team feel like the app looks more premium when we have our own domain for preview URLs.

If it is not currently possible using railway, we are planning to use the Cloudflare typescript SDK. But, I would also like to know about the best way of automating this using existing railway domains.

7 Replies

brody
EMPLOYEE

a year ago

Unless i'm not understanding something, why can't you use a wildcard custom domain?


akhil-naidu
PROOP

a year ago

For every project I create to my customer, I would like to generate a private preview domain. I don't think we can do it using the existing wildcard domain configuration.The existing wildcard domain only supports, multi-tenant applications that are in same project.


brody
EMPLOYEE

a year ago

I'm sorry but your request is not clear, please provide an actual real word example.


akhil-naidu
PROOP

a year ago

Take my scenario as an example. I've created a docker image which I'm planning to use as saas to my customers. Every customer who comes to my application will have the ability to use this docker image and spin up their own service. In order to achieve this I'm using Railway Public API to create a project using the docker image for each customer.Everything is working great, except that the domain generated by railway for new projects is suffixed with *.railway.app. I wan't to ensure this domain was not from railway but my own domain.## To be more specific.Using railway admin panel, if I create a new project, I wan't the autogenerated domain name to be subdomain.example.com, where example.com is my domain name.


brody
EMPLOYEE

a year ago

Okay I think I understand better, and if so, what is stopping you from using the API to attach your custom domain to a given service? in doing so Railway's API will return a CNAME that you would then use with (for example) Cloudflare's API to finish the domain setup, this is what other users have done in the past.


akhil-naidu
PROOP

a year ago

Usually my docker deployment takes upto 20 seconds. But in-order for the domain to be used by the users it is taking more than 60 seconds. To which if I added my own domain name using Cloudflare SDK, it added up almost another 30 to 40 seconds.Though the image was deployed, it is taking more than 2 minutes for the user to access it, until then a 404 from railway is the only option. Our QA felt like this is something we want to reduce.

Solution:

If there is no option to add wildcard domain to my railway account and propagate it to my projects, the better way is to use the cloudflare sdk + edge network (beta).But for some reason, I can't turn on the edge network programatically(via public api or config as code) in my team's admin account.If I opt in for the feature flags in my personal account, any project created in my personal account has default edge network enabled, but not in my team's account. The same also goes for webhook creation(unable to create webhook for a project using team token)So to resolve this efficiently, the only solution I have is:

  1. Use public API to create a project in my personal account using my personal token

  2. As feature flag was enabled it will get edge network and the url availability is almost instant (within 20 seconds)

  3. create webhook so that I can track the deployment status in UI

  4. Then again use public api and add a subdomain

  5. Use cloudflare sdk and configure it

  6. Lastly I need to transfer this project from my personal account to teams account

  7. Now for any future updates from user on the ENV variables side, I need to again use my team token to propagate the changes

Rather than working on all of these, if I can add a subdomain to my railway account, and if all the projects come under my domain, like project-1.app.example.com , configured CNAME would be on *.app.example.com , such a system would be very useful for creating SAAS applications.


brody
EMPLOYEE

a year ago

Okay I fully understand now.

Yes it would be great if you could set a domain that would propagate in one way or another, but that's a very big feature request and not something that would be easily implemented any time soon.

The fast track solution would be allowing Pro users to enable the edge proxy as that would completely eliminate the 404 as that was one of the biggest point of developing the edge proxy. And for that, the team would need to get involved.


Loading...