Skip to content
I have a question about domains system

a year ago

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

a year ago

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


a year ago

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

1441912994459160627


a year ago

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

1441913387155062794


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


dtknepper

a year 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.

a year 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!

a year ago

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.com` 1. Setup cloudflare for saas on your `pingalways.com` domain 2. Do all routing/rewriting through cloudflare.

a year ago

I'll try that way too.


a year ago

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


a year ago

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

1442988746952937482

1442988747221106910

1442988747691135098


a year ago

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.

1442989472655347762


a year ago

@Chandrika can you helpme?


a year ago

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



a year ago

Hi?


a year ago

Hi?


a year 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?


a year ago

||sorry for accidental ping ludwig||


a year 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.


a year ago

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?


a year ago

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


a year ago

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


a year ago

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



a year ago

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


a year ago

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


a year ago

On Railway no, on Cloudflare, yes.


a year ago

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


a year ago

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


a year ago

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


a year 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.


a year ago

  1. You can do it with snippets -

a year 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.


a year ago

Humm


a year ago

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.


a year ago

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


a year ago

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


a year ago

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.


a year ago

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


a year ago

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


a year ago

Hey, are you available now?


a year ago

Hi


a year ago

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.


a year ago

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


a year ago

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


a year ago

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


a year ago

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



a year ago

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?


a year ago

Mine is like that too.


a year ago

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


a year ago

It isn't? will confirm


a year ago

Instead of Nginx Proxy Manager, use something else


a year 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 :
}

a year ago

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




a year ago

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


a year ago

Ok


a year ago

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


a year ago

Change made



a year ago

remove everything else


a year ago

just keep the lines from 1-3


a year ago

Removed



a year ago

Now should I point the CNAME to this service?


a year ago

Great, did you already enable Cloudflare SaaS?


a year ago

Yes


a year ago

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




a year ago

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


a year ago

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


a year ago

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


a year ago

Ok


a year ago

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


a year ago

Ok


a year ago

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



a year ago

Which door should I put here?


a year ago

Set 8080


a year ago

Done


a year ago

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


a year ago

Ok


a year ago

Done


a year ago

Now, add that CNAME as a fallback origin


a year ago

No, sorry


a year ago

give me a minute


a year ago

Ok


a year ago

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

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


a year ago

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



a year ago

Oops, cname.hyren.net is missing go to proxy-fallback.hyren.net.



a year ago

No, on Railway remove the custom domain


a year ago

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


a year ago

And then create a CNAME to it



a year ago

Great, just fix this


a year ago

Fixed



a year ago

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


a year ago

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


a year ago

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


a year ago

Yes


a year ago

I am on the page.




a year ago

No, it's another one


a year ago

Should be in the same category in the sidebar



a year ago

Try "Visão geral"




a year ago

Click on "Nova Regra"



a year ago

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


a year ago

For me, that option is not available.


a year ago

It does not appear on the list.


a year ago

It's the last page, first item

1445855328372527215


a year ago

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



a year ago

Good!


a year ago

It worked haha, I'm here.



a year ago

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

1445856551284768882


a year ago

Done




a year 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/


a year ago

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.


a year ago



a year ago

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


a year ago

If not, maybe try 2019 on Railway


a year ago

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



a year ago

working now


a year ago

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


a year ago

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


a year ago

In the application, it is as follows

1445859675512901713


a year ago

No, cname.hyren.net is not used.


a year ago

Ok


a year ago

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


a year ago

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


a year ago

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


a year ago

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


a year ago

ERR_TOO_MANY_REDIRECTS is occurring


a year ago

What you can do is turn on the Full option.


a year 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 :
}

a year ago

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


a year ago

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


a year ago

yeah, then follow my instructions here


a year ago

Ok


a year ago

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

a year ago

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


a year ago

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)}

a year ago

Resolved


a year ago

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

a year ago

Great, any more issues that you're having?


a year ago

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



Status changed to Solved passos • 12 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...