How to fix Nginx error 403 Forbidden

If you get error 403 Forbidden for all exist files on your server when you use Nginx. Eg: you use VPS of Digital Ocean.

403 Forbidden


nginx 403 forbidden

How to fix this problem ?

Step 1: check if SELinux is running


Result for VPS Digital Ocean

[root@tutorialspots ~]# getenforce

Result for VPS Vultr

[root@tutorialspots ~]# getenforce

Step 2: disable SELinux until next reboot

setenforce Permissive

Step 3: (optinal) restart nginx, done!

But after next reboot, you must do step 2 and 3 again. So, you should do step 4:

Step 4: edit file /etc/sysconfig/selinux

[root@tutorialspots ~]# cat /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are pro
#     mls - Multi Level Security protection.

Use vi or nano to edit that file.

Leave a Reply