简体   繁体   English

设置虚拟主机以重定向到多个Web服务器(Apache)

[英]Set virtual host for redirect to multiple web server (apache)

Don't know what the perfect title for this, but here it is. 不知道什么是完美的标题,但这就是它。

I'm running a server with Windows Server 2008 R2. 我正在使用Windows Server 2008 R2运行服务器。

On this server I have three webapps and it already run well 在此服务器上,我有三个Web应用程序,并且已经运行良好

  1. App1 using Apache2 on port 80 在端口80上使用Apache2的App1
  2. App2 using IIS on port 81 App2在端口81上使用IIS
  3. App3 using Xampp Apache on port 83 在端口83上使用Xampp Apache的App3

I already have a domain for each port 1. domain1.com for port 80 2. domain2.com for port 81 3. domain3.com for port 83 我已经为每个端口1拥有一个域。端口80的domain1.com 2.端口81的domain2.com 3.端口83的domain3.com

all domain has been pointing to server, and it is work fine when I use (:port) behind the domain, eg. 所有域都指向服务器,例如,当我在域后使用(:port)时,它工作正常。 domain1:83 is already open Xampp Apache on port 83. domain1:83已在端口83上打开Xampp Apache。

however, what I need is when I type domain1.com it should open port 80, domain2.com it should open port 81, and domain3.com should open port 83. 但是,我需要的是,当我键入domain1.com时,它应该打开端口80,domain2.com它应该打开端口81,domain3.com应该打开端口83。

Simple say, I don't need to add :81 or :83 if I want to open those sites. 简而言之,如果要打开这些站点,则无需添加:81或:83。

Main apache server used are Apache2, and I need configuration to automatically when I type domain2.com it goes to port 81 (localhost:81), and so if I type domain3.com it goes to port 83 (localhost:83) 使用的主要的Apache服务器是Apache2,当我键入domain2.com时,它需要自动配置以访问端口81(localhost:81),因此,如果键入domain3.com,则将其配置到端口83(localhost:83)。

Meaning is, that Apache2 only handle App1 on port 80, when I want to access App2 using domain2.com then it refer to localhost:81 then the process will be handled by IIS, and so for App3 using domain3.com it refer to localhost:83 then Xampp will handle the process. 意思是,Apache2仅在端口80上处理App1,当我想使用domain2.com访问App2时,它引用localhost:81,那么该进程将由IIS处理,因此对于使用domain3.com的App3,它引用localhost。 :83然后Xampp将处理该过程。

Every Apps has different config so I cannot put it to single port 80 then difference it by DocumentRoot since other Apps are not processed by Apache2. 每个应用程序都有不同的配置,因此我无法将其放在单个端口80上,然后由DocumentRoot进行更改,因为其他应用程序未由Apache2处理。

Regards, 问候,

Set up a name-based virtual host support on Apache. 在Apache上设置基于名称的虚拟主机支持 It is handling port 80, so it will handle all requests to port 80, no matter what port number is used. 它正在处理端口80,因此无论使用哪个端口号,它都将处理对端口80的所有请求。

You then have two options. 然后,您有两个选择。

  • Redirect 重定向
  • Proxy 代理

You can redirect the traffic to the other port (which will show the port number in the address bar of the browser, and cause search engines to index URLs with that port number in them) 您可以将流量重定向到另一个端口(该端口将在浏览器的地址栏中显示该端口号,并使搜索引擎为其中包含该端口号的URL编制索引)

Redirect / http://domain2.com:81/

Or you can proxy the traffic through Apache (which will relay everything through Apache, which could have performance implications): 或者,您可以通过Apache代理流量 (它将通过Apache中继所有内容,这可能会对性能产生影响):

ProxyPass "/"  "http://domain2.com:81/"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM