Static IP redirection to ERPNext Sites

Hello All,

We have installed ERPNext on our local In-house Server successful with multiple sites. Since we have offices in Pune and Delhi as well, we want to now attach this public IP to the different sites we have created.

I am not sure how to go about with this. Please let me know how can we achieve this with single static IP.

Purchase a domain and link it to your IP. Domain would be accessible via Internet from any location.

you should ask your ISP a static IP, or use a dynamic dns (not a good solution but could work for you)

Thanks both for the reply.

I already have a static IP which I purchased from my ISP. I have also created 3 sites on my in-house Server.

So today if I have to access the sites, I just to a hosts entry in /etc/hosts file in the given blow manner.
Assuming 3 sites namely abc, pqr, xyz.

localhost abc
localhost pqr
localhost xyz

Now to access these sites, I would enter in my browser the following

http://abc
http://pqr
http://xyz

respectively.

Now if I have to access this using the static IP, how do I map to a specific site, since I have used domain for multi-tenant and not port.

assuming my static IP is 42.242.121.78 (this is a dummy, which I am using for example).

Guys,

This is really urgent.

I would appreciate if someone can provide some sort of guidance.

@mishrankit

  1. Firstly you need a domain name which you will need to access the individual sites as sub-domains as follows:
    1.1 http://abc.your-domain.com
    1.2 http://pqr.your-domain.com
    1.3 http://xyz.your-domain.com
  2. Map sub.your-domain.com to your static IP by creating an “A” records to each individual sub-domain in your DNS and this is done at your the Registrar DNS zone records
  3. You need to enable Multi tenant DNS on your server to be able to do what you want. This article/guide should help you set things up

https://frappe.github.io/frappe/user/en/bench/guides/setup-multitenancy.html

1 Like

Thanks @saidsl,

I have already done the multi-tenant based on DNS.

Lets assume I have the sub-domain “http://abc.your-domain.com” and also did the A listing i.e mapping static IP to domain/ sub-domain, how would the sub-domain redirect to the specific ERPNext site “abc” in this case?

You can name your sites as the hostnames that would resolve to it. Thus, all the sites you add to the bench would run on the same port and will be automatically selected based on the hostname.

1 Like

Hi @Pawan,

I am not sure if I have completely understood, based on what I have understood I have created sites based on Host/ Domain names.

Do let me know if you are suggesting something different.

Are you using port based multi-tenancy or domain based multi-tenancy?

If you have not run bench config dns_multitenant on, then you are using port based multitenancy.

Assuming you want to continue with port based multitenancy (I’d recommend dns based multitenancy anyday, though, you have to set the port for the two sites other than the default site. The first site you set up is automatically designated as the default site.

You set the ports for the other site by running the commands:

bench set-nginx-port site2name 82. Run the command again with a different port for the other site.

Then run:

Re generate nginx config
bench setup nginx

Reload nginx
sudo service nginx reload

You should have a static IP and you should know what that static ip is. If you don’t open a internet browser and google whats my ip.

Now the first site you set up will be available on http://123.45.67.89.

The other two sites will be available on http://123.45.67.89:82 and http://123.45.67.89:84.

If it doesn’t just check the configuration on your Firewall (if you have one) or if you have used CentOS or Debian as you base OS, you may need to open up the ports on your server as well.

Trust this helps

Thanks

Jay

3 Likes

@mishrankit

When you create the sites with matching sub-domain names using bench new-site sub.your-doman.com and then do bench setup nginx bench will map the sub-domains in nginx config file

If you haven’t done so you can use bench setup add-domain --site old-site.name sub.your-domain.com then you do bench setup nginx to apply the new site names and domains

Thanks @JayRam,

I am using domain based multi-tenancy.

Do I need to assign port even if I am using domain based multi-tenant?

Thanks @saidsl,

Let me try this option. Thanks once again everyone for the quick response.

Nope. But you need to access your domain account and set up site1.domain.com, site2.domain.com, site3.domain.com.

But first try accessing the default site: http://123.45.67.89

and let me know that’s happening.

If you are able to access this on the internet, then everything is fine. You just need to set up the domains and wait for it to propagate over the Internet.

If you are not able to access the default site: http://123.45.67.89 on the Internet, now get to a computer that’s on the same network as the Server and open up http://192.168.1.10 (the servers local IP address). If that opens up, but does not open up on the internet, you need to check the ports on your internet connection.

If that doesn’t open up either, just check if you have the server local IP address right. If you are sure you have the server address right, try the following:

Next, try opening up http://localhost on the server. If you have a server OS, you can still install Google Chrome - just Google how. If that doesn’t open up either, its the firewall on the OS related issue or maybe your installation didn’t go through too well.

Hope this helps.

Thanks

Jay

@JayRam,

On clicking http://localhost or http:// 192.168.1.10 (server local IP) or http:// 123.45.67.89 all show the same page as show in attachment.

Though If I hit http://abc (my first site), it open the ERPNext screen.

Try sudo service nginx restart and sudo service supervisor restart

wait a few seconds and try loading the site again.

Thanks

Jay

Hi @JayRam,

I tried restarting both the services, but unfortunately it did not work.

Since the server in-house, I tried making a hosts entry in /etc/hosts (on client side, from where I am requesting) and it works but with the site name and just by putting localhost or IP does not work.

@JayRam,

Is there a way to check why local IP is not redirecting to default-site (note, I have multiple side based on DNS).

Apologies. I’m in the middle of something. I can only pick this up in the evening.

@saidsl,

I tried this option but it show me the same “Sorry We will be back soon” page with the Local IP/ Static IP and new Sub domain attached now to the site using the commands you suggested.