(1 of 4) Amazon ELB Multi-domain SSL forwarding to NGINX and Play Servers

Posted on Wednesday, April 10, 2013

(1 of 4 Install Scala and Play on Ubuntu 12.10)

This guide goes over setting up an ELB with a multi-domain
SSL certificate. The servers attached to
the ELB will run multiple Play servers on different ports with an nginx server
running in front of them to handle routing based on domain/subdomain names.

I know that is quite a mouthful but here is what I am trying
to accomplish….

I want to run more than one Play Server on an ec2
instance. Each Play Server will run on
its own port. I want to have a domain
name to route to a specific Play server.
Ex. www.example.com routes to the
Play server running on port 9000 and
www2.example.com routes to the Play server running on port 8000. In addition I want all the communication to
be secure using ssl certificates.

For an individual server you could simply put a nginx server
in front of the Play servers and have the nginx handle routing based on domain
name. But, in this case I want to add an
AWS ELB (Elastic Load Balancer) in front of several EC2 machines.

Here is what I have found out thus far. The ELB can handle the ssl certificate, but
it can only have one certificate per ELB.
This forces you to use a multi-domain SSL certificate. Also the ELB cannot port forward based on
domain name so you still need an nginx server in front of the Play servers.

I want something like this.
The ELB handles the certificate and the nginx server handles the domain
name routing.

Installing Scala Play on Ubuntu 12.10

I am going to install Scala play on an ubuntu 12.10
instance.

From the command line you could run the
following

> sudo apt-get
install scala

If you do this on Ubuntu 12.10
you get Scala 2.9.2 using OpenJDK

That is all well and good but I
would rather use Java 1.7 from Sun and the latest scala build 2.10.0 so to do
that install you need to first install java 1.7 to do that run the following
commands

> sudo apt-get purge openjdk*

> sudo apt-get install python-software-properties

> sudo add-apt-repository
ppa:webupd8team/java

> sudo apt-get update

> sudo apt-get install oracle-java7-installer

> java -version

.

Run the following command to
download the .tgz file from scala and untar it