如何将请求路由到不同机器上的 IIS and/or Apache 运行,1 public IP 端口 80

How to route requests to IIS and/or Apache running on different machines , 1 public IP port 80

这是我的设置:

获得域名:domain.com .

在我的本地网络中,我获得了由活动目录框提供的 DNS,

端口 80 上的 IIS Web 服务器 运行,主机名 iis。domain.com, 这有网站 iis1.domain.com, iis2.domain.com

端口 80 上的 Apache Web 服务器 运行,主机名为 apache。domain.com, 使用站点 apache1.domain.com 和 apache2.domain.com.

在我的本地网络中,我可以很好地访问所有这些站点。 我还有 iis1、iis2、apache1 和 apache2 的外部 dns 条目。

我只有一个 public IP 地址,我想设置另一个盒子,它将端口转发到互联网(端口转发端口 80 和 443)。 我想知道在那个盒子上安装什么以及如何配置它。

我看过 nginx、haproxy 和 IIS ARR,但我想知道其中哪些最容易设置且开销最少。

在我看来,我想指定类似...的内容。如果它是对站点 iis1 的请求。domain.com 然后将该请求带到 IIS Web 服务器,如果它是针对 apache1。 domain.com 然后转到 Apache Web 服务器。 我想使用 Linux 解决方案,但我不确定设置哪个以及如何设置它。

提前致谢。

P.S。 我看到了一个可能的解决方案 here

这样的东西行得通吗?

server {

        listen 80 default_server;

        server_name iis1.domain.com;

        location / {
                        proxy_pass http://iis1.domain.com/;
        }

}

server {

        listen 80 default_server;

        server_name apache1.domain.com;

        location / {
                        proxy_pass http://apache1.domain.com/;
        }

}

我会选择 haproxy(我认为最简单)
只是要非常小心你的外部 DNS 和内部 DNS。 您在问题中的示例转发到 dns...。它指向代理(外部)...。它指向 dns...我想您明白我的意思了。

HAProxy 会指向您的后端 IP 地址,因此内部和外部 DNS 都会指向您的代理并正确路由到其预期的后端

HAProxy 配置看起来像这样:

global
    # default globals
defaults
    # default globals
frontend http-in
    bind                        YOUR.IP.GOES.HERE:80
    bind                        YOUR.IP.GOES.HERE:443 ssl crt PATH/TO/CERT-FILE.PEM no-sslv3
    mode                        http
    option                      httplog
    option                      httpclose
    option                      forwardfor

    acl iis1                    hdr(Host) -i iis1.domain.com
    acl iis2                    hdr(Host) -i iis2.domain.com
    acl apache1                 hdr(Host) -i apache1.domain.com
    acl apache2                 hdr(Host) -i apache2.domain.com

    use_backend iis if iis1
    use_backend iis if iis2
    use_backend apache  if apache1
    use_backend apache  if apache2    

 backend iis
        server IIS      xxx.xxx.xxx.xxx:80 check

 backend apache
        server APACHE   xxx.xxx.xxx.yyy:80 check

我设法通过安装一个带有 nginx 的 linux 盒子来真正让它工作。此框的端口 80 被转发到互联网。

在 /etc/nginx 中我添加了一行来查找其他配置文件 -> include /etc/nginx/sites-enabled/*.conf; .

所以在 /etc/nginx/sites-enabled/ 我创建了一个配置文件,其中包含以下信息:

server {
    listen 80;
    server_name apache1.domain.com;
    location /{
        proxy_pass http://apache1.domain.com;
    }
}

server {
    listen 80;
    server_name apache2.domain.com;
    location /{
        proxy_pass http://apache2.domain.com;
    }
}

server {
        listen 80;
        server_name iis1.domain.com;
        location /{
                proxy_pass http://iis1.domain.com;
        }
}

server {
        listen 80;
        server_name iis2.domain.com;
        location /{
                proxy_pass http://iis2.domain.com;
        }
}