Images not available after restore - nginx issue?

Hi,

we set up a fresh install and restored a site database. We restored also the files also following these instructions:

The problem is that the images of the products are not shown although they are copied in /public/files/. When we change the user in /etc/nginx/nginx.conf from ‘nginx’ to ‘erpnext’ the images are shown correctly, but the desk is unresponsive.

Can you check the nginx error logs?

I suspect it would be a permission issue.

In the nginx logs we get failed (13: Permission denied)

It seems to be clearly a permission error that is solved only if we change the user in /etc/nginx/nginx.conf from ‘nginx’ to ‘erpnext’.

We get in console:

Failed to load resource: the server responded with a status of 404 (NOT FOUND)

We tried chmod o+rx /home/erpnext but is not helping

After you change permissions, you’ll have to restart nginx. Also check SELinux audit logs if it’s blocking access.

We checked Selinux and it is not the problem. We restarted nginx after the changes. As said, the only way we can see the pictures is by changing the nginx user to the user to ‘erpnext’ in /etc/nginx/nginx.conf

That confirms it’s a permission issue. You’ll have to see at which level (in the filesystem hierarchy ) is it not allowed.

Both users are listed like this:

erpnext:x:1000:1000:ERPNext:/home/erpnext:/bin/bash
nginx:x:997:996:Nginx web server:/var/lib/nginx:/sbin/nologin

After reading the stackoverfllow article we thought that a solution would be to add the user nginx to the erpnext group:

gpasswd -a nginx erpnext
nginx -s reload

But it is also not working, when we do this is worse, we lose all the css.

This is very strange as also happens from the server itself, here i attach the log we receive:

2014/12/13 11:48:49 [crit] 19867#0: *11190 stat() "/home/erpnext/frappe-bench/sites/erp/public//products" failed (13: Permission denied), client: 127.0.0.1, server: frappe_default_site, request: "GET /products HTTP/1.0", host: "127.0.0.1", referrer: "http://127.0.0.1/"

This happens also with the backup files, they are not found in the browser. Somehow the nginx user created by the script does not have permissions to access the files.

I really think that SELinux is blocking this because a policy is required to be enabled for a webserver (apache/nginx) to read the home_dir. Can you please put it in permissive or off mode and try again?

to be more sure about selinux, we put it in off mode and restarted. the problem is the same. We are in CentOS 7.

Get into the shell as nginx and try to ls / cat the file,
sudo -u nginx bash

We entered in the shell as nginx. Until ls /home/erpnext/frappe-bench/sites is OK:

drwxr-xr-x. 5 erpnext erpnext 4096 13. Dez 11:02 sites

but:
ls /home/erpnext/frappe-bench/sites/erp
throws a permission error:

drwx------  5 erpnext erpnext    68 27. Nov 21:53 erp

OK, we found the solution we did chmod o+rx /home/erpnext but not:

chmod o+rx /home/erpnext/frappe-bench/sites/erp/public/files

Doing the last is solved. Thank you for the patience with this thread.

1 Like

Great!
Glad it worked!
Patience was mostly on your part :wink: