I’m using CloudPanel. How can I fix it?

Nemesis

Active member
Joined
Mar 22, 2025
Messages
35
Points
61
Age
26
I’m getting a 403 Forbidden error on my Nginx server. I’m using CloudPanel. How can I fix it?
 
Solution
Hi there! A 403 Forbidden error on an Nginx server in CloudPanel usually means the server is denying access due to one of the following reasons:

🔹 1. No index file in the directory
By default, Nginx looks for files like index.html or index.php. If none are found, it doesn’t know what to show and returns a 403 error.
Solution:
Create a simple index.html file like this:

Code:
<!DOCTYPE html>
<html>
<head><title>Welcome</title></head>
<body><h1>Hello World!</h1></body>
</html>

Place it inside the directory you're trying to access.

🔹 2. autoindex is turned off
If there’s no index file and you want to list all files in the directory, you need to enable the autoindex setting.
How to do it:

Open the config file...
Hi there! A 403 Forbidden error on an Nginx server in CloudPanel usually means the server is denying access due to one of the following reasons:

🔹 1. No index file in the directory
By default, Nginx looks for files like index.html or index.php. If none are found, it doesn’t know what to show and returns a 403 error.
Solution:
Create a simple index.html file like this:

Code:
<!DOCTYPE html>
<html>
<head><title>Welcome</title></head>
<body><h1>Hello World!</h1></body>
</html>

Place it inside the directory you're trying to access.

🔹 2. autoindex is turned off
If there’s no index file and you want to list all files in the directory, you need to enable the autoindex setting.
How to do it:

Open the config file:

Code:
sudo nano /etc/nginx/sites-available/default

Inside the location / block, add:

Code:
nginx
KopyalaDüzenle
location / {
    autoindex on;
}

Then restart Nginx:

Code:
sudo systemctl restart nginx

⚠️ Warning: Enabling autoindex may expose directory contents to the public. Only use it when absolutely necessary.

🔹 3. Incorrect file or directory permissions
Nginx might not have permission to access the folder.
Solution:

Code:
sudo chown -R www-data:www-data /var/www/html/target_folder
sudo chmod -R 755 /var/www/html/target_folder

This ensures the Nginx process can read the files and directories.

✅ Extra Tips:
  • Disable autoindex after use.
  • Set index index.html index.php; in your config.
  • Avoid giving full permissions like 777 – it’s a security risk.
With these steps, you should be able to fix the “403 Forbidden” error on Nginx when using CloudPanel. Hope it helps! 😊
 
Last edited:
Solution
Back
Top