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.comtenant2.mydomain.com
- Additional Services:
- API:
api.mydomain.com - Reporting Service:
report.mydomain.com
- API:
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)?
- Currently, I can only access the app via
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!
2 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.cominstead ofhttps://{TENANCY_NAME}.app.mydomain.com.
- Modify your appsettings.json to reflect
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
CorsOriginsin appsettings..json allowshttps://*.mydomain.com.
- Ensure
Wildcard SSL Certificate:
- Ensure your SSL certificate supports
*.mydomain.comto cover all tenant subdomains.
- Ensure your SSL certificate supports
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) - Update ClientRootAddress & ServerRootAddress:
-
0
I am using cloudflare and define rules to set tenantId in header for spesific sub/domains, you may also set inbound rules on iis to set tenantId in header
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)