Apache:从两个不同的位置和端口提供内容

Apache: Serving content from two different locations and ports

我在 Ubuntu 14 上有一个 Apache 服务器 运行,在我有 sudo 的服务器上。

当用户请求服务器的 IP 时,Apache 提供来自 /var/www/html 的内容。

我想保持这种行为不变,并让请求 IP/cats 的用户获得一些由端口 7777 上的 Docker 容器托管的特殊内容。

在 Apache 中实现此功能的最佳方法是什么?

感谢@arkascha,我做了以下事情来实现这一目标:

创建一个文件/etc/apache2/sites-available/wow.conf,内容如下:

<VirtualHost *:*>
  # enable proxies
  ProxyPreserveHost On
  ProxyPass /cats http://0.0.0.0:7777/
  ProxyPassReverse /cats http://0.0.0.0:7777/

  ServerAdmin douglas.duhaime@yale.edu
  DocumentRoot /var/www/html

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这表示当请求进入 IP/cats 时,为用户提供来自端口 7777 的内容。

然后我将该文件符号链接到 sites-enabled 目录:

sudo ln /etc/apache2/sites-available/wow.conf /etc/apache2/sites-enabled/wow.conf

最后,我需要删除默认站点启用文件并重新启动服务器:

sudo rm /etc/apache2/sites-enabled/000-default.conf
sudo service apache2 restart

P.S。 Apache 很棒。