Apache2 liefert falsche Webseite aus

Debian macht sich hervorragend als Web- und Mailserver. Schau auch in den " Tipps und Tricks"-Bereich.
Antworten
FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 10:56:27

Hallo Community,

Ich habe eine Frage. Ich habe auf meinem Raspberry Pi einen Apache2 Webserver laufen, der meine Nextcloud Seite ausliefert, wenn ich die Adresse AAA.example.de eingebe. Dies funktioniert tadellos.

Nun habe ich einen 2 Virtuellen Host angelegt der eine Webseite ausliefern soll. Aus einem mir unerklärlichen Grund liefert der Apache aber immer die erste Seite (nach Alphabet) aus, die unter sites-enabled aktiviert ist. Das heist, wenn ich folgende Konstellation habe:

AAA.example.de -> aaa.conf -> /var/www/html/aaa
BBB.example.de -> bbb.conf -> /var/www/html/bbb

Liefert er bei Eingabe von BBB.example.de im Browser die Seite AAA.example.de aus und nicht die BBB.example.de.
Wenn ich die aaa.conf in zzz.conf umbenenne und „enable“ dann liefert der Webserver die BBB.example.conf aus. Wo muss ich ansetzen um dies zu richten?

Vielen Dank

Benutzeravatar
heisenberg
Beiträge: 3540
Registriert: 04.06.2015 01:17:27
Lizenz eigener Beiträge: MIT Lizenz

Re: Apache2 liefert falsche Webseite aus

Beitrag von heisenberg » 08.01.2019 11:48:33

Wenn ich die aaa.conf in zzz.conf umbenenne und „enable“ dann liefert der Webserver die BBB.example.conf aus. Wo muss ich ansetzen um dies zu richten?
Du hast eine weitere virtualhost-config, die auch für aaa.example.de ausliefert. Also möglicherweise eine VHost-Direktive die diesen Hostnamen oder keinen überhaupt Hostnamen enthält, so dass diese für alle Hostnamen greift(Ist der default vhost noch aktiv?). Und wenn die Reihenfolge, dann so ist, dass diese andere VHost-Direktive zuerst kommt, dann geht der Request dorthin.
Jede Rohheit hat ihren Ursprung in einer Schwäche.

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 12:15:55

Ich habe folgende config Dateien (die ich mit a2ensite enabled habe):
  • aaa.example.conf
  • bbb.example.conf
wenn ich nun aber die aaa.example.conf in zzz.example.conf umbenenne und mit a2ensite enable sodass nur noch die
  • bbb.example.conf
  • zzz.example.conf (vorher aaa.example.conf)
vorhanden sind, dann wir die Seite bbb.example.conf ausgeliefert.

sobald ich eine 000-Default.conf anlege erhalte ich folgende Fehlermeldung

Code: Alles auswählen

Forbidden
You don't have permission to access / on this server.
The proxy server could not handle the request GET /.
Reason: Error reading from remote server
Additionally, a 502 Bad Gateway error was encountered while trying to use an ErrorDocument to handle the request.
Nachtrag:
Am Ende möchte ich erreichen, dass bei Eingabe von
aaa.example.com die Nextcloud ausgegeben wird
bbb.example.com die Webseite ausgegeben wird
Zuletzt geändert von FriedrichMS am 08.01.2019 12:19:38, insgesamt 1-mal geändert.

Benutzeravatar
heisenberg
Beiträge: 3540
Registriert: 04.06.2015 01:17:27
Lizenz eigener Beiträge: MIT Lizenz

Re: Apache2 liefert falsche Webseite aus

Beitrag von heisenberg » 08.01.2019 12:18:45

Na dann zeig doch mal deine vhost-configs.
Jede Rohheit hat ihren Ursprung in einer Schwäche.

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 12:22:34

Ich werde nachher, wenn ich wieder zu hause bin die
  • aaa.example.conf
  • bbb,example.conf
  • apache2.conf
Posten. Soll ich eine weitere Posten oder reichen diese zunächst aus?

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 16:07:24

Hallo,

hier sind meine Conf Dateien:

Apache2.conf

