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.

Recent search terms:

  • 403forbiddin 1 12 2
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1874 rQPtPKCQygndLOGkpIzzhFuQAa08czOG79VIdquLHQNqsm2yhmnG474AhDfxoOBW 897c944c01468e3193ff20452c0c4d865521ef9e&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1882 zQMe_bpagd39eI4pJojZzYVb1DxERSOY8IMPh9uUfWGHpzcD2eY7zTFKGAAwvO91 9f8950bf9ce841ae07179411d20a8b2162ef5370&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme

Leave a Reply