Hi,
I have a DO droplet, set up my app via Serverpilot, running a CraftCMS install. Everything has been fine, but just hit an issue. I’m trying to create a subfolder from my root called ‘directory’ so it would be accessed via domain.com/directory. However I keep getting a 403 error when trying to access this. It works fine on a local environment, but when pushed up I get the
"You don’t have permission to access /directory/ on this server.
Possible causes of this error include:
The request was forbidden by rules in the .htaccess file. The directory you requested does not have an index.html or index.php file. The permissions on the file or directory are incorrect."
message. If i rename this folder to anything else, it works.
Just a bit stumped.
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.
Thanks again. So I’ve found the directory block. it is as follows…
My htaccess file contains just…
which was added to remove the index.php from the urls.
I can’t see anything that’s out of place. The strange thing is that every other directory I create is fine. It’s only when I create one actually called ‘directory’. ?
@shorn
Yes and no, but it let’s me know how they have things setup and confirms that they are indeed using NGINX to proxy requests over to Apache (hence port 81 in the VirtualHost block – that means NGINX is listening on port 80).
That said, nothing looks out of place in that specific configuration, so we may have to dig deeper and take a look at what’s inside of:
The line below is telling Apache to include additional configuration files from the above directory (using * means all files ending in
.conf
).In most cases, there’s a
<Directory /path></Directory>
block that defines overall permissions inside of the<VirtualHost></VirtualHost>
block.As a basic example, here’s what this would potentially look like:
The
/
in the above grants access from/
down – a direct path could be used as well. If something like that doesn’t exist, and NGINX isn’t setup to limit directories, then that would be why you’re unable to access newly created directories.NOTE: Don’t copy and paste the above in to you configuration for testing without changing
/
to a direct path. The above would assume/
, or the root path. If you did want to test this out, you could replace/
with:or
There could also be something similar defined in an
.htaccess
file that limits directory browsing since Apache uses.htaccess
files to handle user-defined configuration.OK, so it looks like I have both nginx and apache folders, but these are called apache-sp and ngix-sp (presumably as they are set up by Serverpilot.) I dont have any ‘sites-available’ folders. I’ve managed to fine conf files in the vhosts.d folder. A file in here contains the following virtualhost block.
That help at all?
Thanks for the response. Ive just gone in and checked. The directory and subsequent index.html file have the exact same permissions as the other directories.?
@shorn
The error stating that you don’t have permission to access
./directory
is where we’ll start. It all boils down to permissions.From the CLI,
cd
to the directory above./directory
and run:Who owns
./directory
? If Apache is, for example, running aswww-data
and./directory
is owned byroot
, then the userwww-data
won’t be able to read, write, or execute. In such a case, you’d need to make sure./directory
is owned by the same user and group as your other files (which, for security, should not beroot
).The
root
user can read, write, or execute anything – other users, however, can not do the same for directories or files owned byroot
.