Multi-Tenant without Domain

Hi all,
I have two questions regarding the Multi-Tenant setup:

  1. If I do not have a registered Domain, only I have live IP on DigitalOcean, in this condition can I enable a multi-tenant feature for ERPNext?

  2. If I have a domain but it points to my website (eg: www.abc.com) which has different IP, can I use it subdomain (www.sub1.abc.com or www.sub2.abc.com) for a multi-tenant setup?

Regards,
MAK

1 Like

Well, sort of…
You can use only the IP address and setup the Multitenant as using different ports to represent each tenant. It will feel a bit wonky doing it that way since each site would be represented by a long string of ip numbers and port numbers. Will it work… yeah, but should you do it… probably not. It can get far too complicated.

Yup! This idea would work much better. I use this myself a lot to setup sandbox servers for testing different configurations of ERPNext. I own a few URL’s and then make each new tenant a subdomain of one of the owned URL’s. In this case you would be using Multitenant in DNS mode and it would be much easier to maintain.

BKM

Thanks for your quick reply…
Can you guide me: let assume my IP for the ERPnext server is 198.222.4.1 and I have another server in which my website is host www.abc.com. What changes I will made for the ERPNext server so that when I type www.sub1.abc.com it will show ERPNext site1.

Thanks
MAK

First of all you would not use www.sub1.abd.com
Instead you would use just sub1.abc.com

You will need to go to the servise where you purchased your URL abc.com and use their DNS section to setup the sub domains and then just point the subdomain to the IP address 198.222.4.1 in their DNS table.

Once you have that setup you can go to “whatsmydns.net” and enter your URL to see if it is fully propagated around the world so it will be available in the internet. Once that works everywhere (or at least in your region of the world) then you just use the instructions in the documentation to setup ERPNext as Multitenant and start adding sites and subdomains.

And before you ask… Yes, the system is smart enough to know that even though you are pointing multiple domain names to the same IP address they all go only to their respective ERPNext sites based on the separate site_config.json file with each site.

Hope this helps…

There are several tutorials on how to setup Multitenant here on the forum that can be found with a simple search.

BKM

1 Like

Wow!
Thanks, I will give it a try.

Regards,
MAK

I start to add a subdomain (sub1) from the Cpanel in my website abc.com. I am using Cloudflare then I add “A” record with my website IP. Then I create an index.html file on my hosting server, it is working fine.
Then I update ClouldFalre A record IP address (sub1) with my ERPNext server, and update the ERPNext Multi-Tenant settings:

  1. bench config dns_multitenant on
  2. Update the host’s file:
    198.222.4.1 sub1.abc.com (for example)
  3. bench setup nginx
  4. sudo service nginx restart

When I check sub1.abc.com in the browser, I received an error:

Error 521

Ray ID: 67cf7bb…494f • 2021-08-11 06:42:20 UTC

Web server is down

Anything I missed?

Regards,
MAK

1- If you don’t have a domain, you will not get an SSL certificate. so you can only work with HTTP, not HTTPS. Okay for a test installation, but not advisable for production env. Multi-tenant can be done with multiple TCP ports with the same IP
2-Yes.
We have documented this scenario here

Yes! You tried to force entries into files that do not need to be edited. Try it this way first:

bench config dns_multitenant on
bench setup add-domain --site site1.local [your.subdomain.here]
bench setup nginx
sudo service nginx restart

You do NOT need to update the host’s file. Let the site_config.json file take care of that all by itself using the steps above. If you want to then add additional tenants use the following steps:

(This assumes you already ran the “bench config dns_multitenant on” command)

bench new-site [your.2ndsbudomain.here] 
bench setup nginx
bench service nginx restart
bench --site [your.2ndsubdomain.here] install-app erpnext

At this point it seems you might be trying to over-think this process. The steps I laid out above will take care of updating all of the files that need changes and you do not have to edit anything manually except the manual setup of the DNS pointer to your IP Address at your service provider.

BKM

OK Sir,
Thanks for your assistance.

Regards,
MAK

@bkm
If we restart nginx with the command

bench service nginx restart

will this cause the other sites be non reachable for a certain period.
Is there a way to add a new-site and setup nginx without restart?

Yes, but usually less that a second. Possibly 2 seconds for a slow and overworked server.

I believe the command “sudo server nginx reload” will reload the config file without restarting the nginx binaries.

BKM

1 Like