Multi-Domain setup in one app
-
Using Phoenix Elixir, I want to build one monorepo app that hosts mini-apps with shared code base that should be reachable under different domains.
I have set up my reverse proxy and tested it. On Cloudron, I have set one app as the main domain and the other one as alias. In the cloudron manifest, I have set
"multiDomain": true,
To debug whether the issue is with Cloudron or my proxy setup, I have run this in the app container:
curl -v -H "Host: Domain1" http://localhost:4000/
and respectively with the other domain. 4000 is the port of the proxy inside my app. Both responses resolve the correct site, so I am assuming that my proxy setup works.
Yet the issue is that Cloudron resolves only the main domain. When I access domain2, I am forwarded to domain1 and my app's logs indicate someone had tried to access domain1.
How can I debug this?
-
-
@robi said in Multi-Domain setup in one app:
How did you define domain2 in the manifest?
I don't think this is possible based on the manifest documentation. I can only set multidomain to true, and then define an alias later.
@joseph said in Multi-Domain setup in one app:
you can inspect the generated reverse proxy config in /etc/nginx/applications/appid/ .
Thank you, I am working through it right now!
-
Okay, I found the issue. The problem was that for testing purposes, domain2 was a subdomain of domain1. So, all calls made to domain2 where resolved to domain1 - however, not by my app, but by cloudron. When I connected a top-level domain to Cloudron and changed it in my app's settings, the app resolved correctly both domains.
However, I wonder if that should be the case. Granted, if you wanted to use a subdomain, you probably wouldn't need the multi-domain setup, but at least for testing, I would have assumed this would work.
I believe the issue is that Cloudron didn't preserver the original host.
-
Okay, I found the issue. The problem was that for testing purposes, domain2 was a subdomain of domain1. So, all calls made to domain2 where resolved to domain1 - however, not by my app, but by cloudron. When I connected a top-level domain to Cloudron and changed it in my app's settings, the app resolved correctly both domains.
However, I wonder if that should be the case. Granted, if you wanted to use a subdomain, you probably wouldn't need the multi-domain setup, but at least for testing, I would have assumed this would work.
I believe the issue is that Cloudron didn't preserver the original host.
@ekevu123 said in Multi-Domain setup in one app:
So, all calls made to domain2 where resolved to domain1 - however, not by my app, but by cloudron
Do you mean, domain1 is like
app.example.com
and domain2 is liketest.app.example.com
? (whereexample.com
was added in the Domains UI ?)by resolved, do you mean DNS resolution?
-
@ekevu123 said in Multi-Domain setup in one app:
So, all calls made to domain2 where resolved to domain1 - however, not by my app, but by cloudron
Do you mean, domain1 is like
app.example.com
and domain2 is liketest.app.example.com
? (whereexample.com
was added in the Domains UI ?)by resolved, do you mean DNS resolution?
@joseph said in Multi-Domain setup in one app:
Do you mean, domain1 is like app.example.com and domain2 is like test.app.example.com ? (where example.com was added in the Domains UI ?)
Yes, domain 1 was example.com and domain 2 was test.example.com. When I changed app 2 and connected anotherexample.com, it worked, so the issue was with using a subdomain compared to using a different domain - in my opinion, because Cloudron cut this information, so my proxy didn't have a chance to get this right.
@joseph said in Multi-Domain setup in one app:
by resolved, do you mean DNS resolution?
0
I am referring to the end result, so any traffic to domain2 (subdomain) went to domain1 for whatever reason.
-
I can't seem to reproduce it atleast. I setup an app with domain and subdomain (using minio app, which has same setup as yours) and it seems to work . If you can reproduce it with say minio , maybe that will help us narrow it down. Also, which DNS provider are you using (just to rule out any wildcard/manul DNS setup issues) ?
-
Thank you for checking, I really appreciate it! I had one domain with HostEurope and one with Porkbun.
I will look into Minio, but since that's a completely new codebase, and I might need to extract additional logs from that to understand the difference, I might not be able to do that.