Out of the box I am getting a 403 Forbidden error on a new virtual host.
I am using as simple of a server block as possible
server {
listen 80;
listen [::]:80;
server_name carttest.tabletopstock.com;
root /var/www/carttest1/public;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
The permissions for /var/www/carttest1/public are:
drwxrwxr-x 4 tyson www-data 4096 Jan 30 23:22 public
Same with the permissions of the files within it.
drwxrwxr-x 4 tyson www-data 4096 Jan 30 23:22 .
drwxrwxr-x 14 tyson www-data 4096 Jan 30 23:44 ..
-rw-rw-r-- 1 tyson www-data 593 Jan 30 23:22 .htaccess
drwxrwxr-x 2 tyson www-data 4096 Jan 30 23:22 css
-rw-rw-r-- 1 tyson www-data 0 Jan 30 23:22 favicon.ico
-rw-rw-r-- 1 tyson www-data 1823 Jan 30 23:22 index.php
drwxrwxr-x 2 tyson www-data 4096 Jan 30 23:22 js
-rw-rw-r-- 1 tyson www-data 71 Jan 30 23:22 mix-manifest.json
-rw-rw-r-- 1 tyson www-data 24 Jan 30 23:22 robots.txt
-rw-rw-r-- 1 tyson www-data 1194 Jan 30 23:22 web.config
I have tried setting the owner to www-data as well to no effect.
And in sudo tail -f /var/log/nginx/error.log
I constantly get
*1 directory index of "/var/www/carttest1/public/" is forbidden, client: 131.252.165.128, server: carttest.tabletopstock.com, request: "GET / HTTP/1.1", host: "carttest.tabletopstock.com"
Am I missing a flag somewhere?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
The problem is that in your Virtual Host you have set only
index.html
as anindex
but in your public folder, you only haveindex.php
so Apache is failing to find a directory index.To fix that either add
index.php
to yourindex
list like this:Or change the
index.html
toindex.php
:After that run a config test:
And if you get
Syntax OK
, then restart Apache and it should work as expected:Regards, Bobby