Code: Alles auswählen

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#	/etc/apache2/
#	|-- apache2.conf
#	|	`--  ports.conf
#	|-- mods-enabled
#	|	|-- *.load
#	|	`-- *.conf
#	|-- conf-enabled
#	|	`-- *.conf
# 	`-- sites-enabled
#	 	`-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

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

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/html>
	Options Indexes FollowSymLinks
        Options -Indexes
	AllowOverride all
	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

<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</IfModule>

NameVirtualHost *:443

<VirtualHost *:443>
	ServerName aaa.example.de
	ServerAlias aaa.example.de
	DocumentRoot /var/www/html/nextcloud
</VirtualHost>

<VirtualHost *:443>
	ServerName bbb.example.de
	ServerAlias bbb.example.de
	DocumentRoot /var/www/html/webseite
</VirtualHost>

aaa.example.Conf

Code: Alles auswählen

<VirtualHost *:443>
        ServerName aaa.example.de
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/nextcloud
        <Directory /var/www/html/nextcloud>
                Options +FollowSymLinks
		AllowOverride All
	<IfModule mod_dav.c>
        Dav off
        </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud 
        </Directory>
        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
 SSLCertificateFile /etc/letsencrypt/live/ aaa.example.de/fullchain.pem
 SSLCertificateKeyFile /etc/letsencrypt/live/ aaa.example.de/privkey.pem
 Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

bbb.example.conf

Code: Alles auswählen

<VirtualHost *:443>
        ServerName bbb.example.de
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/webseite/
        <Directory /var/www/html/webseite/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
 SSLCertificateFile /etc/letsencrypt/live/ bbb.example.de/fullchain.pem
 SSLCertificateKeyFile /etc/letsencrypt/live/ bbb.example.de/privkey.pem
 Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Benutzeravatar
bluestar
Beiträge: 2346
Registriert: 26.10.2004 11:16:34
Wohnort: Rhein-Main-Gebiet

Re: Apache2 liefert falsche Webseite aus

Beitrag von bluestar » 08.01.2019 16:39:18

Dann hätte ich doch mal direkt zwei Fragen:
* Warum veränderst du die apache2.conf ?
* Wo hast du deine VHost-Dateien abgelegt ?

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 16:50:36

Die apache2.conf habe ich nur um die letzten Zeilen ergänzt. Ich wusste nicht wohin damit. :roll:

Was meinst du mit VHost Dateien abgelegt? Die .conf Dateien sind im Sites-available Ordner mit einer Verknüpfung zu Sites-enabled.
Die html Dateien die ausgeliefert werden sollen sind in den entsprechenden Ordnern /var/www/html/... abgelegt.

Benutzeravatar
heisenberg
Beiträge: 3540
Registriert: 04.06.2015 01:17:27
Lizenz eigener Beiträge: MIT Lizenz

Re: Apache2 liefert falsche Webseite aus

Beitrag von heisenberg » 08.01.2019 16:55:10

FriedrichMS hat geschrieben:Soll ich eine weitere Posten oder reichen diese zunächst aus?
Es braucht alle. Eine davon ist der Übeltäter.
Jede Rohheit hat ihren Ursprung in einer Schwäche.

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 16:56:38

Welche braucht es noch? Ich habe keine weiteren Sites-enabled. Tips?

Hier mal eine ls -alR

Code: Alles auswählen

.:
drwxr-xr-x   8 root root  4096 Jan  8 17:05 .
drwxr-xr-x 123 root root 12288 Jan  8 12:32 ..
-rw-r--r--   1 root root  7720 Jan  8 10:30 apache2.conf
drwxr-xr-x   2 root root  4096 Dez 16 10:06 conf-available
drwxr-xr-x   2 root root  4096 Jan 14  2018 conf-enabled
-rw-r--r--   1 root root  1782 Sep 19  2017 envvars
-rw-r--r--   1 root root 31063 Sep 19  2017 magic
drwxr-xr-x   2 root root 12288 Dez 13 21:18 mods-available
drwxr-xr-x   2 root root  4096 Jan  8 09:39 mods-enabled
-rw-r--r--   1 root root   416 Jan  8 11:18 ports.conf
-rw-r--r--   1 root root   373 Jan  8 11:43 ports.conf.save
drwxr-xr-x   3 root root  4096 Jan  8 11:24 sites-available
drwxr-xr-x   3 root root  4096 Jan  8 12:16 sites-enabled
-rw-r--r--   1 root root     0 Jan  8 17:05 vz.txt

