Search code examples
apacheamazon-web-servicesplayframeworkvirtualhostbitnami

Configure Apache to serve different play applications on single domain


I have three applications implemented with Play! framework. I would like to run these apps on a single domain but different urls.

For example:

  • First app: www.example.com
  • Second app: www.example.com/second
  • Third app: www.example.com/third

I am using an AWS Bitnami LAMP stack and I am trying to configure Apache virtual hosts to run the applications on different ports(9000, 9001, 9002). Running a single app works fine but not all three at the same time.

Here's what I have so far for just one app:

<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>

Is the Apache virtual hosts the way to go or is there a better solution?


Solution

  • Yes, you can use Apache to serve on single domain using Proxy hosts.

    But you need to define in correct hierarchy.

    For given Example: You need to define Second app and Third app before defining First app. Else www.example.com/second will detect as www.example.com and redirect to First app.