嗨,我有 3 个 apache 服务器,但有一个入站 IP 和一个端口 80 需要监听。所有端口 80 流量都转到 192.168.1.10。但我想通过 vhost 将某些域(如www.mydomain.co.uk
所需的本地文件夹)发送到服务器外,并将某些域发送到服务器 2(192.168..1.11),这对于域来说wiki.mydomain.co.uk
非常有效,但我还想将所有“备用”未知流量发送到 192.168.1.12,但这并不像我希望的那样有效。
我只想将未列出的流量发送到服务器 192.168.1.12。当我在机器 192.168.1.12 上进行端口检查时,没有任何流量到达。
NameVirtualHost *:80
Alias /errors/ /var/www/html/mydomain/errors/
<VirtualHost *:80>
ServerName www.mydomain.co.uk
DocumentRoot /var/www/html/mydomain/www
ErrorDocument 404 /errors/404error.php
</VirtualHost>
<VirtualHost *:80>
ServerName admin.mydomain.co.uk
DocumentRoot /var/www/html/mydomain/admin
</VirtualHost>
<VirtualHost *:80>
ServerName wiki.mydomain.co.uk
ServerAdmin root@localhost
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://192.168.1.11/
ProxyPassReverse / http://192.168.1.11/
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ErrorLog /var/log/httpd/wiki.mydomain.co.uk.log
CustomLog /var/log/httpd/wiki.mydomain.co.uk.err.log combined
</VirtualHost>
<VirtualHost _default_:80>
ProxyPreserveHost On
ProxyPass / http://192.168.1.12/
ProxyPassReverse / http://192.168.1.12/
</VirtualHost>
apachectl -S
虚拟主机
configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 www.mydomain.co.uk (/etc/httpd/conf.d/ssl.conf:74)
*:80 is a NameVirtualHost
default server www.mydomain.co.uk (/etc/httpd/conf.d/vhost.conf:5)
port 80 namevhost www.mydomain.co.uk (/etc/httpd/conf.d/vhost.conf:5)
port 80 namevhost www.mydomain.co.uk (/etc/httpd/conf.d/vhost.conf:12)
port 80 namevhost admin.mydomain.co.uk (/etc/httpd/conf.d/vhost.conf:18)
port 80 namevhost wiki.mydomain.co.uk (/etc/httpd/conf.d/vhost.conf:23)
答案1
放置默认虚拟主机第一的在配置文件中。
如果未找到与 Host: sent 匹配的内容,则将使用第一个 vhost。对于您来说,这意味着这应该是 top:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://192.168.1.12/
ProxyPassReverse / http://192.168.1.12/
</VirtualHost>
(我删除了“_default_”,因为它是多余的。)