Apache地图端口到URL

假设我有一个在3000端口上运行的Web服务器,所以example.com:3000和80上的另一个,所以:example.com

是否有可能将example.com/map映射到example.com:3000?

我想将目录映射到不同的Apache安装的不同端口,但我想隐藏3000号码。

谢谢。

  1. 您可以使用mod_proxy来匹配URL并将连接代理到端口3000
  2. 如果你不需要完全抽象端口3000,你可以使用mod_rewrite来匹配URL,并将其重写为端口3000上的apache将提供的服务。

使用在端口3000上侦听的HTTP代理。如果您尝试使用重写器,它将强制客户端redirect,这不会是您以后的情况。

我知道你可以将虚拟主机映射到不同的站点,如examlple1.com和example2.com – 这只是在虚拟主机,这很容易。

Listen 80 Listen 8080 NameVirtualHost 172.20.30.40:80 NameVirtualHost 172.20.30.40:8080 <VirtualHost 172.20.30.40:80> ServerName www.example1.com DocumentRoot /www/domain-80 </VirtualHost> <VirtualHost 172.20.30.40:8080> ServerName www.example1.com DocumentRoot /www/domain-8080 </VirtualHost> <VirtualHost 172.20.30.40:80> ServerName www.example2.org DocumentRoot /www/otherdomain-80 </VirtualHost> <VirtualHost 172.20.30.40:8080> ServerName www.example2.org DocumentRoot /www/otherdomain-8080 </VirtualHost> 

但是如果你想把一个子目录映射到不同的端口上,我不认为你可以在后端没有URL Rewriting的情况下这样做,所以他们不知道它发生了 – 它不会很干净。 如果您将其设置为像map.example.com这样的子域名,则可以相对轻松地完成此操作

我想最简单的方法是有两个虚拟主机。

 Listen 80 Listen 3000 <VirtualHost abcd:80> DocumentRoot /html </VirtualHost> <VirtualHost abcd:3000> DocumentRoot /html/map </VirtualHost>