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/1.12.2

nginx 403 forbidden

How to fix this problem ?

Step 1: check if SELinux is running

getenforce

Result for VPS Digital Ocean

[root@tutorialspots ~]# getenforce
Enforcing

Result for VPS Vultr

[root@tutorialspots ~]# getenforce
Disabled

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.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are pro
tected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Use vi or nano to edit that file.

Recent search terms:

  • 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=1827 IZ2u10Gcp_b9SijLR1uR5bYjJmQuOUWQoJp9736P7DpyXywV3XHJGpWXX_4w8OCj a6a29bc65030d271f276fb41009e6f258a9b7b48&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1826 llpJYG5Brh-GtmSH8f7y0lonR3-lT2EkXbohGK0F-sVdkt2OkCc1Jewzgc6CU5-Y d9e642036f8eee7b956149851cabc29fa5549d5d&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1825 aMvaTvVHGqh0N14nT8_OV5h3slraLuObYk5XNKmTbCMcJi8NskmFOJkgglNvHWU7 76c8a25ae7d33a8e9af961bdfbad9ccdf438e855&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1824 5jTqbqL_nY2yL158UfZ3gmeTaCuYKD9AglGtzHoIJAPQOSjRBlJVQTGEyq9U_7rQ 975d18c4a424b87f112d9af6c861f24b19a2d6c7&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1824 2jBhHlJWpwePBWgx6m7fCtv_2HSwR8jf3Gu9f673-56T6CjJtWoKMunvJTNlPhQx fe4835f5f470365dcbe15cd0893a8ba82b796545&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1823 zxS3VduCAZTu9rMFMkT_ESqWytdbU2hq3yn5gGFELdHyN0V2ypeSpojUkAsKKa6W a7fdf23e6b42fec13833495af15c205cc19cc0c3&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1823 IjPZjTnnQtKYaqhe6hEgrfpZQnQrelfLuIOC1Bdyd8psN6WN9NoRRrUpGgmSd3Ml 3a238596f06c7de9bef63c040f52ad3c39d0c7e6&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1821 h7xMzWxU2W78YSHAE-UyHemznTCrjYoqHMekYYpDu6AUyYKNgzqx0hBaNW45EqVI 0b403758d49f9c670592109adb3e2636556b9ab7&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1821 CXOYJ5GtMDEgdLNrvjl3_JJwRycAR2BPnny9owhB6Udn78qK4Gn6TQRNgolBjkDD fe8f7be2d9d4df0d247985d04d78e50ad76a83e3&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme

Leave a Reply