Apache:将特定的URLredirect到不同端口上的本地服务器

这看起来很简单,但是我不能使它工作。

我有一个漂亮的web服务器,只需要做两件事情:

  1. example.com/status.html返回一个本地文件(这个工作)
  2. example.com/atom在端口4000上redirect运行在同一台计算机上的防火墙服务器的内容

这不起作用:

RewriteRule ^$ http://localhost:4000 

从请求者的angular度(即在客户端的机器上)将stream量重新定向到localhost:4000。

我对VirtualHost的有限理解表明,这对于像atom.example.com,而不是example.com/atom

我想我必须使用ProxyReverse,但我找不到合适的组合。

更新:尝试由Shane Madden给出的ProxyPass / ProxyReversebuild议在错误日志文件中产生:

 [Thu Mar 15 11:59:15 2012] [error] (13)Permission denied: proxy: HTTP: attempt to connect to 127.0.0.1:4000 (localhost) failed [Thu Mar 15 11:59:15 2012] [error] ap_proxy_connect_backend disabling worker for (localhost) [Thu Mar 15 11:59:17 2012] [error] proxy: HTTP: disabled connection for (localhost) 

(本地服务器肯定在127.0.0.1:4000上运行)

除非你有理由这样做,否则不要使用mod_rewrite。

试试这个(把它放在<VirtualHost>块中):

 ProxyPass /atom http://127.0.0.1:4000/atom ProxyPassReverse /atom http://127.0.0.1:4000/atom