help with directory indexing

ca2236

Well-Known Member
Feb 2, 2018
244
25
28
Nebraska
cPanel Access Level
DataCenter Provider
Hi

I'm trying to enable directory indexing for something outside of /home/. It is for the below


<Directory /www/sites/servername.domain.tld/docs/subdir>
Options +Indexes
</Directory>


I added the above to pre-main in apache configuration. But it didn't seem to to work. The goal is to be able to access that directory via the web (like server-status)
currently, I get a 404 with or without that entry. (trying to go https://servername.domain.tld/subdir) to get a listing of that directory. We also want to lock it down to only certain IPs, but I think that would be a separate entry.

I could have the wrong format, location, etc for what I want to do.

if someone could tell me if I can do what I want, or there is a different location (both for pre-main idea and physical disk location) that would be appreciated.
Thanks for your help.
:)
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
11,718
1,862
363
cPanel Access Level
Root Administrator
Hey there! That isn't how the Apache system works, but we may be able to come up with an alternative.

If you wanted to host some content on the server's hostname, which isn't recommended, that would end up in /var/www/html. Can you try placing your files there instead to see if that behaves how you're expecting?

If I was going to do this, I'd create docs.hostdomain.com as a subdomain with its own cPanel account, so you can still use the same domain as the hostname without using the actual hostname itself.
 

ca2236

Well-Known Member
Feb 2, 2018
244
25
28
Nebraska
cPanel Access Level
DataCenter Provider
I could try to create a subdomain with that, I was trying to keep it consistent with non cpanel servers. But I know cpanel is a different beast sometimes. in non cpanel servers, although, they probably have a vhosts entry for that direct past, so I think I will try the both methods for curiosity, but leaning towards the subdomain idea.

Thanks! I will let you know what way works.
 
  • Like
Reactions: cPRex

ca2236

Well-Known Member
Feb 2, 2018
244
25
28
Nebraska
cPanel Access Level
DataCenter Provider
ok, I tried /var/www/html and it works like I want, now to lock it down. so that outside can't access it. If we block access to it with allow directives, are there still security concerns? I was just seeing two other locations for servername.domain.tld/docs in /var/www/ and /www/sites

I wasn't for sure, thanks for your help
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
11,718
1,862
363
cPanel Access Level
Root Administrator
Sure, you can place a .htaccess file in there like any other web directory, and it will work how you expect.

There isn't a security issue with this, we just don't recommend it to avoid confusion down the road as this doesn't get handled under a typical user structure like other web-facing content on a cPanel machine. Just ensure you don't remove the .well-known directory or else the hostname AutoSSL will not be able to renew properly.