I have a question about domains system
luccabassoli
PROOP

3 months 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

luccabassoli
PROOP

3 months ago

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


luccabassoli
PROOP

3 months ago

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

1441912994459160600


luccabassoli
PROOP

3 months ago

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
PRO

3 months 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

3 months 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!

luccabassoli
PROOP

3 months 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.comSetup cloudflare for saas on your pingalways.com domainDo all routing/rewriting through cloudflare.

luccabassoli
PROOP

3 months ago

I'll try that way too.


luccabassoli
PROOP

3 months ago

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


luccabassoli
PROOP

3 months ago

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

1442988746952937500
1442988747221107000
1442988747691135000


luccabassoli
PROOP

3 months 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.

1442989472655347700


luccabassoli
PROOP

2 months ago

@Chandrika can you helpme?


medim
MODERATOR

2 months ago

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



luccabassoli
PROOP

2 months ago

Hi?


luccabassoli
PROOP

2 months ago

Hi?


passos
MODERATOR

2 months 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

2 months ago

||sorry for accidental ping ludwig||


passos
MODERATOR

2 months 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.


luccabassoli
PROOP

2 months 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?


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

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


passos
MODERATOR

2 months ago

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



luccabassoli
PROOP

2 months ago

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


luccabassoli
PROOP

2 months ago

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


brody
EMPLOYEE

2 months ago

On Railway no, on Cloudflare, yes.


luccabassoli
PROOP

2 months ago

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


brody
EMPLOYEE

2 months ago

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


passos
MODERATOR

2 months 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

2 months 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

2 months ago

  1. You can do it with snippets -


passos
MODERATOR

2 months 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.


luccabassoli
PROOP

2 months ago

Humm


luccabassoli
PROOP

2 months 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.


luccabassoli
PROOP

2 months ago

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

2 months ago

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


luccabassoli
PROOP

2 months 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.


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

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


passos
MODERATOR

2 months ago

Hey, are you available now?


luccabassoli
PROOP

2 months ago

Hi


luccabassoli
PROOP

2 months 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.


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

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


luccabassoli
PROOP

2 months ago

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


passos
MODERATOR

2 months ago

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


passos
MODERATOR

2 months ago

1445542153894891800


luccabassoli
PROOP

2 months 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?


luccabassoli
PROOP

2 months ago

Mine is like that too.


luccabassoli
PROOP

2 months ago

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


passos
MODERATOR

2 months ago

It isn't? will confirm


passos
MODERATOR

2 months ago

Instead of Nginx Proxy Manager, use something else


passos
MODERATOR

2 months 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 :
}

luccabassoli
PROOP

2 months ago

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




passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

Ok


luccabassoli
PROOP

2 months ago

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


luccabassoli
PROOP

2 months ago

Change made


luccabassoli
PROOP

2 months ago

1445844913638867000


passos
MODERATOR

2 months ago

remove everything else


passos
MODERATOR

2 months ago

just keep the lines from 1-3


luccabassoli
PROOP

2 months ago

Removed


luccabassoli
PROOP

2 months ago

1445845549952532500


luccabassoli
PROOP

2 months ago

Now should I point the CNAME to this service?


passos
MODERATOR

2 months ago

Great, did you already enable Cloudflare SaaS?


luccabassoli
PROOP

2 months ago

Yes


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

1445846243141222400


luccabassoli
PROOP

2 months ago

This?

1445846409063563300


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

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


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

Ok


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

Ok


luccabassoli
PROOP

2 months ago

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


luccabassoli
PROOP

2 months ago

1445847098024136700


luccabassoli
PROOP

2 months ago

Which door should I put here?


passos
MODERATOR

2 months ago

Set 8080


luccabassoli
PROOP

2 months ago

Done


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

Ok


luccabassoli
PROOP

2 months ago

Done


passos
MODERATOR

2 months ago

Now, add that CNAME as a fallback origin


passos
MODERATOR

2 months ago

No, sorry


passos
MODERATOR

2 months ago

give me a minute


luccabassoli
PROOP

2 months ago

Ok


passos
MODERATOR

2 months 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

2 months ago

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


luccabassoli
PROOP

2 months ago

Like this?

1445849374142894000
1445849374360867000
1445849374621040600



luccabassoli
PROOP

2 months ago

Done

1445849876414861600


passos
MODERATOR

2 months ago

No, on Railway remove the custom domain


passos
MODERATOR

2 months ago

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


passos
MODERATOR

2 months ago

And then create a CNAME to it


luccabassoli
PROOP

2 months ago

That way?

1445851182827307000


passos
MODERATOR

2 months ago

Great, just fix this


luccabassoli
PROOP

2 months ago

Fixed


luccabassoli
PROOP

2 months ago

1445851558595137800


passos
MODERATOR

2 months ago

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


passos
MODERATOR

2 months ago

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


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

Yes


luccabassoli
PROOP

2 months ago

I am on the page.


luccabassoli
PROOP

2 months ago

1445852867142484200


luccabassoli
PROOP

2 months ago

1445852948415516700


passos
MODERATOR

2 months ago

No, it's another one


passos
MODERATOR

2 months ago

Should be in the same category in the sidebar


luccabassoli
PROOP

2 months ago

1445853303001845800


passos
MODERATOR

2 months ago

Try "Visão geral"


luccabassoli
PROOP

2 months ago

1445853744502800400


luccabassoli
PROOP

2 months ago

1445853838476181500


passos
MODERATOR

2 months ago

Click on "Nova Regra"


luccabassoli
PROOP

2 months ago

1445853995632558000


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

For me, that option is not available.


luccabassoli
PROOP

2 months ago

It does not appear on the list.


passos
MODERATOR

2 months ago

It's the last page, first item

1445855328372527000


luccabassoli
PROOP

2 months ago

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



luccabassoli
PROOP

2 months ago

Good!


luccabassoli
PROOP

2 months ago

It worked haha, I'm here.


luccabassoli
PROOP

2 months ago

1445856020449595400


passos
MODERATOR

2 months ago

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

1445856551284768800


luccabassoli
PROOP

2 months ago

Done


luccabassoli
PROOP

2 months ago

1445857571415265500


luccabassoli
PROOP

2 months ago

1445857651195122000


passos
MODERATOR

2 months 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/


luccabassoli
PROOP

2 months 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.


luccabassoli
PROOP

2 months ago

2019 or 80?

1445858646863905000


luccabassoli
PROOP

2 months ago

1445858774094057700


passos
MODERATOR

2 months ago

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


passos
MODERATOR

2 months ago

If not, maybe try 2019 on Railway


luccabassoli
PROOP

2 months ago

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



luccabassoli
PROOP

2 months ago

working now


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

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


luccabassoli
PROOP

2 months ago

In the application, it is as follows

1445859675512901600


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

Ok


passos
MODERATOR

2 months ago

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


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

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


passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

2 months ago

ERRTOOMANY_REDIRECTS is occurring


passos
MODERATOR

2 months ago

What you can do is turn on the Full option.


passos
MODERATOR

2 months 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

2 months ago

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


luccabassoli
PROOP

2 months ago

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


passos
MODERATOR

2 months ago

yeah, then follow my instructions here


luccabassoli
PROOP

2 months ago

Ok


luccabassoli
PROOP

2 months ago

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

passos
MODERATOR

2 months ago

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


luccabassoli
PROOP

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

luccabassoli
PROOP

2 months ago

Resolved


luccabassoli
PROOP

2 months ago

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

passos
MODERATOR

2 months ago

Great, any more issues that you're having?


luccabassoli
PROOP

2 months ago

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



Status changed to Solved passos 2 months ago


Loading...