./conf-available:
insgesamt 36
drwxr-xr-x 2 root root 4096 Dez 16 10:06 .
drwxr-xr-x 8 root root 4096 Jan  8 17:05 ..
-rw-r--r-- 1 root root  315 Sep 19  2017 charset.conf
-rw-r--r-- 1 root root  127 Jul 29  2013 javascript-common.conf
-rw-r--r-- 1 root root 3224 Sep 19  2017 localized-error-pages.conf
-rw-r--r-- 1 root root  189 Sep 19  2017 other-vhosts-access-log.conf
-rw-r--r-- 1 root root 1316 Dez  7 12:36 php7.0-cgi.conf
-rw-r--r-- 1 root root 2174 Sep 19  2017 security.conf
-rw-r--r-- 1 root root  455 Sep 19  2017 serve-cgi-bin.conf

./conf-enabled:
insgesamt 8
drwxr-xr-x 2 root root 4096 Jan 14  2018 .
drwxr-xr-x 8 root root 4096 Jan  8 17:05 ..
lrwxrwxrwx 1 root root   30 Jan 14  2018 charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root   44 Jan 14  2018 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root   46 Jan 14  2018 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root   31 Jan 14  2018 security.conf -> ../conf-available/security.conf
lrwxrwxrwx 1 root root   36 Jan 14  2018 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf

