I have a question about domains system

I have a question: does your domain system accept my CNAME system? For example, I have a multi-tenant system, and I need it to work with multiple domains, and my customers can point the domain to the platform. Is this possible? Currently, I release cname.domain.tld to my customers, and they point CNAME to their domains.

Solved$10 Bounty

163 Replies

My system is a store for game servers, similar to tebex.


When I point to a custom domain, I get an error.

1441912994459160600


This error occurs when I try to access the custom domain that is pointed to in the CNAME.

1441913387155062800


Did you make sure the proxied port is the port your application is listening to?


dtknepper
HOBBY

15 days ago

Hi man,

I am currently working on a similar style app and what I am doing is the following.

1. Setup a wildcard domain on railway so you can have customer.pingalways.com

  1. Setup cloudflare for saas on your pingalways.com domain

  2. Do all routing/rewriting through cloudflare.


passos
MODERATOR

15 days ago

Hey, Railway has support for wildcard domains. Here's the full documentation on how to set it up: https://docs.railway.com/guides/public-networking#wildcard-domains.

I would recommend removing any custom domains (even DNS records) you've added and trying again from scratch by following the documentation above.

If you hit any roadblocks, let us know!


passos

Hey, Railway has support for wildcard domains. Here's the full documentation on how to set it up: https://docs.railway.com/guides/public-networking#wildcard-domains.I would recommend removing any custom domains (even DNS records) you've added and trying again from scratch by following the documentation above.If you hit any roadblocks, let us know!

I'll take a look to do it that way.


dtknepper

Hi man,I am currently working on a similar style app and what I am doing is the following.1. Setup a wildcard domain on railway so you can have customer.pingalways.comSetup cloudflare for saas on your pingalways.com domainDo all routing/rewriting through cloudflare.

I'll try that way too.


From what I've seen in the documentation, do I need to register each of my clients' domains in your dashboard?


My current setup, railway and Cloudflare (DNS and CF for SaaS). Is there anything wrong with it?

1442988746952937500
1442988747221107000
1442988747691135000


