Apache2 vHost Konfiguration

brustring

Cadet 4th Year
Registriert
Okt. 2012
Beiträge
107
Hallo zusammen,
ich habe mir mal wieder meinen Raspbarry eingeschaltet und mir einen Server aufgesetzt.

Meine Konfiguration:

apache2.config

#
# The directory where shm and other runtime files will be stored.
#

#DefaultRuntimeDir /var/run/apache2
DefaultRuntimeDir ${APACHE_RUN_DIR}


#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you do define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<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>

#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

#Include /etc/phpmyadmin/apache.conf
#ServerName localhost
#<IfModule mod_security2.c>
# SecServerSignature " "
#</IfModule>
#ServerName localhost
Hallo zusammen,

000_default.conf

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

vHost für die Testseite
<VirtualHost *:80>
DocumentRoot /var/www/seiteTest
ServerName seiteTest.domain.de
<Directory /var/www/seiteTest/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
</Directory>
</VirtualHost>

Zum Problem.
Ich kann nur auf Dateien zugreifen, die im Verzeichnis /var/www/html liegen.
Auf /var/www/seitTest habe ich keinen Zugriff und erhalte nur "Server nicht gefunden ", wenn ich das Verzeichnis über seiteTest.domain.de aufrufen möchte.
Hat jmd eine Idee?


Auf den Raspberry greife ich über eine no-ip-Domain vom Typ AAAA zu.
 
Zuletzt bearbeitet:
Das DocumentRoot ist auf /var/www/html konfiguriert. Da hast du natürlich ohne weitere Konfigurationen keinen Zugriff auf /var/www/seitTest. Entweder du legst das in /var/www/html/seitTest oder du änderst das DocumentRoot ab oder du legst einen neuen vHost an oder du regelst das über Aliase oder oder oder ;)
 
foo_1337 schrieb:
Das DocumentRoot ist auf /var/www/html konfiguriert. Da hast du natürlich ohne weitere Konfigurationen keinen Zugriff auf /var/www/seitTest. Entweder du legst das in /var/www/html/seitTest oder du änderst das DocumentRoot ab oder du legst einen neuen vHost an oder du regelst das über Aliase oder oder oder ;)
Danke für Deine Antwort.

Da fällt mir auf, ich habe die seiteTest.conf vergessen. ist auch enabled.

<VirtualHost *:80>
DocumentRoot /var/www/seiteTest
ServerName seiteTest.domain.de
<Directory /var/www/seiteTest/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
</Directory>
</VirtualHost>

Hatte mir dann auch ein Video angesehen (
) und verstehe nicht, weshalb ich nicht auf die Elemente zugreifen kann.
In dem Video ist zu sehen, dass auf die Verzeichnisse zugegriffen werden kann, obwohl das DocumentRoot auf /var/www/html gesetzt ist.
Habe ich da etwas missverstanden?
 
Aaah, jetzt wird ein Schuh draus. Wie rufst du denn die Seite auf? Mit dem Hostnamen, den du auch in der vHost Config (ServerName) angegeben hast? kannst du mal den output von curl -Lv http://seiteTest.domain.de >/dev/null (kannst den output gerne zensieren) posten?
 
  • Gefällt mir
Reaktionen: up.whatever
Ohne passende Domain im http Host-Header bekommst du deine Antwort immer vom Default vhost.
 
  • Gefällt mir
Reaktionen: foo_1337
foo_1337 schrieb:
Aaah, jetzt wird ein Schuh draus. Wie rufst du denn die Seite auf? Mit dem Hostnamen, den du auch in der vHost Config (ServerName) angegeben hast? kannst du mal den output von curl -Lv http://seiteTest.domain.de >/dev/null (kannst den output gerne zensieren) posten?

Da erhalte ich folgenden Output. Habe die Domain mal angepasst/zensiert.
% Total % Received % Xferd Average Speed Time Time Time Current


Dload Upload Total Spent Left Speed


0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Could not resolve host: seiteTest.domain.de


* Closing connection 0


curl: (6) Could not resolve host: seiteTest.domain.de

Vermute stark, dass ich da irgendwas in der Konfiguration versemmelt habe :/

Wenn ich die Hauptdomain aufrufe erhalte ich folgende Antwort
% Total % Received % Xferd Average Speed Time Time Time Current


Dload Upload Total Spent Left Speed


0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ****************...


* TCP_NODELAY set


* Trying **************..


* TCP_NODELAY set


