VHOST problem auf apache2

Debian macht sich hervorragend als Web- und Mailserver. Schau auch in den " Tipps und Tricks"-Bereich.
Antworten
heinzelrumpel
Beiträge: 159
Registriert: 26.07.2004 20:07:58

VHOST problem auf apache2

Beitrag von heinzelrumpel » 03.09.2022 17:04:18

Hi zusammen,

habe einen Vodafone Kabel Business Anschluss mit fester IP, also dachte ich mir, kann ich meine Website auch darüber in einer DMZ hosten. Apache2 installiert, vhost Konfig erstellt, dann via Letsencrypt Zertifikat geholt. Alles gut soweit. Nun wollte ich das gleiche für eine 2. Domain auf dem gleichen Server machen, also wieder vhost konfig erstellt, via a2ensite enabled, aber noch kein LetsEncrypt. Rufe ich die 2. Domain im Browser auf ( egal welcher) dann findet immer ein redirect auf die erste Domain via SSL statt. Hier mal meine Konfigs:

Domain1:

Code: Alles auswählen

<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.

        ServerAdmin postmaster@domain.net
        DocumentRoot /var/www/html/domain1/

        # 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
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain1.de [OR]
RewriteCond %{SERVER_NAME} =www.domain1.de
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Domain 1 SSL:

Code: Alles auswählen

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # 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.

        ServerAdmin postmaster@domain.net
        DocumentRoot /var/www/html/domain/

        # 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


ServerName www.domain.de
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias domain.de
SSLCertificateFile /etc/letsencrypt/live/www.domain.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.domain.de/privkey.pem
</VirtualHost>
</IfModule>





Domain2:

Code: Alles auswählen

<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 domain2.gratis
        ServerAlias www.domain2.gratis
        ServerAdmin postmaster@domain1.net
        DocumentRoot /var/www/html/domain2.gratis

        # 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>


Hier die aktivierten Sites:

Code: Alles auswählen

lrwxrwxrwx 1 root root   36 Aug  7 19:53 002-domain1.conf -> ../sites-available/002-domain1.conf
lrwxrwxrwx 1 root root   53 Aug 19 18:12 002-domain1-le-ssl.conf -> /etc/apache2/sites-available/002-domain-le-ssl.conf
lrwxrwxrwx 1 root root   40 Sep  3 15:02 003-domain2.gratis.conf -> ../sites-available/003-domain2.gratis.conf


Puh, keine Ahnung was los ist. Im DNS hab ich jeweils @ auf die Vodafone IP und www als Host A ebenfalls auf die IP. Von der Vodafone Fritzbox habe ich Port80 und 443 an meine Pfsense weitergeleitet. Dahinter ist die u.A. DMZ

Wer hat einen Tipp für mich?

ciao, heinzelrumpel

Benutzeravatar
debilian
Beiträge: 1162
Registriert: 21.05.2004 14:03:04
Wohnort: 192.168.43.7
Kontaktdaten:

Re: VHOST problem auf apache2

Beitrag von debilian » 03.09.2022 20:06:04

und wie möchtest du die Domains aufrufen?
also unter welchem Namen, du brauchst ja entweder hosts Einträge oder 2 DNS Einträge zu je der jeweiligen Domain..
-- nichts bewegt Sie wie ein GNU --

AxelMD
Beiträge: 1350
Registriert: 15.03.2009 08:02:11

Re: VHOST problem auf apache2

Beitrag von AxelMD » 03.09.2022 23:20:39

Hallo heinzelrumpel,

nach welcher Anleitung bist Du für deine Apache2 vhost bist Du vorgegangen?

Hast Du davor auch einen Reverse Proxy in Betracht gezogen?

Was genau ist deine DMZ, wie hast Du die eingerichtet?

Welche Domains willst Du routen?

MfG
AxelMD

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

Re: VHOST problem auf apache2

Beitrag von bluestar » 03.09.2022 23:51:20

In deiner Domain1 / 80 Konfig fehleb die Optionen ServerName domain1.de und ServerAlias www.domain1.de

AxelMD
Beiträge: 1350
Registriert: 15.03.2009 08:02:11

Re: VHOST problem auf apache2

Beitrag von AxelMD » 04.09.2022 00:11:34

bluestar hat geschrieben: ↑ zum Beitrag ↑
03.09.2022 23:51:20
In deiner Domain1 / 80 Konfig fehleb die Optionen ServerName domain1.de und ServerAlias www.domain1.de
Wie muss die Konfig konkret aussehen?
In welchem Pfad liegt die Konfig?

/Dateipfad/...../..../*.conf

Code: Alles auswählen

So dann die Datei anzeigen.
Apache2
Apache HTTP Server Version 2.4
Die Verwendung von namensbasierten virtuellen Hosts
https://httpd.apache.org/docs/2.4/de/vh ... based.html
Zuletzt geändert von AxelMD am 04.09.2022 00:13:42, insgesamt 1-mal geändert.

heinzelrumpel
Beiträge: 159
Registriert: 26.07.2004 20:07:58

Re: VHOST problem auf apache2

Beitrag von heinzelrumpel » 04.09.2022 11:00:17

bluestar hat geschrieben: ↑ zum Beitrag ↑
03.09.2022 23:51:20
In deiner Domain1 / 80 Konfig fehleb die Optionen ServerName domain1.de und ServerAlias www.domain1.de
Danke. Das wars. Hab ich voll übersehen. Wie peinlich

AxelMD
Beiträge: 1350
Registriert: 15.03.2009 08:02:11

Re: VHOST problem auf apache2

Beitrag von AxelMD » 04.09.2022 21:54:07

https://wiki.ubuntuusers.de/Apache/Virtual_Hosts/

Beispiel

So würde eine funktionierende Virtual Host Konfiguration aussehen.

Code: Alles auswählen

<VirtualHost *:80>
        ServerName maxisforum.example.com     
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/maxisforum/
        <Directory /var/www/maxisforum/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Require all granted
        </Directory>
        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
</VirtualHost>

VirtualHost

Die einzelnen Dateien in /etc/apache2/sites-available/<optionaler prefix>-<virtualhostname>.conf :

Code: Alles auswählen

<VirtualHost *:80>
.
.
.
</VirtualHost>
Das waren die Antworten auf meine Fragen.
Danke

MfG
AxelMD

Antworten