mod_proxy & vhosts

Apache, Lighttpd, nginx, Cherokee
Post Reply
tadam
Posts: 4
Joined: 2005-11-08 12:29
 

mod_proxy & vhosts

Post by tadam »

Hi,

ich hätte mal eine Frage zu Apache und dem mod_proxy in Verbindung mit vHosts:
Angenommen auf einem Host A läuft Apache mit dem mod_proxy und schickt Anfragen an eine bestimmte Domains weiter an einen Host B.

Host A Konfiguration:

Code: Select all

<VirtualHost *:80>
  ServerName bla.xyz.de
  ServerAlias blo.xyz.de, blu.xyz.de
  ProxyPass / http://10.0.0.11/
</VirtualHost>
In diesem Fall hätte Host B für die Domains jeweils einen virtuellen Host am laufen. Doch irgendwie funktioniert das nicht. Die weitergeleitete Anfrage an Host B wird immer an den "default" vhost geleitet. Leider geht aus den Host B logs nichts anormales hervor.
Jetzt meine Frage:
Fehlt mir was in der mod_proxy Konfiguration des Host A, oder stimmt irgendwas mit der Host B Konfiguration nicht?

Host B:

Code: Select all

NameVirtualHost *

<VirtualHost *:80>
  ServerName bla.xyz.de
  DocumentRoot /bla
  <Directory />
   AllowOverride All
   Order deny,allow
 </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName blo.xyz.de
  DocumentRoot /blo
  <Directory />
   AllowOverride All
   Order deny,allow
 </Directory>
</VirtualHost>

...

Code: Select all

$ httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server bla.xyz.de (/usr/local/etc/apache2/httpd.conf:1070)
         port 80 namevhost bla.xyz.de (/usr/local/etc/apache2/httpd.conf:1070)
         port 80 namevhost blo.xyz.de (/usr/local/etc/apache2/httpd.conf:1079)
Syntax OK

:)
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: mod_proxy & vhosts

Post by Joe User »

Beide Configs sind OK und werden korrekt verarbeitet.

Hint: Dein Denkfehler liegt auf Host A...
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
jamiewolf
Posts: 43
Joined: 2003-01-12 05:09
Contact:
 

Re: mod_proxy & vhosts

Post by jamiewolf »

Um die Port fehler weg zu bekommen änder mal:

Code: Select all

NameVirtualHost * 
nach

Code: Select all

NameVirtualHost *:80
Ansonsten kann ich dir leider nicht weiterhelfen :)
tadam
Posts: 4
Joined: 2005-11-08 12:29
 

Re: mod_proxy & vhosts

Post by tadam »

Joe User wrote:Beide Configs sind OK und werden korrekt verarbeitet.

Hint: Dein Denkfehler liegt auf Host A...
äh, ja ...?! Aber wenn beide Configs in Ordnung sind, was stimmt dann nicht?! %)

Code: Select all

Um die Port fehler weg zu bekommen
Welche Port-fehler?
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: mod_proxy & vhosts

Post by Joe User »

tadam wrote:Aber wenn beide Configs in Ordnung sind, was stimmt dann nicht?!
Deine Denkfehler (ja, es sind mehrere) liegen in diesen beiden Zeilen:

Code: Select all

  ServerAlias blo.xyz.de, blu.xyz.de
  ProxyPass / http://10.0.0.11/
Zeichne Dir mal die "Wege der Bytes" auf...
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
tadam
Posts: 4
Joined: 2005-11-08 12:29
 

Re: mod_proxy & vhosts

Post by tadam »

hm, ich komm nicht drauf, aber ich habe zumindest das hier gefunden:

Code: Select all

ProxyPreserveHost:
"When enabled, this option will pass the Host: line from the incoming request to the proxied host, instead of the hostname specified in the proxypass line."
und das hier

Code: Select all

The following example allows a front-end machine to proxy a virtual host through to a server running on another machine. In the example, a virtual host of the same name is configured on a machine at 192.168.111.2. The ProxyPreserveHost On directive is used so that the desired hostname is passed through, in case we are proxying multiple hostnames to a single machine.

<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://192.168.111.2
ProxyPassReverse / http://192.168.111.2/
ServerName hostname.example.com
</VirtualHost> 
Aber das ändert nichts :/ ... Jetzt bin ich ganz schön zappelisch: Was sind meine Denkfehler?
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: mod_proxy & vhosts

Post by Joe User »

Einen Denkfehler hast Du ja bereits selbst gefunden/gelöst, ein Weiterer liegt im ServerAlias: Verfrachte die ServerAliase auf Host A in eigene vHosts (analog zu Host B)...
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
tadam
Posts: 4
Joined: 2005-11-08 12:29
 

Re: mod_proxy & vhosts

Post by tadam »

ja, hey, das hat funktioniert :) merci

Aber was ist mit wildcards? Geht das überhaupt in ServerName? Denn in ServerAlias ist das anscheinend zulässig, aber damit kann Host B ja nicht.

Code: Select all

<VirtualHost *:80>
  ServerName *.bla.xyz.de
  ProxyPass / http://10.0.0.11/
  ProxyPreserveHost On
</VirtualHost> 
Komme jetzt leider gerade nicht dazu das auszuprobieren. Aber vielleicht weiß es ja auch jemand so...
Post Reply