Hello. I have a problem. I created WSL distro with NixOS inside. Now i trying to host project, but get 403 Forbidden error even when using 127.0.0.1.
What i did:
Apache had a problem with “DocumentRoot doesnt exist”. I found solution
It helped, warning disappeared.
2) I looked up in httpd.conf file created and i found, that is create with AllowOverride None
So i replaced it with the full virtual host description in extraConfig option
Listen 127.0.0.1:8000 http
<VirtualHost 127.0.0.1:8000>
DocumentRoot "/home/nixos/Documents/Laravel-pet-1/public"
ServerName laravelPet1
<Directory "/home/nixos/Documents/Laravel-pet-1/public">
AllowOverride All
Allow from all
Require all granted
</Directory>
</VirtualHost>
Also there is firewall settings:
enable = true;
allowedTCPPorts = [ 8000 ];
Just in case checked the apache version, just so i using the directives correctly, my version is 2.4.62
Also checked the htaccess file in the “public” directory. Found only rewrite rules.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Changed my config. Now im using nixos user and only one directive, still doesn’t work
I’m not familiar with Apache, but this Require all granted seems sus: it feels like it’s used to authenticate users using a password (e.g with some htpasswd file).
The Require provides a variety of different ways to allow or deny access to resources. In conjunction with the RequireAll , RequireAny , and RequireNone directives, these requirements may be combined in arbitrarily complex ways, to enforce whatever your access policy happens to be.
It also says that Allow is deprecated, it feels like you wanna allow access from everywhere, then you can remove everything you have in the <Directory> block, and have something like DirectoryIndex index.html instead?
The default settings deny everything and the virtual hosts allow what they needed. i tried to remove Allow directives, run into the access denied to log directory, so i changed the config.
FWIW I asked some llm, and assuming the server has the permissions to access the files, if there is no index to serve then you’ll get a 403, directory listing can be enabled with Options +Indexes within the directory block.
Finally got it working. This was the trivial problem, but i remember, that i did not do it previously. So i added DirectoryIndex index.php to specify what file to process and it seems to work now.