Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
|
fortgeschrittene:apache_zugriffskontrolle [2021/08/16 02:51] ingo_wichmann [Auslagerung in .htaccess] |
fortgeschrittene:apache_zugriffskontrolle [2022/03/31 13:51] (aktuell) |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== Zugriffskontrolle ====== | ====== Zugriffskontrolle ====== | ||
| ===== Apache 2.4 ===== | ===== Apache 2.4 ===== | ||
| - | ==== LogLevel für die Fehlersuche ==== | ||
| - | <file> | ||
| - | LogLevel warn authz_core:debug | ||
| - | </file> | ||
| ==== Auslagerung in .htaccess ==== | ==== Auslagerung in .htaccess ==== | ||
| Mit Hilfe von ''AllowOverride'' können Einstellungen ausgelagert werden: | Mit Hilfe von ''AllowOverride'' können Einstellungen ausgelagert werden: | ||
| Zeile 14: | Zeile 10: | ||
| ''/etc/httpd/conf.d/intern.conf'': (CentOS) | ''/etc/httpd/conf.d/intern.conf'': (CentOS) | ||
| <file> | <file> | ||
| + | LogLevel warn authz_core:debug | ||
| Alias /intern /srv/www/intern | Alias /intern /srv/www/intern | ||
| Zeile 126: | Zeile 123: | ||
| AuthName "Bitte Username und Passwort" | AuthName "Bitte Username und Passwort" | ||
| AuthBasicProvider file | AuthBasicProvider file | ||
| - | AuthUserFile /srv/www/intern/wiki/.htpasswd | + | AuthUserFile /srv/www/.htpasswd |
| Require valid-user | Require valid-user | ||
| </file> | </file> | ||
| Zeile 150: | Zeile 147: | ||
| AuthUserFile /srv/www/.htpasswd | AuthUserFile /srv/www/.htpasswd | ||
| AuthGroupFile /srv/www/.htgroup | AuthGroupFile /srv/www/.htgroup | ||
| - | Require group gf | ||
| - | </file> | ||
| - | |||
| - | ===== Apache 2.2 ===== | ||
| - | ==== Zugriffsteuerung per IP/Hostname ==== | ||
| - | |||
| - | In Apache kann mittels | ||
| - | |||
| - | Fall 1: | ||
| - | <file> | ||
| - | order deny,allow | ||
| - | </file> | ||
| - | |||
| - | Per Directory / Location / File | ||
| - | |||
| - | <file> | ||
| - | <Directory /srv/www/intern> | ||
| - | order deny,allow | ||
| - | deny from All | ||
| - | allow from 10.0.0.0/24 .linuxhotel.de 127.0.0.1 | ||
| - | </Directory> | ||
| - | </file> | ||
| - | |||
| - | Erst werden die deny-Regeln ausgewertet, danach die allow-Regeln, falls keine Regel greift gilt allow | ||
| - | |||
| - | |||
| - | Fall 2: | ||
| - | <file> | ||
| - | order allow,deny | ||
| - | </file> | ||
| - | |||
| - | <file> | ||
| - | <Directory /srv/www/intern> | ||
| - | order allow,deny | ||
| - | allow from 10.0.0.0/24 .linuxhotel.de 127.0.0.1 | ||
| - | </Directory> | ||
| - | </file> | ||
| - | |||
| - | Erst werden die allow-Regeln ausgewertet, danach die deny-Regeln, falls keine Regel greift gilt deny | ||
| - | |||
| - | ==== Eigene Projekte / Configdateien ==== | ||
| - | |||
| - | openSuSE: | ||
| - | |||
| - | Am besten die eigenen Konfigurationen in folgendem Pfad ablegen mit der Endung .conf | ||
| - | |||
| - | ''/etc/apache2/conf.d/wiki.conf'' | ||
| - | |||
| - | ==== Auslagerung in .htaccess ==== | ||
| - | |||
| - | In Kontextdirektiven lassen sich die Konfigurationswerte durch allowoverride auslagern. | ||
| - | |||
| - | z.B.: ''/etc/apache2/conf.d/wiki.conf'' | ||
| - | |||
| - | <file> | ||
| - | <Directory /srv/www/wiki> | ||
| - | |||
| - | Allowoverride All | ||
| - | # Allowoverride Auth | ||
| - | |||
| - | </Directory> | ||
| - | </file> | ||
| - | |||
| - | Die Datei ''/srv/www/wiki/.htaccess'' hat folgenden Inhalt: | ||
| - | |||
| - | <file> | ||
| - | order allow,deny | ||
| - | allow from 192.168. 127. | ||
| - | </file> | ||
| - | |||
| - | ==== Benutzerauthentifizierung ==== | ||
| - | Einfache Benutzeridentifikation mittels Passwortdatei | ||
| - | |||
| - | ==== Anlegen der Passwortdatei ==== | ||
| - | openSuSE (12.3): | ||
| - | htpasswd2 -c .htpasswd heinz | ||
| - | debian (6): | ||
| - | htpasswd -c .htpasswd heinz | ||
| - | |||
| - | Achtung Erweiterung der Datei mittels | ||
| - | |||
| - | openSuSE (12.3): | ||
| - | htpasswd2 .htpasswd elke | ||
| - | debian (6): | ||
| - | htpasswd .htpasswd elke | ||
| - | |||
| - | In der Kontextdirektive oder im ''.htaccess'' folgende Optionen setzen | ||
| - | |||
| - | Beispieldatei ''.htaccess'' | ||
| - | <file> | ||
| - | AuthType Basic | ||
| - | AuthName "Bitte Username und Passwort" | ||
| - | AuthBasicProvider file | ||
| - | AuthUserFile /srv/www/wiki/.htpasswd | ||
| - | Require valid-user | ||
| - | </file> | ||
| - | |||
| - | ==== Nutzung einer Gruppendatei ==== | ||
| - | |||
| - | Aufbau der Gruppendatei ''/srv/www/wiki/.htgroup'' | ||
| - | |||
| - | <file> | ||
| - | gf: peter heinz gerd | ||
| - | sekretariat: elke heinz | ||
| - | </file> | ||
| - | |||
| - | Änderung in der ''.htaccess'' | ||
| - | |||
| - | <file> | ||
| - | AuthType Basic | ||
| - | AuthName "Bitte Username und Passwort" | ||
| - | AuthBasicProvider file | ||
| - | AuthUserFile /srv/www/wiki/.htpasswd | ||
| - | AuthGroupFile /srv/www/wiki/.htgroup | ||
| Require group gf | Require group gf | ||
| </file> | </file> | ||