Just want to help somebody out. yes ,you just want to serve static file using nginx, and you got everything right in nginx.conf:
location /s
Try the accepted answer by @gitaarik, and if it still gives 403 Forbidden
or 404 Not Found
and your location target is /
read on.
I also experienced this issue, but none of the permission changes mentioned above solved my problem. It was solved by adding the root
directive because I was defining the root location (/
) and accidentally used the alias
directive when I should have used the root
directive.
The configuration is accepted, but gives 403 Forbidden
, or 404 Not Found
if auto-indexing is enabled for /
:
location / {
alias /my/path/;
index index.html;
}
Correct definition:
location / {
root /my/path/;
index index.html;
}
I bang my head on this 403 problem for quite some time. I'm using CentOS from DigitalOcean.
I thought to fix the problem was just to set SELINUX=disabled in /etc/selinux/config but I was wrong. Somehow, I screwed my droplet.
This works for me! sudo chown nginx:nginx /var/www/mydir