配置 Apache 以在单个域上为不同的播放应用程序提供服务

Configure Apache to serve different play applications on single domain

我用 Play 实现了三个应用程序!框架。 我想 运行 这些应用程序在一个域但不同的 url 上。

例如:

我正在使用 AWS Bitnami LAMP 堆栈,我正在尝试将 Apache 虚拟主机配置为 运行 不同端口(9000、9001、9002)上的应用程序。 运行 一个应用程序可以正常工作,但不能同时使用所有三个应用程序。

以下是我目前只有一个应用程序的情况:

<VirtualHost *:80>
  ServerAdmin www.example.com
  ServerName www.example.com
  ServerAlias "/opt/bitnami/apps/first/data"
  DocumentRoot "/opt/bitnami/apps/first/data"

  Include "/opt/bitnami/apps/first/conf/httpd-app.conf"

  ProxyPreserveHost On
  ProxyPass / http://127.0.0.1:9000/ KeepAlive=On timeout=600
  ProxyPassReverse / http:127.0.0.1:9000/
</VirtualHost>

A​​pache 虚拟主机是可行的方法还是有更好的解决方案?

是的,您可以使用 Apache 在使用代理主机的单个域上提供服务。

但您需要在正确的层次结构中定义。

对于给定的示例:您需要在定义第一个应用程序之前定义第二个应用程序和第三个应用程序。否则 www.example.com/second 将检测为 www.example.com 并重定向到 First app.