I am getting the error “Invalid SSL certificate” when pointing to the domain hyren.luccabassoli.com (example domain for a customer's store). This domain is pointed to cname.hyren.net and configured in Cloudflare for SaaS, which I use their API to register.

1442989472655347700


@Chandrika can you helpme?


medim
MODERATOR

12 days ago

Please don't ping team members! #🛂|readme 5)



Hi?


Hi?


passos
MODERATOR

10 days ago

Hey @Lucca Bassoli, I'm trying to understand your case. Do you have multiple client domains that you want Railway to support? Are these domains dynamic rather than static?


passos
MODERATOR

10 days ago

||sorry for accidental ping ludwig||


passos
MODERATOR

10 days ago

If that's a yes, then I'm afraid your case isn't supported. Railway currently only supports a set of known domains. I'm guessing that your use case is some kind of shop that users can create and is known by their own custom domain.


I have a system where my system's client can point their domain through cname. I release a cname (cname.hyren.net) and it points to domain.tld, but when it points, it does not show the website and gives an SSL error. Do I need to register the client's domain in the railway domains?


passos
MODERATOR

10 days ago

Yes, you're required to register your client's domain in Railway.


Is there a limit? Can I change my limits? Because I would need to run more than 100 stores.


passos
MODERATOR

10 days ago

Yes, the Pro Plan is limited to 20 domains per service. The Railway Team might increase this limit upon request.



I saw that thread, but it seems they didn't get anywhere.


So it seems to me that this is not possible to do on the Railroad.


brody
EMPLOYEE

9 days ago

On Railway no, on Cloudflare, yes.


Okay, but I use Cloudflare for SaaS. How can I point to the application? How do I do that in Cloudflare?


brody
EMPLOYEE

9 days ago

I'm sorry but we cannot provide support for 3rd party services, I'll let the community assist with that.


passos
MODERATOR

9 days ago

I'm unfamiliar with Cloudflare SaaS, but I'm testing how it would work on your specific setup, give me a minute.


passos
MODERATOR

9 days ago

I've managed to figure it out, but be aware, it's quite complicated to follow.

  1. Since Cloudflare only allows Host header rewrites on Enterprise plans, we'll not be able to use Railway's proxy so deploy an Nginx instance on Railway and expose it via TCP proxy to access its port directly.

  2. Configure Cloudflare SaaS. When defining your fallback origin (where traffic routes), specify your TCP proxy's domain without the port number as a CNAME.

  3. Create an origin rule in Cloudflare to route all incoming traffic to Railway's TCP proxy port.

  4. Under Cloudflare's SSL/TLS settings, enable Flexible encryption mode to allow the HTTP traffic.

If you really want to proceed with it, let me know and I can guide you through their dashboard using screenshots. However, I completely understand if you choose not to, as unfortunately, I don't think Railway is the best option for you in this situation.

Maybe the team can increase your domain limits, after which you'll be able to complete the task either manually or via API until Railway develops a more effective solution for this issue.


brody
EMPLOYEE

9 days ago

  1. You can do it with snippets -


passos
MODERATOR

9 days ago

Only available on Pro Plans and above. I won't be able to help here on how to set up the snippets as I don't have the Pro Plan. But in theory, it should be a simple script to rewrite the Host header to be yours and then include an extra header to identify which domain it is.


Humm


I am interested in continuing, as Ralway is a good place to deploy and I already have several applications with them. If you could help me with step-by-step instructions on printing 🙂 That would even help the community.


Cloudflare Snippets is only available on the Pro plan. I am currently on Cloudflare's free plan. I only pay for their SaaS.


brody
EMPLOYEE

8 days ago

I think if you are running a business and you use Cloudflare it would be reasonable to be on their Pro plan?


If I can do it for free, there's no reason to pay for it. I don't have that many customers. I only use their routing for SaaS and some blocking rules. But I intend to pay for it. I just don't see much reason to do so yet.


passos
MODERATOR

7 days ago

Great, just give me sometime to get off work (might take awhile), i'll mention you here.


Okay, thanks for your help. I look forward to hearing from you!


passos
MODERATOR

7 days ago

Hey, are you available now?


Hi


I wasn't home at that time, but if you want, you can send it and I'll take a look. I don't think we'll be able to synchronize due to the time zones, haha.


passos
MODERATOR

6 days ago

@Lucca Bassoli Are you able to follow it? If you have any questions, just send them here. I'll be active.


How do I upgrade nginx? The Railway template I saw here doesn't save the data correctly.


Can you send me your DNS record settings? Mine already has flexible SSL.


passos
MODERATOR

6 days ago

Sorry for delay, I would recommend using the Nginx Proxy Manager as it offers a nice UI to manage it


passos
MODERATOR

6 days ago

1445542153894891800


I installed that one, but it isn't saving the data. It seems that when it restarts, it loses the credentials and settings. How did you solve that?


Mine is like that too.


I reinstalled nginx proxy manager. How are your settings in it?


passos
MODERATOR

5 days ago

It isn't? will confirm


passos
MODERATOR

5 days ago

Instead of Nginx Proxy Manager, use something else


passos
MODERATOR

5 days ago

Instead of Nginx Proxy Manager, use the Caddy template.

  1. Deploy the template

  2. Click on the service created, go to settings and then eject, follow instructions to eject

  3. On the repository created by Railway, modify the Caddyfile to be something like this:

:{$PORT} {
    reverse_proxy :
}

What is the caddy template? I don't understand.




passos
MODERATOR

5 days ago

Try that first and then I'll get you a better config that handles service replicas and more


Ok


It seems to me that what I sent is the same, isn't it?


Change made



passos
MODERATOR

5 days ago

remove everything else


passos
MODERATOR

5 days ago

just keep the lines from 1-3


Removed



Now should I point the CNAME to this service?


passos
MODERATOR

5 days ago

Great, did you already enable Cloudflare SaaS?


Yes


passos
MODERATOR

5 days ago

Now, you'll add a TCP proxy to your Caddy application



This?

1445846409063563300


passos
MODERATOR

5 days ago

Yep, first add the PORT environment variable to your service, PORT=8080 is define


A gente está falando em ingles e agora vi que vc é br 😐


passos
MODERATOR

5 days ago

On here, each customer you add will need to be added there, you can remove your CNAME


Ok


passos
MODERATOR

5 days ago

Yeah, but Railway wants to keep every message in here in English. It keeps things more organized.


Ok


The custom host name cname.hyren.net has been deleted.



Which door should I put here?


passos
MODERATOR

5 days ago

Set 8080


Done


passos
MODERATOR

5 days ago

Railway will give you a combination of domain:port, create a CNAME pointing to the domain only


Ok


Done


passos
MODERATOR

5 days ago

Now, add that CNAME as a fallback origin


passos
MODERATOR

5 days ago

No, sorry


passos
MODERATOR

5 days ago

give me a minute


Ok


passos
MODERATOR

5 days ago

After you've added that CNAME, create another one that points to that one

So if you've created [proxy-fallback.hyren.net](proxy-fallback.hyren.net) thats points to Railway for example, create another CNAME that points to that, for example [customers.hyren.net](customers.hyren.net) points to [proxy-fallback.hyren.net](proxy-fallback.hyren.net)


passos
MODERATOR

5 days ago

And then add the [proxy-fallback.hyren.net](proxy-fallback.hyren.net) into Cloudflare SaaS as a fallback origin


Like this?

1445849374142894000
1445849374360867000
1445849374621040600



Done

1445849876414861600


passos
MODERATOR

5 days ago

No, on Railway remove the custom domain


passos
MODERATOR

5 days ago

you should get the combination below it shuttle.<…>


passos
MODERATOR

5 days ago

And then create a CNAME to it


That way?

1445851182827307000


passos
MODERATOR

5 days ago

Great, just fix this


Fixed



passos
MODERATOR

5 days ago

Now we'll create a page rule to redirect all traffic to that Railway port


passos
MODERATOR

5 days ago

Can you find where we can create that? I don't have the URL unfortunately


passos
MODERATOR

5 days ago

It should be in the sidebar, named as "rules" or "origin rules"


Yes


I am on the page.




passos
MODERATOR

5 days ago

No, it's another one


passos
MODERATOR

5 days ago

Should be in the same category in the sidebar



passos
MODERATOR

5 days ago

Try "Visão geral"




passos
MODERATOR

5 days ago

Click on "Nova Regra"



passos
MODERATOR

5 days ago

Sorry, go to "Modelos" and then navigate to the last page, where you should find a "Change Port" template.


For me, that option is not available.


It does not appear on the list.


passos
MODERATOR

5 days ago

It's the last page, first item

1445855328372527000


Can you click on it and send me the link it redirected you to? I'll change the parameters according to my account.



Good!


It worked haha, I'm here.



passos
MODERATOR

5 days ago

Great, now on Rewrite to set 23113 (the same as Railway), also make sure to set the following Custom Filter Expression

1445856551284768800


Done




passos
MODERATOR

5 days ago

That should've been the last step but I'm unable to connect to your Caddy service, are you sure it's up? http://shuttle.proxy.rlwy.net:23113/


Yes, but it seems that it is not on the correct port where the TCP proxy was generated. From what I can see in the logs, it is running on another port.


2019 or 80?

1445858646863905000



passos
MODERATOR

5 days ago

Definitely weird, you added the PORT environment variable, right?


passos
MODERATOR

5 days ago

If not, maybe try 2019 on Railway


True, I hadn't seen the email. It's running at 80.



working now


passos
MODERATOR

5 days ago

I'm seeing it's working https://hyren.luccabassoli.com/ 👀


One question: do I need to register cname.hyren.net in the application?


In the application, it is as follows

1445859675512901600


passos
MODERATOR

5 days ago

No, [cname.hyren.net](cname.hyren.net) is not used.


Ok


passos
MODERATOR

5 days ago

Every customer that you add simply needs to be added on Cloudflare


passos
MODERATOR

5 days ago

If you want to automate that, Cloudflare has APIs for that.


I can no longer access the main domain. Do I need to point it to the CNAME?


passos
MODERATOR

5 days ago

Maybe it's related to the SSL/TLS flexible option as Cloudflare is now sending HTTP traffic instead of HTTPS


ERRTOOMANY_REDIRECTS is occurring


passos
MODERATOR

5 days ago

What you can do is turn on the Full option.


passos
MODERATOR

5 days ago

And then change your Caddy config to generate a self signed certificate
Something like this should do the trick:

{
    acme_ca internal
}

:${PORT} {
    tls internal
    reverse_proxy :
}

passos
MODERATOR

5 days ago

To be sure, turn on the Full option first and see if it recovers the main domain


I activated Full, the main domain came back, but the one using cname stopped working.


passos
MODERATOR

5 days ago

yeah, then follow my instructions here


Ok


Error: adapting config using caddyfile: parsing key: invalid port '${PORT}': strconv.Atoi: parsing "${PORT}": invalid syntax

passos
MODERATOR

5 days ago

change :${PORT} to :{$PORT}


A new error occurred

Error: adapting config using caddyfile: automation policy from site block is also default/catch-all policy because of key without hostname, and the two are in conflict: []certmagic.Issuer(nil) != []certmagic.Issuer{(*caddytls.InternalIssuer)(0xc0002d3560)}

Resolved


:{$PORT} {
    tls internal
    reverse_proxy hyren-web.railway.internal:8080
}

passos
MODERATOR

5 days ago

Great, any more issues that you're having?


None, thank you very much for your help! 🤝 🇧🇷



Status changed to Solved passos 5 days ago


Loading...