Pointing multiple URLs to same site in a multitenant ERPNext setup

Hi,

I want to point multiple urls to a single site in a multitenant ERPNext setup. Any idea what changes do I need to do in nginx configuration to achieve this ? Any bench functionality to achieve this ?

Thanks,
Palash

1 Like

Follow DNS based multitenancy steps in this link:

And try to keep the site name same as the url
Example url domain: erp.palash.com
Then Site name: erp.palash.com

Point Domain: erp.palash.com A record to the Multitenant erpnext Server IP address.

Hope this helps.

Hi,

Thanks for the reply. I have achieved DNS based multitenancy. No problems with that. Works absolutely fine. But my question is slightly different.

I want to redirect more than one URLs lets say erp.palash.com and erp1.palash.com to the same site (erp.palash.com) in my multitenant ERPNext setup. Is my question clear ?

I think that can be done with Site_config file.
Add this host to the File.

I m not sure. I will check it and update you later.

EDIT:
Yes i think it can be achieved by nginx setting thought but same can be done under site_config.json
Reference to nginx setting:

Cool. will try and update. Thanks :slight_smile:

@palashjhabak, were you able to achieve this? If so, how did u do?

Create your different domains/sub domains, point them to your server ip (where site is located)
The add them to the site as below:

bench config dns_multitenant on

bench setup add-domain subdomain.com
sudo -H bench setup lets-encrypt site1.local --custom-domain subdomain.com

bench setup add-domain subdomain1.com
sudo -H bench setup lets-encrypt site1.local --custom-domain subdomain1.com

Your site_config.json should look like below after:
image

Discovered by accident.

4 Likes

LOL that’s the best kind of learning :wink:

It didnt work for me.

When i ran bench setup add-domain subdomain.com it prompted for the site name, i gave it
Is there a need for the second command?
Also i am not using SSL. so what would be the command?

Yes, the second command is necessary(it sets up ssl for your site: Using Let's Encrypt to setup HTTPS)

Follow the prompts that follow, after the second command.

If you follow the steps it should work

Thanks for your help. It worked. Its documented here Adding Custom Domains to your Site

Well, the second command is actually 2 commands one to update the nginx configuration and the next would be to restart nginx. But more importantly, the first command needs to have more detail.

If you did a generic Easy Install and did not make the effort to rename the bench or create a specifically named site, then your default site name is “site1.local”

On a fresh system with no URL’s assigned yet the process would look like this:

bench config dns_multitenant on
bench setup add-domain --site site1.local example.com
bench setup add-domain --site site1.local erp1.example.com
bench setup add-domain --site site1.local erp2.example.com
bench setup add-domain --site site1.local erp3.example.com
bench setup nginx
sudo service nginx restart

In the example above, you have a single default generic site called site1.local and you have pointed the main URL (example.com) and all three of the sub-domains (erp1, erp2, and erp3) to the exact same site (site1.local).

This is the simplified version. You still have to handle the DNS pointers at your provider. If you want to add the Lets Encrypt certificates, I would do that after you test all of your URL access.

Hope this helps.

BKM

@bkm do you use offline or online for your pos ?

Have you ever used the loyalty module in pos ?

@olamide_shodunke

I only use the ONLINE settings for POS because I always had trouble with the offilne not syncing correctly and then if the cashier is smart, the buffers can be cleared and you lose the transactions.

Never trusted offline.

The loyalty module didn;t really get underway until v11 and v12. None of my v11 and v12 clients have been interested in a loyalty program yet.

BKM

@bkm while using pos(online) experience this(Users can edit prices on the POS even if Allow user to edit Rate is not ticked - v12.5.2 (version-12) ¡ Issue #20889 ¡ frappe/erpnext ¡ GitHub)?

I.e. Users being able to change prices, even if they’re restricted on the pos profile? If so, did you solve it?

I have not encountered this problem. My v12.5 installs are with small businesses with 5 or 6 users and all of them needed the ability to edit anything. I would not have had an interest in this function as of yet. In each case they are all “System” level users and regular users.

BKM

I see.

Hey @bkm I would like to achieve the same but not on a fresh system. I initially had a single domain for my ERPNext Instance, but now I want to add another, and on using your previously given steps doesn’t seem to work.

I am unable to generate an SSL Certificate for the new URL using Certbot, and also cannot access ERP on the new domain.

Here is the error I get but my A record correctly points to the correct IP address for the server.

image

The reason I want to have an extra domain is to use it as a Route for a Web Page.

Any assistance will be greatly appreciated.

Regards,
Peter.

Did you set the new domain url in server_name in the nginx site config file?? if you did then certbot should be able to get a certificate for you.

Remember…

You must already have dns multitenant turned on, then the ‘bench add-domain’ will work.

Beyond that you also have to run ‘bench setup nginx’ and then you must restart nginx. If you already have your dns pointers setup through your URL registrar, then all should work.

BKM