./mods-available:
insgesamt 572
drwxr-xr-x 2 root root 12288 Dez 13 21:18 .
drwxr-xr-x 8 root root  4096 Jan  8 17:05 ..
-rw-r--r-- 1 root root   100 Sep 19  2017 access_compat.load
-rw-r--r-- 1 root root   377 Sep 19  2017 actions.conf
-rw-r--r-- 1 root root    66 Sep 19  2017 actions.load
-rw-r--r-- 1 root root   843 Sep 19  2017 alias.conf
-rw-r--r-- 1 root root    62 Sep 19  2017 alias.load
-rw-r--r-- 1 root root    76 Sep 19  2017 allowmethods.load
-rw-r--r-- 1 root root    76 Sep 19  2017 asis.load
-rw-r--r-- 1 root root    94 Sep 19  2017 auth_basic.load
-rw-r--r-- 1 root root    96 Sep 19  2017 auth_digest.load
-rw-r--r-- 1 root root   100 Sep 19  2017 auth_form.load
-rw-r--r-- 1 root root    72 Sep 19  2017 authn_anon.load
-rw-r--r-- 1 root root    72 Sep 19  2017 authn_core.load
-rw-r--r-- 1 root root    85 Sep 19  2017 authn_dbd.load
-rw-r--r-- 1 root root    70 Sep 19  2017 authn_dbm.load
-rw-r--r-- 1 root root    72 Sep 19  2017 authn_file.load
-rw-r--r-- 1 root root    78 Sep 19  2017 authn_socache.load
-rw-r--r-- 1 root root    74 Sep 19  2017 authnz_fcgi.load
-rw-r--r-- 1 root root    90 Sep 19  2017 authnz_ldap.load
-rw-r--r-- 1 root root    72 Sep 19  2017 authz_core.load
-rw-r--r-- 1 root root    96 Sep 19  2017 authz_dbd.load
-rw-r--r-- 1 root root    92 Sep 19  2017 authz_dbm.load
-rw-r--r-- 1 root root   104 Sep 19  2017 authz_groupfile.load
-rw-r--r-- 1 root root    94 Sep 19  2017 authz_host.load
-rw-r--r-- 1 root root    74 Sep 19  2017 authz_owner.load
-rw-r--r-- 1 root root    94 Sep 19  2017 authz_user.load
-rw-r--r-- 1 root root  3374 Sep 19  2017 autoindex.conf
-rw-r--r-- 1 root root    70 Sep 19  2017 autoindex.load
-rw-r--r-- 1 root root    64 Sep 19  2017 buffer.load
-rw-r--r-- 1 root root   889 Sep 19  2017 cache_disk.conf
-rw-r--r-- 1 root root    89 Sep 19  2017 cache_disk.load
-rw-r--r-- 1 root root    62 Sep 19  2017 cache.load
-rw-r--r-- 1 root root    95 Sep 19  2017 cache_socache.load
-rw-r--r-- 1 root root    70 Sep 19  2017 cern_meta.load
-rw-r--r-- 1 root root   115 Sep 19  2017 cgid.conf
-rw-r--r-- 1 root root    60 Sep 19  2017 cgid.load
-rw-r--r-- 1 root root    58 Sep 19  2017 cgi.load
-rw-r--r-- 1 root root    76 Sep 19  2017 charset_lite.load
-rw-r--r-- 1 root root    60 Sep 19  2017 data.load
-rw-r--r-- 1 root root    83 Sep 19  2017 dav_fs.conf
-rw-r--r-- 1 root root    79 Sep 19  2017 dav_fs.load
-rw-r--r-- 1 root root    58 Sep 19  2017 dav.load
-rw-r--r-- 1 root root    68 Sep 19  2017 dav_lock.load
-rw-r--r-- 1 root root    58 Sep 19  2017 dbd.load
-rw-r--r-- 1 root root   522 Sep 19  2017 deflate.conf
-rw-r--r-- 1 root root    84 Sep 19  2017 deflate.load
-rw-r--r-- 1 root root    64 Sep 19  2017 dialup.load
-rw-r--r-- 1 root root   157 Sep 19  2017 dir.conf
-rw-r--r-- 1 root root    58 Sep 19  2017 dir.load
-rw-r--r-- 1 root root    64 Sep 19  2017 dump_io.load
-rw-r--r-- 1 root root    60 Sep 19  2017 echo.load
-rw-r--r-- 1 root root    58 Sep 19  2017 env.load
-rw-r--r-- 1 root root    66 Sep 19  2017 expires.load
-rw-r--r-- 1 root root    72 Sep 19  2017 ext_filter.load
-rw-r--r-- 1 root root    89 Sep 19  2017 file_cache.load
-rw-r--r-- 1 root root    64 Sep 19  2017 filter.load
-rw-r--r-- 1 root root    66 Sep 19  2017 headers.load
-rw-r--r-- 1 root root   176 Sep 19  2017 heartbeat.load
-rw-r--r-- 1 root root   182 Sep 19  2017 heartmonitor.load
-rw-r--r-- 1 root root    62 Sep 19  2017 http2.load
-rw-r--r-- 1 root root    62 Sep 19  2017 ident.load
-rw-r--r-- 1 root root    68 Sep 19  2017 imagemap.load
-rw-r--r-- 1 root root    82 Sep 19  2017 include.load
-rw-r--r-- 1 root root   402 Sep 19  2017 info.conf
-rw-r--r-- 1 root root    60 Sep 19  2017 info.load
-rw-r--r-- 1 root root   116 Sep 19  2017 lbmethod_bybusyness.load
-rw-r--r-- 1 root root   116 Sep 19  2017 lbmethod_byrequests.load
-rw-r--r-- 1 root root   114 Sep 19  2017 lbmethod_bytraffic.load
-rw-r--r-- 1 root root   114 Sep 19  2017 lbmethod_heartbeat.load
-rw-r--r-- 1 root root   121 Sep 19  2017 ldap.conf
-rw-r--r-- 1 root root    60 Sep 19  2017 ldap.load
-rw-r--r-- 1 root root    70 Sep 19  2017 log_debug.load
-rw-r--r-- 1 root root    76 Sep 19  2017 log_forensic.load
-rw-r--r-- 1 root root    58 Sep 19  2017 lua.load
-rw-r--r-- 1 root root    62 Sep 19  2017 macro.load
-rw-r--r-- 1 root root  7639 Sep 19  2017 mime.conf
-rw-r--r-- 1 root root    60 Sep 19  2017 mime.load
-rw-r--r-- 1 root root   120 Sep 19  2017 mime_magic.conf
-rw-r--r-- 1 root root    72 Sep 19  2017 mime_magic.load
-rw-r--r-- 1 root root   668 Sep 19  2017 mpm_event.conf
-rw-r--r-- 1 root root   106 Sep 19  2017 mpm_event.load
-rw-r--r-- 1 root root   571 Sep 19  2017 mpm_prefork.conf
-rw-r--r-- 1 root root   108 Sep 19  2017 mpm_prefork.load
-rw-r--r-- 1 root root   836 Sep 19  2017 mpm_worker.conf
-rw-r--r-- 1 root root   107 Sep 19  2017 mpm_worker.load
-rw-r--r-- 1 root root   724 Sep 19  2017 negotiation.conf
-rw-r--r-- 1 root root    74 Sep 19  2017 negotiation.load
-rw-r--r-- 1 root root   867 Jan  5  2018 php7.0.conf
-rw-r--r-- 1 root root   102 Jan  5  2018 php7.0.load
-rw-r--r-- 1 root root    87 Sep 19  2017 proxy_ajp.load
-rw-r--r-- 1 root root   347 Sep 19  2017 proxy_balancer.conf
-rw-r--r-- 1 root root   115 Sep 19  2017 proxy_balancer.load
-rw-r--r-- 1 root root   822 Sep 19  2017 proxy.conf
-rw-r--r-- 1 root root    95 Sep 19  2017 proxy_connect.load
-rw-r--r-- 1 root root    95 Sep 19  2017 proxy_express.load
-rw-r--r-- 1 root root    89 Sep 19  2017 proxy_fcgi.load
-rw-r--r-- 1 root root    93 Sep 19  2017 proxy_fdpass.load
-rw-r--r-- 1 root root   189 Sep 19  2017 proxy_ftp.conf
-rw-r--r-- 1 root root    87 Sep 19  2017 proxy_ftp.load
-rw-r--r-- 1 root root    93 Sep 19  2017 proxy_hcheck.load
-rw-r--r-- 1 root root  2511 Sep 19  2017 proxy_html.conf
-rw-r--r-- 1 root root    97 Sep 19  2017 proxy_html.load
-rw-r--r-- 1 root root    97 Sep 19  2017 proxy_http2.load
-rw-r--r-- 1 root root    89 Sep 19  2017 proxy_http.load
-rw-r--r-- 1 root root    62 Sep 19  2017 proxy.load
-rw-r--r-- 1 root root    89 Sep 19  2017 proxy_scgi.load
-rw-r--r-- 1 root root    97 Sep 19  2017 proxy_wstunnel.load
-rw-r--r-- 1 root root    85 Sep 19  2017 ratelimit.load
-rw-r--r-- 1 root root    70 Sep 19  2017 reflector.load
-rw-r--r-- 1 root root    68 Sep 19  2017 remoteip.load
-rw-r--r-- 1 root root  1190 Sep 19  2017 reqtimeout.conf
-rw-r--r-- 1 root root    72 Sep 19  2017 reqtimeout.load
-rw-r--r-- 1 root root    66 Sep 19  2017 request.load
-rw-r--r-- 1 root root    66 Sep 19  2017 rewrite.load
-rw-r--r-- 1 root root    58 Sep 19  2017 sed.load
-rw-r--r-- 1 root root    99 Sep 19  2017 session_cookie.load
-rw-r--r-- 1 root root    99 Sep 19  2017 session_crypto.load
-rw-r--r-- 1 root root    93 Sep 19  2017 session_dbd.load
-rw-r--r-- 1 root root    66 Sep 19  2017 session.load
-rw-r--r-- 1 root root  1280 Sep 19  2017 setenvif.conf
-rw-r--r-- 1 root root    68 Sep 19  2017 setenvif.load
-rw-r--r-- 1 root root    78 Sep 19  2017 slotmem_plain.load
-rw-r--r-- 1 root root    74 Sep 19  2017 slotmem_shm.load
-rw-r--r-- 1 root root    74 Sep 19  2017 socache_dbm.load
-rw-r--r-- 1 root root    84 Sep 19  2017 socache_memcache.load
-rw-r--r-- 1 root root    78 Sep 19  2017 socache_shmcb.load
-rw-r--r-- 1 root root    66 Sep 19  2017 speling.load
-rw-r--r-- 1 root root  3110 Sep 19  2017 ssl.conf
-rw-r--r-- 1 root root    97 Sep 19  2017 ssl.load
-rw-r--r-- 1 root root   749 Sep 19  2017 status.conf
-rw-r--r-- 1 root root    64 Sep 19  2017 status.load
-rw-r--r-- 1 root root    72 Sep 19  2017 substitute.load
-rw-r--r-- 1 root root    64 Sep 19  2017 suexec.load
-rw-r--r-- 1 root root    70 Sep 19  2017 unique_id.load
-rw-r--r-- 1 root root   324 Sep 19  2017 userdir.conf
-rw-r--r-- 1 root root    66 Sep 19  2017 userdir.load
-rw-r--r-- 1 root root    70 Sep 19  2017 usertrack.load
-rw-r--r-- 1 root root    74 Sep 19  2017 vhost_alias.load
-rw-r--r-- 1 root root    66 Sep 19  2017 xml2enc.load

