Try ERPNext Buy Support Partners Foundation

Question about multitenant setup

hi

this is my first time doing manual install and need some help regarding multitenancy
im following the hitchhikers guide uptill this step

after that i went to my browser and typed in my usual ip address plus port combo like 192.168.254.157:8000 but was only greeted with an error. page cannot load

error%20multitennacy

can anyone tell me what i amx doing wrong?

before i did the multitenancy step i was able to access my site fine

My erpnext is in a ubuntu server while im using another pc to connect to the ubuntu server

There are two types of multi-tenancy:

  1. port multitenancy
  2. dns multitenancy

In your case, you switched on dns multi-tenancy, thus you need to setup a web server (e.g. Nginx) to do the routing to the correct site based on the domain you typed in /etc/hosts.
In your case you’ll need to type foo.bar, not the IP address.

When using port multi-tenancy, then you can use the ip address with the port number to route to your site.

Please check the docs again:
https://frappeframework.com/docs/user/en/bench/guides/setup-multitenancy

Basically the question is how the system can route your request to the correct files, using port numbers or domain names (DNS server or hosts-file).

Using nginx for DNS multi-tenancy with bench is pretty straight forward, just follow the instructions and you’ll good to go, including let’s encrypt certificates if needed.

@Paul_Frydlewicz

i already have nginx active and also supervisor active but whenever i try to access using the name demo.erp(i didnt really use foo.bar as stated in the tutorial and used my own) it always goes to my search engine like google. I am accessing the erpnext on a different pc though.

here is the error when i try to access it using ip

update 1: i was able to make it work when i use port multitenancy so i think dns multitenancy is the only thing i cant make work. is there a step i should have done to make dns multitenancy work?

Did you call “bench setup nginx” with your site?

Also, did you make a link in the /etc/nginx/config folder to your bench config file?
Something like: ln -s /etc/nginx/bench.conf /home/myuser/mybench/config/nginx.conf
Exchance paths accordingly.

Nginx needs to load the config files for the bench sites. Thus we need to let nginx know which one to load.

yes i did those. does dns multi tenancy really work this really work on a separate local device?

i am using my own ubuntu server located at my home. its not in some cloud instance

If it is not local, you have to use full domain name to access. And set your dns to point to the ip address.
If the domain is not the same as the site name, you have to run bench setup add-domain

by local do you mean the same pc used to run the erpnext? if so then yes i access it using ssh and browser using my windows desktop.

the domain name is the same as site name.

if you setup nginx and supervisor then most likely you are on production which is not on localhost.
If on localhost you have to add your domain to the local host list.

Check nginx.conf if it has your domain name in it. If not you have to run bench setup nginx again, and bench setup reload-nginx.

Access the site from browser with domain name without the port.

Actually I curious if you use the name demo.erp because I think it is not a valid TLD.

what would be a valid TLD

The .com .net. etc

hmm using .com .net etc means i need my ubuntu server to be hosted at the cloud and also buy working dns name from online right? if so is it possible to do it just on the local machines using dns? by local machine i mean i have my server physically at home and i just connect to it locally using a router
so i have 2 pc at home one is headless running ubuntu server with erpnext the the other one is windows which is my daily driver and the one i used to ssh into my ubuntu server

I don’t think you can use dns multi tenant on local.

so you have 2 computer in your local net, right?
Let’s say

  1. your laptop 192.168.0.1
  2. your server 192.168.0.2

on computer 2 your bench is installed in multi tenancy.

on computer 1 you set your hosts file to point your domain to 192.168.0.2

You can check if your host file is correct by calling ping on comp1:

ping demo.erp
the result should show the correct ip of comp2 (192.168.0.2)

If not, something’s wrong with your hosts config.

Now try to enter demo.erp in your browser.

remark: the hosts file is something like a simple domain to IP resolving function for your computer without the need of a DNS server.

2 Likes

you can apply the above method also on a single machine.
In the hosts file you define 127.0.0.1 for demo.erp or whatever domain you want to map.
You can use the ping command for checking as well.

if i understand it correctly i will edit the host file on my windows pc so it will point to the ip address of my ubuntu server?

ill use your example
so on my laptop i will go to the host file(fig 1) below then add a line (see fig 2) that contains the ip address. after that its gonna be all ok?

fig 1: C:\Windows\System32\drivers\etc\hosts

fig 2: 192.168.0.2 demo.erp

Correct.
This way you can type demo.erp into you browser’s address line and your browser is going to connecto to comp2.

But maybe better you test locally on comp2 first. You can just add to your host file on comp2:

127.0.0.1 demo.erp