* Connected to virei.ddns.net (**************) port 80 (#0)




Host: no-ip-domain.ddns.net


User-Agent: curl/7.64.1






< HTTP/1.1 200 OK


< Date: Sat, 15 Jan 2022 12:50:30 GMT


< Server: Apache


< Upgrade: h2,h2c


< Connection: Upgrade


< Last-Modified: Sat, 28 Nov 2020 17:25:49 GMT


< ETag: "29cd-5b52e116fabc2"


< Accept-Ranges: bytes


< Content-Length: 10701


< Vary: Accept-Encoding


< Content-Type: text/html


<


{ [9887 bytes data]


100 10701 100 10701 0 0 47986 0 --:--:-- --:--:-- --:--:-- 47986


* Connection #0 to host no-ip-domain.ddns.net left intact


* Closing connection 0



up.whatever schrieb:
ähm. Wie bitte? Ich freue mich schon weiter dazuzulernen
 
"curl: (6) Could not resolve host: seiteTest.domain.de" <- Meint, dass es keinen DNS Eintrag dafür gibt. Falls es ausschließlich einen AAAA Record gibt, kann der client von dem der curl gestartet wurde kein v6.
 
foo_1337 schrieb:
"curl: (6) Could not resolve host: seiteTest.domain.de" <- Meint, dass es keinen DNS Eintrag dafür gibt. Falls es ausschließlich einen AAAA Record gibt, kann der client von dem der curl gestartet wurde kein v6.
Kann bei no-ip ja einige Einstellungen vornehmen bei der Domain. Aktuell habe ich dort eine iPv4 und iPv6 hinterlegt (beim Anlegen AAAA gewählt und beide Adressen hinterlegt).
Im Backend der Fritzbox steht in der Übersicht "iPv6: unbekannt", wenn ich meine IP abfrage, habe ich jedoch eine -> Denke das geht.

Wo kann ich denn einsehen, ob das unterstützt wird und wir bekomme ich die Unterstützung hin?



up.whatever schrieb:
Lass uns mal zwei Schritte zurück gehen: Benötigst du überhaupt mehrere vhosts?
Brauchen ist immer relativ. Ich würde gerne verstehen, was hier das Problem ist. Es interessiert mich sehr und Weiterbilden schadet nich (:
 
Ich bin jetzt etwas weitergekommen.
Wenn ich auf meinem PI seiteTest.localhost pinge, erhalte ich keine Fehlermeldung, sondern der Server ist erreichbar.

Daraus schließe ich, dass das Problem bei No-ip liegt und die mir die Subdomain nicht weiterleiten/erlauben.

Gibt es Ideen, wie ich das lösen kann und geht das mit dem Kostenlosen Konto bei denen nicht?
Gibt es einen anderen ddns Dienst, der das kann und bei dem Ihr Erfahrungen habt?
 
Versuchst du aus deinem Heimnetz auf eine No-IP Domain zuzugreifen, die auf deinen Raspi im Heimnetz zeigt? Dann ist es ein DNS Rebind Problem. Trag die Domain doch mal in die Fritzbox ein.
 
riversource schrieb:
Versuchst du aus deinem Heimnetz auf eine No-IP Domain zuzugreifen, die auf deinen Raspi im Heimnetz zeigt? Dann ist es ein DNS Rebind Problem. Trag die Domain doch mal in die Fritzbox ein.
Ich habe die IP des Pis bei No-IP hinterlegt, die Zugangsdaten in der Fritzblox für Dyndns hinterlegt.
Ich kann auf alles, was im Standardroot-Verzeichnis (var/www/html) liegt zugreifen. Meine VPN und das PIhole funktionieren reibungslos.

Ich möchte mir jetzt in var/www weitere Verzeichnisse anlege und WP oder ähnliches installieren und darauf via vHost zugreifen (URL-Bsp.: seiteTest.no-ip-domain).
Suche ich nach "curl -Lv http://seite1.localhost:80 >/dev/null" erhalte ich das Feedback "Server geht". Ersetze ich die Seite durch "seiteTest.no-ip-domain", kommt "curl: (6) Could not resolve host:"
 
Es wäre halt alles einfacher, wenn wir die Domain kennen würden, aber ich verstehe, wenn man die nicht preisgeben will. Daher bitte
'host -t A seiteTest.no-ip-domain' sowie 'host -t AAAA seiteTest.no-ip-domain' auf dem Pi ausführen. Und dann das gleiche nochmal so: 'host -t A seiteTest.no-ip-domain 8.8.8.8 ' und 'host -t AAAA seiteTest.no-ip-domain 8.8.8.8'
Den output kannst du dann wieder zensieren
 
foo_1337 schrieb:
Es wäre halt alles einfacher, wenn wir die Domain kennen würden, aber ich verstehe, wenn man die nicht preisgeben will. Daher bitte
'host -t A seiteTest.no-ip-domain' sowie 'host -t AAAA seiteTest.no-ip-domain' auf dem Pi ausführen. Und dann das gleiche nochmal so: 'host -t A seiteTest.no-ip-domain 8.8.8.8 ' und 'host -t AAAA seiteTest.no-ip-domain 8.8.8.8'
Den output kannst du dann wieder zensieren
Das möchte ich tatsächlich etwas ungern :D

Der Output ist fast identisch
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:

Host xxxx not found: 3(NXDOMAIN)

EDIT: hatte es eben mit der falschen Adresse versucht.
 
Der Host ist nicht auflösbar... da stimmt was mit der dyndns config nicht.
 
foo_1337 schrieb:
Der Host ist nicht auflösbar... da stimmt was mit der dyndns config nicht.
Moment mal. Muss ich hier für jede Subdomain einen eigenen Host anlegen?

Da ich auf dem Schlauch stehe..ist das eine Sache des Pis, oder liegt das eher an einer Einstellung bei no-ip?
 
Ja klar, du brauchst sowohl in der Apache Config die Konfiguration (ServerName) wie bei dem Dyndns provider den zugehörigen DNS Record.
 
foo_1337 schrieb:
Ja klar, du brauchst sowohl in der Apache Config die Konfiguration (ServerName) wie bei dem Dyndns provider den zugehörigen DNS Record.
Aha. Jetzt kommen wir hier vielleicht etwas weiter. Danke dir!

Wie pflege ich denn dann dieses cnames, um meine Subdomains zu erstellen? Denn das ging nicht :D

1642357311332.png
 
Zurück
Oben