./mods-enabled:
insgesamt 8
drwxr-xr-x 2 root root 4096 Jan  8 09:39 .
drwxr-xr-x 8 root root 4096 Jan  8 17:05 ..
lrwxrwxrwx 1 root root   36 Jan 14  2018 access_compat.load -> ../mods-available/access_compat.load
lrwxrwxrwx 1 root root   28 Jan 14  2018 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root   28 Jan 14  2018 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root   33 Jan 14  2018 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root   33 Jan 14  2018 authn_core.load -> ../mods-available/authn_core.load
lrwxrwxrwx 1 root root   33 Jan 14  2018 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root   33 Jan 14  2018 authz_core.load -> ../mods-available/authz_core.load
lrwxrwxrwx 1 root root   33 Jan 14  2018 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root   33 Jan 14  2018 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root   32 Jan 14  2018 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root   32 Jan 14  2018 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root   30 Jan 14  2018 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root   30 Jan 14  2018 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root   26 Jan 14  2018 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root   26 Jan 14  2018 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root   26 Jan 14  2018 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root   29 Jan 14  2018 filter.load -> ../mods-available/filter.load
lrwxrwxrwx 1 root root   30 Jan 14  2018 headers.load -> ../mods-available/headers.load
lrwxrwxrwx 1 root root   27 Jan 14  2018 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root   27 Jan 14  2018 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root   34 Jan 14  2018 mpm_prefork.conf -> ../mods-available/mpm_prefork.conf
lrwxrwxrwx 1 root root   34 Jan 14  2018 mpm_prefork.load -> ../mods-available/mpm_prefork.load
lrwxrwxrwx 1 root root   34 Jan 14  2018 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root   34 Jan 14  2018 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root   29 Jan 14  2018 php7.0.conf -> ../mods-available/php7.0.conf
lrwxrwxrwx 1 root root   29 Jan 14  2018 php7.0.load -> ../mods-available/php7.0.load
lrwxrwxrwx 1 root root   33 Jan 14  2018 reqtimeout.conf -> ../mods-available/reqtimeout.conf
lrwxrwxrwx 1 root root   33 Jan 14  2018 reqtimeout.load -> ../mods-available/reqtimeout.load
lrwxrwxrwx 1 root root   30 Jan 18  2018 rewrite.load -> ../mods-available/rewrite.load
lrwxrwxrwx 1 root root   31 Jan 14  2018 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root   31 Jan 14  2018 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root   36 Jan 14  2018 socache_shmcb.load -> ../mods-available/socache_shmcb.load
lrwxrwxrwx 1 root root   26 Jan  8 09:39 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root   26 Jan  8 09:39 ssl.load -> ../mods-available/ssl.load
lrwxrwxrwx 1 root root   29 Jan 14  2018 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root   29 Jan 14  2018 status.load -> ../mods-available/status.load

