u/FujoshiPeanut

▲ 2 r/nginx+1 crossposts

Why am I getting a forbidden request error?

I'm fairly new to having a VPS and I'm currently using nginx via Gunicorn to serve my Flask applications. I want to use the server to also serve static audio files, but this is where I'm running into problems.

I added this to my .conf file

location ~ \.mp3$ {

root /var/www/myproject;

types { audio/mpeg mp3; }

add_header Content-Disposition "inline";

}

and restarted nginx and everything worked perfectly fine.

But for some reason now I'm getting the 403 error. I looked online for some fixes. I added nginx to my user group and made sure to check all the permissions using namei -u nginx and it looked all good. I restarted nginx and still getting the error. I'm not really sure what else I can do at this point. Everything else appears to be working fine. Does anyone know what the problem could be?

EDIT: Thank you for all the answers. Turns out it was SELinux the whole time and restorecon solved the issue. Same thing happened to me again today with a whole bunch of files haha

reddit.com
u/FujoshiPeanut — 10 days ago