The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Trying to Stop Global Directory Listing

Discussion in 'General Discussion' started by AtariAge, Nov 5, 2007.

  1. AtariAge

    AtariAge Registered

    Joined:
    Mar 14, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I'm setting up a new server that has WHM/cPanel installed. I am trying to prevent directory listing at a global level, as I don't want to add .htaccess files to every new account if I can avoid it. I've already read several threads here and have changed "Indexes" to "-Indexes" in both the access.conf and httpd.conf files. My access.conf is as follows:

    Code:
    <Directory />
    
    Options -Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    
    order allow,deny
    allow from all
    
    </Directory>
    The relevant tags in my httpd.conf are as follows:

    Code:
    <Directory "/">
        Options -Indexes All
        AllowOverride All
    </Directory>
    
    <Directory "/usr/local/apache/htdocs">
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    
    </Directory>
    The word "Indexes" does not appear anywhere else (that is, it is not overridden for any of the VirtualHosts). There are no .htaccess files overriding the Indexes behavior at the root level for the accounts I am testing. I have been restarting Apache anytime I make configuration changes.

    Can someone shed some insight on what might be causing directory listing to STILL occur even after I've made the above changes? Why this is not a setting in WHM boggles the mind (and yes, I know you can add a .htaccess to the skeleton, but I still think you should be able to disable this globally from within WHM without having to resort to editing configuration files yourself).

    Thanks!

    ..Al
     
  2. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    I couldn't find a trivial solution to this myself when I was searching a few months back, and yes, it really should be an option in WHM ... keep us posted if you get it working.
     
  3. AtariAge

    AtariAge Registered

    Joined:
    Mar 14, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Nothing yet, and I've fumbled around in access.conf and httpd.conf enough for today. Makes no sense to me. For now I have stuck .htaccess files in each of the sites, but I'd still like to get this working globally.

    ..Al
     
  4. fairlylarge

    fairlylarge Member

    Joined:
    Feb 19, 2005
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    I stuck my .htaccess in /home and this took effect on all sites?

    Might be something to try.
     
  5. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    I've finally found the fix :

    Code:
    replace "Options All" "Options -Indexes" -- /usr/local/apache/conf/httpd.conf
    /usr/local/cpanel/bin/apache_conf_distiller --update --main
    service httpd restart
    
    Enjoy :)
     
  6. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    Better solution that won't be lost when recompiling Apache :

    Code:
    mkdir /usr/local/apache/conf/userdata/
    touch /usr/local/apache/conf/userdata/noindex.conf
    
    Then edit /usr/local/apache/conf/userdata/noindex.conf and paste the following :
    Code:
    <Directory "/">
        Options -Indexes
        AllowOverride All
    </Directory>
    Then run :
    Code:
    /usr/local/cpanel/bin/build_apache_conf
    service httpd restart
    And you're done :)
     
  7. AtariAge

    AtariAge Registered

    Joined:
    Mar 14, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Yapluka--thanks for your fixes, I'll try the latter one today and see if it works for me. :) I appreciate your digging around for this..

    ..Al
     
  8. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    And even easier ;)

    Code:
    mkdir /usr/local/apache/conf/userdata/
    echo -e '<Directory "/">\nOptions -Indexes\nAllowOverride All\n</Directory>' > /usr/local/apache/conf/userdata/noindex.conf
    /usr/local/cpanel/bin/build_apache_conf
    service httpd restart
    
     
  9. SonicE

    SonicE Member

    Joined:
    Dec 6, 2007
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    ok this fix is great but when i create a new account it doesn't work for the new acc. All existing accounts are fine, only the new one has the to be modified. Is there any solution to get this automated done when setting up a new account. Sorry for my bad english.

    Cheers
     
  10. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    Good catch !

    Do this :
    Code:
    echo -e '/usr/local/cpanel/bin/build_apache_conf\n/etc/rc.d/init.d/httpd restart' >> /scripts/postwwwacctuser
    chmod 700 /scripts/postwwwacctuser
    Then it'll work for the new accounts :)
     
  11. SonicE

    SonicE Member

    Joined:
    Dec 6, 2007
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Dude you just rock! But other question: Will this work when we upgrade WHM/Cpanel in the future.

    Thanks
     
  12. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    Unless cPanel changes the new Apache design, it shouldn't be affected by any update :)
     
  13. SonicE

    SonicE Member

    Joined:
    Dec 6, 2007
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Great!

    Thank You for your time!
     
Loading...

Share This Page