主机:1 个 Windows、1 个 Linux、1 个 Internet IP 地址。如何操作?

主机:1 个 Windows、1 个 Linux、1 个 Internet IP 地址。如何操作?

我有 1 个互联网 IP 地址。

我有 2 个物理网络服务器。

1 个 Windows IIS7 托管3网站。主机头名称在 IIS7 中配置。这可以正常工作,直到我添加:

1 Linux (Ubuntu lucid) Apache2 托管 1 个网站。VirtualHost 在 Apache2 中配置。我遵循以下步骤:http://ubuntu-tutorials.com/2008/01/09/setting-up-name-based-virtual-hosting/

这两台服务器似乎在“拉锯战”。这可能是配置错误,还是这种设置会导致问题?

答案1

一种可能的解决方案是将外部 IP 地址提供给 Ubuntu 系统并使用其 Apache 作为 IIS7 服务器的反向代理。

为 IIS 服务器上的每个主机创建一个虚拟主机,例如/etc/apache2/sites-avilable/iisproxyhosts

<VirtualHost *:80>
        ServerName IIS.Domain1.TLD      
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass / http://AddressOfIIServer/
        ProxyPassReverse / http://AddressOfIIServer/
</VirtualHost>

<VirtualHost *:80>
        ServerName IIS.Domain2.TLD      
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass / http://AddressOfIIServer/
        ProxyPassReverse / http://AddressOfIIServer/
</VirtualHost>

<VirtualHost *:80>
        ServerName IIS.Domain3.TLD      
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass / http://AddressOfIIServer/
        ProxyPassReverse / http://AddressOfIIServer/
</VirtualHost>

启用代理

a2enmod proxy_http
a2enmod proxy

启用 iisproxyhosts 并重新启动 apache

a2ensite iisproxyhosts
/etc/init.d/apache2 reload

答案2

基于名称的虚拟托管仅在所有虚拟主机都运行在同一个 Web 服务器实例上时才有效。在这种情况下,您需要使用 NAT 让两台机器都连接到网络,并配置 NAT 盒以将非标准端口的连接转发到其中一个盒,或者安排其中一个 Web 服务器代理另一个(基于名称的虚拟托管将可用于调用代理)。或者只需购买另一个 IP 地址。

答案3

Microsoft TMG Server 作为这两台服务器前面的防火墙,可以在一个公共 IP 地址上托管多个 Web URL,并使用 NAT “反向代理”到其后面的多个主机。简单的解决方案是获取另一个公共 IP,正如 @geekosaur 所说。

答案4

您有一台具有公共 IP 的服务器,Apache 正在其上运行。现在您想在 LAN 上托管您的应用程序,并希望它们可以在互联网上访问,重要的是这些应用程序仍在 LAN 上的机器上运行。对于这种情况,需要反向代理。以下是此类设置的一些说明

假设网站是:

a)internal1.example.com 应该映射到 internal1.example.com
b)internal2.example.com 应该映射到 internal2.example.com
c)internal3.example.com 应该指向 internal3 .example.com
d)internal4.example.com 应该指向 internal4 .example.com

                           |--------------192.168.1.3 
                           |            (internal3.example.com)
                           |
                           |--------------192.168.1.4
                           |            (internal4.example.com)
  (Public IP )             |
            A-------------|
(reverse proxy server)     |
  (192.168.1.25)           |
example.com                |
                           |--------------192.168.1.1
                           |            (internal1.example.com)
                           |
                           |--------------192.168.1.2
                           |            (internal2.example.com)

我使用 Ubuntu 来托管 Apache,如果是基于 Debian 的系统,则 vhost 定义网站是在上图中具有公共 IP 的系统 A 上完成的

/etc/apache2/sites-enabled/internal1.conf  
/etc/apache2/sites-enabled/internal2.conf  
/etc/apache2/sites-enabled/internal3.conf  
/etc/apache2/sites-enabled/internal4.conf  

每个站点的 vhost 定义如下 /etc/apache2/sites-enabled/internal1.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal1.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.1/
      ProxyPassReverse / http://192.168.1.1/
</VirtualHost >

/etc/apache2/sites-enabled/internal2.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal2.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.2/
      ProxyPassReverse / http://192.168.1.2/
</VirtualHost >

/etc/apache2/sites-enabled/internal3.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal3.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.3/
      ProxyPassReverse / http://192.168.1.3/
</VirtualHost >

/etc/apache2/sites-enabled/internal4.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal4.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.4/
      ProxyPassReverse / http://192.168.1.4/
</VirtualHost >

请注意,在上述所有 vhost 定义中,我都删除了日志文件选项。因此,如果您将其应用于生产服务器,请将它们添加到每个 vhost 文件中。以上只是为您提供一个清晰的示例,说明它如何工作。

相关内容