How to host erpnext in public domain

i want brows this erpnext from other conputer.

  1. i have global IP and even i have link with sub-domain with global public IP.
  2. i edit the hosts file also ( ip domain name)

when i enter ip of erpnext server i can get nginx server page only, that i know nginx Apache server is working. BUT how i can get erpnext page.

Did you reroute to the correct virtual host name and port?

@trentmu, you mean in nginx/config.d directory?.. there i have done.

upstream erp-frappe {
server 127.0.0.1:8000 fail_timeout=0;
}

upstream erp-socketio-server {
server 127.0.0.1:9000 fail_timeout=0;
}

setup maps

server blocks

server {
listen 443;
server_name
erp-dev.example.com
;

root /home/kinl/erp/sites;




location /assets {
	try_files $uri =404;
}

location ~ ^/protected/(.*) {
	internal;
	try_files /$host/$1 =404;
}

location /socket.io {
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	proxy_set_header X-Frappe-Site-Name $host;
	proxy_set_header Origin $scheme://$http_host;
	proxy_set_header Host $host;

	proxy_pass http://erp-socketio-server;
}

location / {
	try_files /$host/public/$uri @webserver;
}

location @webserver {
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
	proxy_set_header X-Frappe-Site-Name $host;
	proxy_set_header Host $host;
	proxy_set_header X-Use-X-Accel-Redirect True;
	proxy_read_timeout 120;
	proxy_redirect off;

	proxy_pass  http://erp-frappe;
}

# error pages
error_page 502 /502.html;
location /502.html {
	root /home/kin/bench-repo/bench/config/templates;
	internal;
}

# optimizations
sendfile on;
keepalive_timeout 15;
client_max_body_size 50m;
client_body_buffer_size 16K;
client_header_buffer_size 1k;

# enable gzip compresion
# based on https://mattstauffer.co/blog/enabling-gzip-on-nginx-servers-including-laravel-forge
gzip on;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
	application/atom+xml
	application/javascript
	application/json
	application/rss+xml
	application/vnd.ms-fontobject
	application/x-font-ttf
	application/font-woff
	application/x-web-app-manifest+json
	application/xhtml+xml
	application/xml
	font/opentype
	image/svg+xml
	image/x-icon
	text/css
	text/plain
	text/x-component
	;
	# text/html is always compressed by HttpGzipModule

}

On a production setup, you can change the port to your preference like this… (as user frappe)

cd ~/frappe-bench
bench set-nginx-port erp-dev.example.com 8120
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
bench setup nginx
sudo systemctl reload nginx

Then you would go to http://erp-dev.example.com:8120

@trentmu, thanks for your reply. i put port 8080, but its not working. can’t brows from other computer.

Port 8080 is normally the development system, which needs to get a

bench start

@trentmu, even i change to 443. its not working

Have you checked that there is nothing running on the default port 443?
You also need to open the port on your firewall.
I recommend changing to a non-standard port to ensure that there is no clash.

Maybe try setting it to 8443 or something simple to remember

@trentmu and @rmehta, can help me to brows erpnext system from other out side computer. i can ping to my public ip and domain name, but can’t brows the erp system.
my hosts file:
local ip erpdev.example.com

nginx/conf.d/frappe-bench.conf file

upstream erp-frappe {
server 127.0.0.1:8000 fail_timeout=0;
}

upstream erp-socketio-server {
server 127.0.0.1:9000 fail_timeout=0;
}

server {
listen 8443;
server_name
erpdev.example.com
;

root /home/kin/erp/sites;

location /assets {
	try_files $uri =404;
}

location ~ ^/protected/(.*) {
	internal;
	try_files /erpdev.example.com/$1 =404;
}

location /socket.io {
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	proxy_set_header X-Frappe-Site-Name erpdev.example.com;
	proxy_set_header Origin $scheme://$http_host;
	proxy_set_header Host $host;

	proxy_pass http://erp-socketio-server;
}

location / {
	try_files /erpdev.example.com/public/$uri @webserver;
}

location @webserver {
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
	proxy_set_header X-Frappe-Site-Name erpdev.example.com;
	proxy_set_header Host $host;
	proxy_set_header X-Use-X-Accel-Redirect True;
	proxy_read_timeout 120;
	proxy_redirect off;

	proxy_pass  http://erp-frappe;
}

# error pages
error_page 502 /502.html;
location /502.html {
	root /home/kin/bench-repo/bench/config/templates;
	internal;
}

# optimizations
sendfile on;
keepalive_timeout 15;
client_max_body_size 50m;
client_body_buffer_size 16K;
client_header_buffer_size 1k;

# enable gzip compresion
# based on https://mattstauffer.co/blog/enabling-gzip-on-nginx-servers-including-laravel-forge
gzip on;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
	application/atom+xml
	application/javascript
	application/json
	application/rss+xml
	application/vnd.ms-fontobject
	application/x-font-ttf
	application/font-woff
	application/x-web-app-manifest+json
	application/xhtml+xml
	application/xml
	font/opentype
	image/svg+xml
	image/x-icon
	text/css
	text/plain
	text/x-component
	;
	# text/html is always compressed by HttpGzipModule

}

If you have the IP and DNS set for erpdev.example.com, then this should work

cd ~/frappe-bench
bench set-nginx-port erpdev.example.com 8443
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
bench setup nginx
sudo systemctl reload nginx

Then http://erpdev.example.com:8443 should work.

Maybe check that everything is up and running

netstat -tnlp | grep -i listen

@trentmu
when i run (bench set-nginx-port erpdev.example.com 8443) this command, my port is auto configure to 80. i don’t know why. and after that can’t run nginx.

Can you run the command(s) and share the traceback/console screen?

@trentmu, now when i run nginx it give this error:
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.

You’ll need to share/show those log files so that people can assist you

@trentmu, i have solved nginx, but when i brows from browser, it give nginx page. i can ping my erp sub domain and public ip too. but when i brows using domain name, it give nginx page not the erp login page

You are probably specifying the wrong port in the URL. If it shows the default nginx page, it is probably looking at port 80 instead of port 8080, or 8000

@trentmu, thanks for reply…i used port 443. how and where i can put or redirect port.

This would change the port to 8443

1 Like

i can open by using port number (erp.example.com:443). but port is ssl. i can’t open page not using port. i dose not want to use port number after url.

This might do what you want then…

cd ~/frappe-bench
bench set-nginx-port erpdev.example.com 443
bench setup nginx
sudo systemctl reload nginx

Then just browse to https://erpdev.example.com which will automatically send you to port 443. The alternative is to create a rewrite rule which redirects you to the other port number
(eg. you could set it up so that http://erpdev.example.com:8443https://erpdev.example.com:443)