Configuration for Nginx that on another server

I have a Nginx server that seats in front of ERPNext server on my private network.
I want a request from internet to my Nginx server will be passed to ERPNext server.
I ran bench setup nginx and but it seems the generated configurations are only use for a Nginx server that install on the same server with ERPNext.
An example:

location /502.html {
root /home/vgs/bench/bench/config/templates;
internal;
}

I don’t want install another Nginx server on my ERPNext server.
How can I have production Nginx configuration for a Nginx server that seats in front of ERPNext server and proxy to that ERPNext server?
Thank you.

Hi @lapphan,

if I understand you correctly, you want the first nginx (not the one on the ERPNext server) to act like a reverse proxy.

If you want to achieve this with an apache2 server, you need a2enmod proxy (and depending on the configuration related modules). Then, in the virtual host config, you will need something like

<Proxy *>
           Order deny,allow
           Allow from all
    </Proxy>

    ProxyPass / https://[erpnext_ip]/
    ProxyPassReverse / https://[erpnext_ip]/
    ProxyPreserveHost On
    ProxyAddHeaders Off

The same can be achieved with nginx, refer e.g. to NGINX Reverse Proxy | NGINX Plus

Hope this helps.

Thank you @lasalesi.
You understand me. I want my Nginx server acts as a reverse proxy.
But I don’t want to have another Nginx server on my ERPNext server and can use the generated configuration from command bench setup nginx. I know how to config proxy_pass.
How can I achieve that with only my first Nginx server?

Hi @lapphan,
that part I did not understand.

  • on your ERPNext server: the standard nginx (configured by bench). Provides ERPNext on a local address
  • on your separate nginx gateway server: configure the reverse proxy (configuration has to be done manually, this function does not exist in bench)

So you have two nginx servers, on on each server…

Can you share a working nginx reverse proxy on the fron nginx server. I did like this, I can access the server but lost static files (css and img)

Sorry, we only have running apache2 reverse proxies (see snippet above), but nginx should be roughly similar, I guess

location / {
    proxy_pass https://[erpnext_ip];
}

What have you got?

server {
	listen		443 ssl http2;
	server_name	example.domain;
	location / {
		proxy_pass			http://<erpnext-ip>;
		proxy_set_header	Host				$host;
		proxy_set_header	X-Forwarded-For		$proxy_add_x_forwarded_for;
		proxy_set_header	X-Forwarded-Proto	$scheme;
		proxy_http_version	1.1;
		proxy_set_header	Upgrade $http_upgrade;
		proxy_set_header	Connection "upgrade";
		proxy_set_header	X-Frappe-Site-Name example.domain;
		proxy_set_header	Origin $scheme://$http_host;
		proxy_set_header	Host $host;
	}
}
1 Like

with this one, I can access the site but the css and images cannot be accessed

1 Like

@Tech_Hack_IT How do we configure nginx already in use in hosted Erpnext to enable Metabase to be hosted in the same server.The Nginx for metabase is in proxy. Once I follow the instruction on the configuration of the proxy nginx, Erpnext will no longer open. Help out on how to ensure the nginx serves both the Erpnext and Metabase with ssl in a hosted environment.Thanks

@Fred1 Please Check the following cmd.
For checking your nginx port active list.

sudo lsof -i -P -n | grep LISTEN

To integrate your metabase inside the erpnext. So you can access the metabase inside the erp dashboard

Refer the link:

We have followed the above .It does not work.We actually installed the metabase and we can see the metabase dashboard on the Erpnext board.But we cannot access the metabase.

@Fred1
You want access the metabase or only view the metabase?

After the installation.The metabase came up when we accessed with the url:3000 for the first time for us to supply the needed database name and password,etc but never accessible with the url:3000 after that. Although the metabase dashboard is still shown in the Erpnext dashboard but there is no communication with the metabase.We followed the instruction strictly as provided in the link.However what we concluded is that the write up is for local installation of metabase in erpnext deployed locally and not one deployed on the vps.However we may be wrong but need a bit guidance from you.Thanks

@Fred1

  1. Install the metabase.

  2. You create the dashboard in metabase then click the sharing and embedding option you see the code there (Default its shows in javascript file you can change into Python code).

  3. Then create the custom app in the name of metabase.

  4. You can copy the entire python code from sharing and embedding option.Then paste the entire code in the custom app py file.

  5. Then you can see the metabase data inside the erpnext by using metabase dashboard menu.

In mycase like this:

If it is not clear to understand please refer my youtube channel. I will upload a video soon about metabase.

Keep in touch…

Thanks.I will wait for your video.Deeply appreciate.

@Fred1

ref,How to Configure Nginx Server in ERPNext & Metabase Same IP || Multiple Server || Reverse Proxy - YouTube