search | index | tags | login/register

Apache webserver config (by damian)

Enable file listing / directory listing directly in /etc/apache2/sites-enabled/XXYYZZ.conf:

<Directory /var/www/domain.com/pdfs>
    Options Indexes FollowSymLinks
</Directory>

Per directory via .htacces file:

# deny directory listing:
Options -Indexes

# allow directory listing:
Options +Indexes

# enabe fancy indexing:
IndexOptions +FancyIndexing

# Add description to listed items:
AddDescription "latest test file" test.txt
AddDescription "another test directory" test

# Enable MultiViews (https://httpd.apache.org/docs/2.4/mod/mod_negotiation.html)
Options +MultiViews

# Redirect all traffic to https
RewriteEngine On

RewriteCond %{HTTPS} !on
# except for ip 1.2.3.4
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Auth (SSL should be on)
AuthUserFile /etc/apache2/htpasswd
AuthName "Restricted Area"
AuthType Basic
Require valid-user

# workaround: do not ask for the password before request redirected to ssl
Allow from env=IS_NON_SSL

 

Tags:
#apache #apache2 #config #directory #file #help #howto #index #linux #list #password #protected #server #webserver

Info:
Attribute(s): Public
Created: 24.03.2013 13:35   Total Views: 338
Last Changed: 28.04.2017 08:59   Total Changes: 4
Δt = 0.10390400886536s