How to Solve 13: Permission denied browse for file in nginx centos

After long hour install and setting up my new Centos 7 VPS server and succefully load .php file through web broswer, god damm ! tailing error log there are failed (13: Permission denied) when  browse for folder and image file. ugh! i almost crazy for a long day...

open files failed (13: Permission denied)
open files failed (13: Permission denied)


what happern! what wrong?

I have cheked again my ngin.conf file, fastcgi.conf and proxy.conf file and try to sparate the nginx backend and frontend  optimization code but no luck! the 13: permission denied still appear. Through my confuse time i dig a lot to google search and try so many method and luckily i found one of them is most comply and the best resolution for my vps centos 7 nginx backed end server.

Here is the solution for resolve failed (13: Permission denied) when you test open file from your server in browser.

First at all, you must login as root user to follow this method.
Chek if  httpd_enable_homedirs is on


#getsebool -a | grep httpd
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_graceful_shutdown --> on
httpd_manage_ipa --> off



look like our home_dir is disabled in context, lets activate them, type and enter :

#setsebool -P httpd_enable_homedirs 1

verify again is home_dir was enable (on)
#getsebool -a | grep httpd
httpd_enable_homedirs --> on

by this line test your browser to open any directory and file and see, are error 13: denied permission still appear? if not skipp this method and enjoy your day.

While you still facing 503 error, letst settel all of this thing. The error is come from "SELinux issue " for solving 13: denied error just disable it and finish, our error disapear ...

Type this command  then enter:
#setenforce 0

Reload nginx and daemon tool
#systemctl restart nginx
#systemctl daemon-reload

Verify with curl -I command

[root@amazon helenaberkovah]# curl -I http://theserver.com/asset/1.JPG
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 13 Dec 2017 08:04:55 GMT
Content-Type: image/jpeg
Content-Length: 25325
Last-Modified: Tue, 12 Dec 2017 08:21:15 GMT
Connection: keep-alive
ETag: "5a2f917b-62ed"
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
expires: max
Accept-Ranges: bytes

test again in browser

solving failed (13: Permission denied) success
solving failed (13: Permission denied) success

Conclussion


Everyone do not want facing any problem actually in big live server which is placed at VPS system because the cost still running and the server is down #arrggghh it's  so bad. When someday you find out again the solution for open files failed (13: Permission denied) before take any action, take your time to look is in the logs to find out what is being denied to make sure what going on and you will know what action to do next.

If you have the 'audit' package installed and the auditd daemon running then it logs to /var/log/audit/audit.log. The contents of that file can be analyzed by running `aureport -a` and more detailed information about interesting looking lines can be gathered by running `ausearch -a NN` where NN is the number at the end of the aureport line in question.

0 Response to "How to Solve 13: Permission denied browse for file in nginx centos"

Post a Comment