nginx 403 Forbidden on CentOS (Vagrant)
6,986
Had the same issue with CentOS 7. Resolved by:
Check getenforce
This should show 'Enforcing'
Then I ran chcon
to change the httpd security context to allow access.
chcon -Rt httpd_sys_content_t /path/to/web/content
Reload Nginx
systemctl restart nginx
Now my pages load.
Related videos on Youtube
Author by
user1502178
Updated on September 18, 2022Comments
-
user1502178 over 1 year
What I have checked so far:
Logs - they are empty, booted a new VM.
Permissions:
$ namei -l /var/www/awesome/ f: /var/www/awesome/ dr-xr-xr-x root root / drwxr-xr-x root root var drwxrwxr-x www-data www-data www drwxrwxr-x www-data www-data awesome
Given 777 to the host OS folder that has the vagrant file.
Enabled SELinux.
Still, even inside the vm with curl localhost I get a 403.
Here is the nginx configuration for awesome.dev
server { listen *:80; server_name awesome.dev www.awesome.dev; index index.html index.htm index.php; access_log /var/log/nginx/awesome.dev.access.log; error_log /var/log/nginx/awesome.dev.error.log; location / { root /var/www/awesome; try_files $uri $uri/ index.php /index.php$is_args$args; } location ~ \.php$ { root /var/www/awesome; index index.html index.htm index.php; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param APP_ENV dev; fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; } sendfile off; }
How to fix this?
-
aairey over 9 yearsIs SELinux set to enforcing?
-
user1502178 over 9 years@aairey SELinux is disabled. (sestatus)
-
user1502178 over 9 yearsEnabled SELinux, still getting 403.
-
Michael Hampton over 9 yearsCheck your error log.
-
user1502178 over 9 years@MichaelHampton nginx error and access logs are empty.
-
user1502178 over 9 years@XavierLucas added the conf, how to reduce the log level? Do you mean add debug, e.g error_log /path/to/log debug; ?
-