./sites-available:
insgesamt 48
drwxr-xr-x 3 root root 4096 Jan  8 11:24 .
drwxr-xr-x 8 root root 4096 Jan  8 17:05 ..
-rw-r--r-- 1 root root  790 Jan  8 09:37 aaa.example.conf
-rw-r--r-- 1 root root  732 Jan  8 09:38 bbb.example.conf

./sites-enabled:
insgesamt 12
drwxr-xr-x 3 root root 4096 Jan  8 12:16 .
drwxr-xr-x 8 root root 4096 Jan  8 17:05 ..
lrwxrwxrwx 1 root root   37 Feb 14  2018 aaa.example.conf -> ../sites-available/aaa.example.conf
lrwxrwxrwx 1 root root   36 Dez 16 19:38 bbb.example.conf -> ../sites-available/bbb.example.conf

mludwig
Beiträge: 794
Registriert: 30.01.2005 19:35:04

Re: Apache2 liefert falsche Webseite aus

Beitrag von mludwig » 08.01.2019 18:14:18

In beiden vhost Dateien steht

Code: Alles auswählen

<VirtualHost *:443>
Wenn du aus dem *:443 ein aaa.example.conf:443 bzw. bbb.example.conf:443 machst - jeweils in der richtigen vhost-Datei, wird das was. Außerdem gibt es in der apache2.conf nochmal 2 virtualhost-Direktiven, welche soll er denn nehmen? Ich würde alles was zu einem Virtualhost gehört in die zugehörige Datei schreiben, und die apache2.conf nur für globale Sachen.
*:443 heisst, der Virtualhost ist für alle IPs und Namen des Servers zuständig und antwortet auch darauf. Wenn hinterher nochmal ein Virtualhost kommt, bleibt für den nix übrig.

