Reputation: 7422
For some reason i'm getting permission denied error while reading the file using nginx and in rhel6, here is my output of the log file
tail -f /var/log/nginx/ph-repo.error.log
and the logs says
"/opt/nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm" failed (13: Permission denied), client: 10.20.5.236, server: my-repo, request: "GET /nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm HTTP/1.1", host: "my-repo"
When i check the permission of the file it's 777
[root@my-repo]# ls -l nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm
-rwxrwxrwx. 1 root root 360628 Oct 23 02:59 nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm
The nginx process is also running as root
[root@ph-repo]# ps -elf | grep nginx
1 S root 1527 1 0 80 0 - 11195 rt_sig 09:48 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
5 S root 1528 1527 0 80 0 - 11378 ep_pol 09:48 ? 00:00:00 nginx: worker process
0 S root 3062 2258 0 80 0 - 25827 pipe_w 10:52 pts/1 00:00:00 grep nginx
The ACL
[root@my-repo]# getfacl nginx
# file: nginx
# owner: root
# group: root
user::rwx
group::rwx
other::rwx
[root@my-repo]# getfacl nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm
# file: nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm
# owner: root
# group: root
user::rwx
group::rwx
other::rwx
I'm not sure what's wrong is happening here can some one help me on this please
Upvotes: 2
Views: 2318
Reputation: 582
I had exactly the same situation. Nginx just was listing directories, but no files, (and it is also a yum repository, like your setup).
the "(13: permission denied)" error was because of SELINUX.
Disabling SELINUX and rebooting the Linux, solved the problem.
to disable selinux, edit /etc/selinux/config
inside the file, change option to: SELINUX=disabled
requires rebooting the Linux after changing it.
This will solve this, and any similar, Permission Denied error on nginx.
Upvotes: 0
Reputation: 418
Your problem is mostly the owner of the file,
su
cd /var/www
sudo chown www-data:www-data -R *
this is put the file under the same user as that of nginx/apache, should resolve your issue
Upvotes: 1