2016-04-03 12 views
0

Ich habe ein Problem in Bezug auf Apache 2.4 und es ist VirtualHost-Konfiguration.Apache ignoriert mehrere ServerName-Anweisungen für Subdomains

bekam ich eine Sub-Domain sub.example.com und subsubdomain static.sub.example.com. Ich versuche, verschiedene DocumentRoots zuzuweisen, aber mit meiner Konfiguration unten führt es nur zu /var/www/html/.

<VirtualHost *:80> 
    ServerName sub.example.com 
    DocumentRoot /var/www/html/ 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName static.sub.example.com 
    DocumentRoot /var/www/html/static/ 
</VirtualHost> 

Was mache ich falsch?

Zusätzliche Informationen: Config oben ist in einer Datei /etc/apache2/sites-available/000-default.conf und natürlich aktiviert (standardmäßig). Alle anderen Konfigurationen haben keine Standardeinstellungen. Server läuft unter Ubuntu 14.04.

Ich fand this solution, aber es hat leider nicht für mich funktioniert.

Update: Ausgabe von apachectl -S:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message 
VirtualHost configuration: 
*:80     is a NameVirtualHost 
    default server sub.example.com (/etc/apache2/sites-enabled/000-default.conf:1) 
    port 80 namevhost sub.example.com (/etc/apache2/sites-enabled/000-default.conf:1) 
    port 80 namevhost static.sub.example.com (/etc/apache2/sites-enabled/000-default.conf:6) 
ServerRoot: "/etc/apache2" 
Main DocumentRoot: "/var/www" 
// Some more lines that are not related I think 

Update: zusätzliche Informationen für die Lösung zu finden:

Ich habe einen Reverse-Proxy vor meinem Webserver läuft. Auszug aus 000-default.conf von Reverse-Proxy (auch Apache 2.4):

ProxyPass    /  http://webserver/ nocanon 
ProxyPassReverse  /  http://webserver/ 
+0

Alle anderen Virtual arbeiten? Es scheint, dass Sie die vhost-Funktionalität überhaupt nicht aktiviert haben. – DevilaN

+0

Ich denke schon, ja. Ich habe meinen Beitrag mit der Ausgabe von 'apachectl -S' aktualisiert. – Alex

+0

Stellen Sie sicher, dass Ihre Datei in der httpd.conf-Include-Anweisung enthalten ist (sie befindet sich normalerweise am Ende der Datei) – DevilaN

Antwort

0

Hinzufügen Option ProxyPreserveHost zu Proxy-config Reverse tut das Geschäft:

ProxyPreserveHost  On 
ProxyPass    /  http://webserver/ nocanon 
ProxyPassReverse  /  http://webserver/