Hi,
I am setting up a multi-tenant system with ASP.NET Zero using subdomains and have structured my application as follows:
-
Landing Page:
mydomain.com
(public landing page) -
Host & Tenant Registration:
app.mydomain.com
(admin panel & new tenant creation) -
Tenant Subdomains:
-
tenant1.mydomain.com
-
tenant2.mydomain.com
-
-
Additional Services:
-
API:
api.mydomain.com
-
Reporting Service:
report.mydomain.com
-
Current Configuration
appsettings.production.json
"App": {
"ServerRootAddress": "https://{TENANCY_NAME}.api.mydomain.com",
"ClientRootAddress": "https://{TENANCY_NAME}.app.mydomain.com",
"CorsOrigins": "https://*.mydomain.com"
}
appconfig.json
"remoteServiceBaseUrl": "https://api.mydomain.com",
"appBaseUrl": "https://{TENANCY_NAME}.app.mydomain.com"
My Issues & Questions
-
Access Issue:
-
Currently, I can only access the app via
tenant.app.mydomain.com
, but nottenant.mydomain.com
. -
What could be causing this, and what needs to be adjusted for direct subdomain access (e.g.,
tenant1.mydomain.com
)?
-
-
DNS Configuration:
-
What type of A or CNAME record is required?
-
I assume I need
*.mydomain.com
, but do I also need specific entries forapp.mydomain.com
,api.mydomain.com
, andreport.mydomain.com
?
-
-
Additional Setup Requirements:
-
What else needs to be configured in ASP.NET Zero to ensure the described setup works correctly?
-
Are there any required changes in the tenancy resolution, CORS policies, or middleware settings?
-
Thanks for your help!
1 Answer(s)
-
0
Hi
Access Issue (tenant.mydomain.com Not Working)
Your current setup is configured to use {TENANCY_NAME}.app.mydomain.com, meaning the system expects tenants to be accessed via tenant1.app.mydomain.com, not tenant1.mydomain.com. To enable direct access via tenant1.mydomain.com, you'll need to:
By default, ASP.NET Zero uses subdomains in the format
{TENANCY_NAME}.yourdomain.com
, but your configuration suggests it expects{TENANCY_NAME}.app.mydomain.com
.-
Update ClientRootAddress & ServerRootAddress:
-
Modify your appsettings.json to reflect
https://{TENANCY_NAME}.mydomain.com
instead ofhttps://{TENANCY_NAME}.app.mydomain.com
.
-
DNS Configuration
To support wildcard subdomains for your tenants and services, you'll need the following DNS records:
-
Wildcard Subdomain:
-
mydomain.com → A record → Your server's IP (or CNAME if using a load balancer).
-
This ensures that tenant1.mydomain.com, tenant2.mydomain.com, etc., resolve properly.
-
-
Explicit Entries (if not covered by *.mydomain.com):
-
app.mydomain.com → A record → Your web app server IP.
-
api.mydomain.com → A record → API server IP.
-
report.mydomain.com → A record → Reporting service IP.
-
Additional Setup Requirements
To ensure everything functions correctly, consider the following adjustments:-
CORS Configuration:
-
Ensure
CorsOrigins
in appsettings..json allowshttps://*.mydomain.com
.
-
-
Wildcard SSL Certificate:
-
Ensure your SSL certificate supports
*.mydomain.com
to cover all tenant subdomains.
-
-