Benutzeravatar
heisenberg
Beiträge: 3540
Registriert: 04.06.2015 01:17:27
Lizenz eigener Beiträge: MIT Lizenz

Re: Apache2 liefert falsche Webseite aus

Beitrag von heisenberg » 08.01.2019 18:57:34

mludwig hat geschrieben: ↑ zum Beitrag ↑
08.01.2019 18:14:18
In beiden vhost Dateien steht

Code: Alles auswählen

<VirtualHost *:443>
Wenn du aus dem *:443 ein aaa.example.conf:443 bzw. bbb.example.conf:443 machst - jeweils in der richtigen vhost-Datei, wird das was.
Das ist so nicht richtig. *:443 ist korrekt hier. Der vhost greift dann, wenn IP(hier *), Port(hier 443) und ServerName/ServerAlias Direktive zutreffen.

Dort wo der Stern steht darf afaik kein Servername stehen.
Außerdem gibt es in der apache2.conf nochmal 2 virtualhost-Direktiven, welche soll er denn nehmen?
Ja. Die vhost Direktiven in der apache2.conf sollten weg. Der erste VHost der greift, bekommt die Anfrage. In irgend einer Form ist das aber schon das Problem hier. Aber ich sehe es noch nicht.
Jede Rohheit hat ihren Ursprung in einer Schwäche.

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 19:15:36

Habe nun die Virtual Host Zeilen aus der apache2.conf entnommen. Es wird aber noch nur die aaa.example.de ausgeliefert... auch wenn ich bbb.example.de aufrufe.

Als Default wird mir aber auch die aaa.example.de genannt.

mludwig
Beiträge: 794
Registriert: 30.01.2005 19:35:04

Re: Apache2 liefert falsche Webseite aus

Beitrag von mludwig » 08.01.2019 19:22:22

Ich bin immer nach Apache Doku gegangen, wonach laut

https://httpd.apache.org/docs/2.4/mod/c ... irtualhost

dort IPs, HostNamen, * oder _default_ stehen dürfen. Ab apache 2.2 steht bei Hostnamen aber not recommended, was mir aber jetzt erst aufgefallen ist. Ansonsten wird wohl zutreffen, was weiter unten auf dieser Seite steht: für die Anfrage wird der am besten passende Host ausgewählt, und zwar anhand von Ziel IP und Port der Anfrage zum dazu am besten passenden VirtualHost. Wenn es mehrere gibt, kommt der ServerName zum tragen.

Ich nehme an hier kommen anonymisierte (falsche) hostnamen in den Konfigs an, gibt es vielleicht Schreibfehler im Original?

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 19:33:49

Nein Schreibfehler gibt es nicht.

Aus irgendeinem Grund liefert er immer die Alphabetisch erste Seite aus :evil:

FriedrichMS
Beiträge: 13
Registriert: 08.01.2019 10:54:06

Re: Apache2 liefert falsche Webseite aus

Beitrag von FriedrichMS » 08.01.2019 20:08:55

Ich habe die Lösung, ich werde diese morgen in Ruhe zusammenschreiben und mich melden... Vielen Dank erstmal an alle.

Antworten