Hallo hyle,
ich vergaß:
Es geht noch nicht
Hallo hyle,
ich vergaß:
Es geht noch nicht
Webseite schützen? Schau mal ob du hier fündig wirst!
Sieht soweit alles OK aus, bis auf:
Das "bis auf" sollte erstmal kein Problem sein. Wird jetzt nach den Zugangsdaten gefragt?
//Edit
Die letzte Frage hat sich somit erledigt.
Wie sieht jetz Deine .htaccess aus? Was sind die Ausgaben von
?
//Edit
llutz Gerade erst gesehen... In #12 fehlt ein Punkt vor htpasswd.
Hallo hyle,
hier die Ausgaben der beiden Kommandos:
pi@blau31:/var/www/html/h6 $ cat /var/www/html/h6/.htaccess
AuthType Basic
AuthName "Erst anmelden!"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
pi@blau31:/var/www/html/h6 $ ls -l /var/www/html/h6/.htaccess
-rw-r--r-- 1 pi pi 96 5. Nov 21:45 /var/www/html/h6/.htaccess
pi@blau31:/var/www/html/h6 $
Danke Thomas
.. In #12 fehlt ein Punkt vor htpasswd
Nein, wieso? Das ist ein Dateiname wie jeder andere auch. Warum sollte man daraus ein leicht zu übersehendes Dot-File machen? Zugriff darauf hast du über den Webserver ohnehin nicht.
Siehe auch z.B. "Get it working" in
https://httpd.apache.org/docs/2.4/howto/auth.html
bzw man-page von htpasswd (dem Tool)
Pfff!
Und wie sehen die Zeilen für Directory /var/www/html/> aus? Hast Du die von oben kopiert oder selber eingetragen?
Warum sollte man daraus ein leicht zu übersehendes Dot-File machen?
Weil es folgende Regel in der /etc/apache2/apache2.conf gibt:
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
Das ist zwar in dem Fall (wenn die .htpasswd in /etc/apache2/ liegt) egal, aber trotzdem sollte man sich m.M.n. an die Konventionen halten.
Hallo hyle,
in #14 steht diese Zeile:
<Directory /var/www/>
Ich habe die Einträge um
<Directory /var/www/html/>
ergänzt.
Keine Änderung
Danke Thomas
Update: war in #13!
Den ganzen Eintrag dazu bitte bis </Directory>!
Btw. Verwendest Du noch Jessie oder älter?
Das ist zwar in dem Fall (wenn die .htpasswd in /etc/apache2/ liegt) egal, aber trotzdem sollte man
Das Passwortfile sollte nie in einem vom Webserver erreichbaren Pfad liegen, um bei eventueller Fehlkonfiguration (z.B Fehlen / Überschreiben der von dir genannten Direktive durch admin-Fehler) ein Herunterladen des Files definitiv auszuschliessen.
Hallo zusammen,
noch was zum Überlegen:
In der apache2.conf steht dieser Eintrag:
<Directory />
Options FollowSymLinks
#AllowOverride None
AllowOverride All
Require all denied
</Directory>
Wenn ich den, wie geschehen, von
AllowOverride None auf AllowOverride All ändere, passiert gar nichts.
Kommentiere ich diese Sektion aber ganz aus (# vor jede Zeile), dann erhalte ich beim Aufruf der Seite eine Fehlermeldung:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.54 (Raspbian) Server at 192.168.10.31 Port 80
???
Habe das jetzt wieder geändert, so dass zumindest die Seite wieder angezeigt wird.
Dann habe ich die .htpasswd in /etc/apache2/ geändert in htpasswd.
In der .htaccess habe ich das auch angepasst
AuthUserFile /etc/apache2/htpasswd
Es funktioniert nicht. Die Seite wird ohne Rückfrage angezeigt. Habe das auch mit einem anderen Browser getestet. Auch mit Seite neu Laden, Cache löschen, Browserdaten löschen etc.
Danke Thomas
Das Passwortfile sollte nie in einem vom Webserver erreichbaren Pfad liegen
Das wissen Du und ich, aber....
Den Beitrag #31 verstehe ich nicht wirklich, denn mir geht es um den Pfad /var/www/html/. Es geht nicht um / oder /var/www/!
Was ist bei Dir die Ausgabe von cat /etc/os-release?
Hallo hyle,
der Pfad /var/www/html/ war in der apache2.conf nicht vorhanden.
Habe ihn ergänzt:
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
- keine Änderung.
Das Kommando cat /etc/os-release ergibt dieses Ergebnis:
pi@blau31:/var/www/html/h6 $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
Alles anzeigen
Danke Thomas
So langsam tappe ich hier wirklich im Dunklen.
Woher kommt eigentlich dieses Verzeichnis /var/www/html/h6? Hast Du das eingerichtet und falls ja warum? Hast Du das Raspbery Pi OS installiert oder ist das ein anderes OS, welches nur darauf basiert?
Thomas220 Prüfe mal deine gesamte Konfiguration und die Apache2-Logs. Eventuell wurde beim Rumspielen irgendwo etwas geändert, was nun basic_auth verhindert.
Aktive Konfiguration kannst du z.B. mit folgendem einsehen:
#!/bin/sh
a2enmod info
apache2ctl -DDUMP_CONFIG | grep -vE "^[ ]*#[ ]*[0-9]+:$"
a2dismod info
apache2ctl -M |grep auth
Ich habe hier gerade mal einen nackten Debian 11 Container (allerdings kein Raspbian, sollte aber keinen Unterschied machen) mit
Apache2 aufgesetzt und Basic-Auth wie in #12 beschrieben aktiviert - es funktioniert genau so.
Keine Änderung apache2.conf, keine .htaccess, kein rewrite etc. lediglich in der aktivierten /etc/apache2/sites-available/000-default.conf die passende Direktive eingebaut und ein Reload gemacht.
Guten Morgen zusammen.
Gestern Abend war es mir zu spät und auch das Gehirn hing schon aus dem Kopf
hyle:
Also aufgesetzt wurde das System mit diesem Abbild 2021-10-30-raspios-bullseye-armhf.img
Das Verzeichnis .../h6 habe ich angelegt. Dort befinden sich die Seiten/Dateien, die ich schützen will. Doch selbst wenn ich alles schützen will, also von /var/www/ abwärts, geht es nicht.
@llutz :
Habe die Zeilen in ein Shellscript kopiert. Das Ergebnis ist das hier:
pi@blau31:/home/scripts $ sudo ./apache_auslesen.sh
Enabling module info.
To activate the new configuration, you need to run:
systemctl restart apache2
AH00558: apache2: Could not reliably determine the server's fully qualified doma in name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress th is message
# In file: /etc/apache2/apache2.conf
PidFile /var/run/apache2/apache2.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User www-data
Group www-data
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
# In file: /etc/apache2/mods-enabled/alias.conf
Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
Options FollowSymlinks
AllowOverride None
Require all granted
</Directory>
# In file: /etc/apache2/mods-enabled/autoindex.conf
IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=* DescriptionWidth=* Charset=UTF-8
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip x-bzip2
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif /core
AddIcon (SND,/icons/sound2.gif) .ogg
AddIcon (VID,/icons/movie.gif) .ogm
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
AddIcon /icons/odf6odt-20x22.png .odt
AddIcon /icons/odf6ods-20x22.png .ods
AddIcon /icons/odf6odp-20x22.png .odp
AddIcon /icons/odf6odg-20x22.png .odg
AddIcon /icons/odf6odc-20x22.png .odc
AddIcon /icons/odf6odf-20x22.png .odf
AddIcon /icons/odf6odb-20x22.png .odb
AddIcon /icons/odf6odi-20x22.png .odi
AddIcon /icons/odf6odm-20x22.png .odm
AddIcon /icons/odf6ott-20x22.png .ott
AddIcon /icons/odf6ots-20x22.png .ots
AddIcon /icons/odf6otp-20x22.png .otp
AddIcon /icons/odf6otg-20x22.png .otg
AddIcon /icons/odf6otc-20x22.png .otc
AddIcon /icons/odf6otf-20x22.png .otf
AddIcon /icons/odf6oti-20x22.png .oti
AddIcon /icons/odf6oth-20x22.png .oth
DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# RCS CVS *,v *,t
# In file: /etc/apache2/mods-enabled/deflate.conf
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javasc ript
AddOutputFilterByType DEFLATE application/x-javascript application/javascript ap plication/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/wasm
AddOutputFilterByType DEFLATE application/xml
# In file: /etc/apache2/mods-enabled/dir.conf
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
# In file: /etc/apache2/mods-enabled/info.conf
<Location /server-info>
SetHandler server-info
Require local
</Location>
# In file: /etc/apache2/mods-enabled/mime.conf
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-bzip2 .bz2
AddLanguage am .amh
AddLanguage ar .ara
AddLanguage be .be
AddLanguage bg .bg
AddLanguage bn .bn
AddLanguage br .br
AddLanguage bs .bs
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage cy .cy
AddLanguage da .da
AddLanguage da .dk
AddLanguage de .de
AddLanguage dz .dz
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
RemoveType es
AddLanguage es .es
AddLanguage et .et
AddLanguage eu .eu
AddLanguage fa .fa
AddLanguage fi .fi
AddLanguage fr .fr
AddLanguage ga .ga
AddLanguage gl .glg
AddLanguage gu .gu
AddLanguage he .he
AddLanguage hi .hi
AddLanguage hr .hr
AddLanguage hu .hu
AddLanguage hy .hy
AddLanguage id .id
AddLanguage is .is
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ka .ka
AddLanguage kk .kk
AddLanguage km .km
AddLanguage kn .kn
AddLanguage ko .ko
AddLanguage ku .ku
AddLanguage lo .lo
AddLanguage lt .lt
AddLanguage ltz .ltz
AddLanguage lv .lv
AddLanguage mg .mg
AddLanguage mk .mk
AddLanguage ml .ml
AddLanguage mr .mr
AddLanguage ms .msa
AddLanguage nb .nob
AddLanguage ne .ne
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pa .pa
AddLanguage pl .po
AddLanguage pt-BR .pt-br
AddLanguage pt .pt
AddLanguage ro .ro
AddLanguage ru .ru
AddLanguage sa .sa
AddLanguage se .se
AddLanguage si .si
AddLanguage sk .sk
AddLanguage sl .sl
AddLanguage sq .sq
AddLanguage sr .sr
AddLanguage sv .sv
AddLanguage ta .ta
AddLanguage te .te
AddLanguage th .th
AddLanguage tl .tl
RemoveType tr
AddLanguage tr .tr
AddLanguage uk .uk
AddLanguage ur .ur
AddLanguage vi .vi
AddLanguage wo .wo
AddLanguage xh .xh
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw
AddCharset us-ascii .ascii .us-ascii
AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .arb .arabic
AddCharset ISO-8859-7 .iso8859-7 .grk .greek
AddCharset ISO-8859-8 .iso8859-8 .heb .hebrew
AddCharset ISO-8859-9 .iso8859-9 .latin5 .trk
AddCharset ISO-8859-10 .iso8859-10 .latin6
AddCharset ISO-8859-13 .iso8859-13
AddCharset ISO-8859-14 .iso8859-14 .latin8
AddCharset ISO-8859-15 .iso8859-15 .latin9
AddCharset ISO-8859-16 .iso8859-16 .latin10
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5 .b5
AddCharset cn-Big5 .cn-big5
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8 .koi8
AddCharset KOI8-E .koi8-e
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-U .koi8-u
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-7 .utf7
AddCharset UTF-8 .utf8
AddCharset UTF-16 .utf16
AddCharset UTF-16BE .utf16be
AddCharset UTF-16LE .utf16le
AddCharset UTF-32 .utf32
AddCharset UTF-32BE .utf32be
AddCharset UTF-32LE .utf32le
AddCharset euc-cn .euc-cn
AddCharset euc-gb .euc-gb
AddCharset euc-jp .euc-jp
AddCharset euc-kr .euc-kr
AddCharset EUC-TW .euc-tw
AddCharset gb2312 .gb2312 .gb
AddCharset iso-10646-ucs-2 .ucs-2 .iso-10646-ucs-2
AddCharset iso-10646-ucs-4 .ucs-4 .iso-10646-ucs-4
AddCharset shift_jis .shift_jis .sjis
AddCharset BRF .brf
AddHandler type-map var
AddType text/html .shtml
# In file: /etc/apache2/mods-enabled/mpm_event.conf
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
# In file: /etc/apache2/mods-enabled/negotiation.conf
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW
ForceLanguagePriority Prefer Fallback
# In file: /etc/apache2/mods-enabled/reqtimeout.conf
RequestReadTimeout header=20-40,minrate=500
RequestReadTimeout body=10,minrate=500
# In file: /etc/apache2/mods-enabled/setenvif.conf
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-caref ully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^gvfs/1" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
BrowserMatch " Konqueror/4" redirect-carefully
# In file: /etc/apache2/mods-enabled/status.conf
<Location /server-status>
SetHandler server-status
Require local
</Location>
ExtendedStatus On
# In file: /etc/apache2/ports.conf
Listen 80
# In file: /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/h6/>
AllowOverride All
Require all granted
</Directory>
AccessFileName /var/www/html/h6/.htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" v host_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combine d
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# In file: /etc/apache2/conf-enabled/other-vhosts-access-log.conf
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
# In file: /etc/apache2/conf-enabled/security.conf
ServerTokens OS
ServerSignature On
TraceEnable Off
# In file: /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/h6
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
httpd (pid 366) already running
Module info disabled.
To activate the new configuration, you need to run:
systemctl restart apache2
AH00558: apache2: Could not reliably determine the server's fully qualified doma in name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress th is message
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
pi@blau31:/home/scripts $
Alles anzeigen
Weiß damit leider nicht so viel anzufangen.
Wenn ich die /var/log/apache2/access.log auslese, habe ich diese beiden Einträge von Heute:
192.168.10.117 - - [06/Nov/2022:10:58:04 +0100] "GET / HTTP/1.1" 200 11138 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHT>
192.168.10.117 - - [06/Nov/2022:10:58:04 +0100] "GET /favicon.ico/favicon-32x32.png HTTP/1.1" 200 3474 "http://192.168.10.31/" "Mozilla/5.0 (Wind>
Und in der /var/log/apache2/error.log diese beiden Zeilen:
[Sun Nov 06 00:00:06.804070 2022] [mpm_event:notice] [pid 366:tid 3070037568] AH00489: Apache/2.4.54 (Raspbian) configured -- resuming normal ope>
[Sun Nov 06 00:00:06.804387 2022] [core:notice] [pid 366:tid 3070037568] AH00094: Command line: '/usr/sbin/apache2'
Ich kann nichts erkennen, was auf einen Missstand hindeutet. Aber vielleicht sehe ich auch nicht richtig.
Danke Thomas
Weiß damit leider nicht so viel anzufangen.
Dann vergleiche mit dieser (zu #37 passenden) Ausgabe und versuche deine Konfiguration zu verstehen und ggf. anzupassen.
..
# In file: /etc/apache2/apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
..
..
# In file: /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Location />
AuthType Basic
AuthName "Please login."
AuthUserFile "/etc/apache2/htpasswd"
Require valid-user
</Location>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!