How to fix the 403 forbidden error: Difference between revisions

Jump to navigation Jump to search
 
Line 68: Line 68:


Root cause: the original syntax was written for another version of HTTP server.
Root cause: the original syntax was written for another version of HTTP server.
=== Server side: lacks an index file (index.html) ===
==== Solution 1: Create Index Page (Recommended) ====
Create an index.html file in {{kbd | key=<nowiki>/path/to/website/</nowiki>}}:
<pre>
cat > /path/to/website/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Website Title</title>
</head>
<body>
    <h1>Welcome</h1>
</body>
</html>
EOF
chmod 644 /path/to/website/index.html
</pre>
==== Solution 2: Enable Directory Listing ====
If the configuration file has been updated with {{kbd | key=<nowiki>autoindex on;</nowiki>}}, execute:
<pre>
# Verify configuration
sudo nginx -t
# Reload Nginx
sudo systemctl reload nginx
</pre>
==== Verification Checklist ====
<pre>
# 1. Verify directory permissions
ls -ld /path/to
ls -ld /path/to/website
# 2. Ensure directories have rx (read+execute) permissions for others
# Expected: drwxr-xr-x or more permissive
# 3. Verify Nginx configuration
sudo nginx -t
# 4. Check Nginx error log
sudo tail -f /var/log/nginx/error.log
</pre>


== More detail on HTTP server log ==
== More detail on HTTP server log ==

Navigation menu