/ mozey.co / blog

ec2 multiple ssl virtualhosts

July 1, 2015

EC2 allow you to setup Multiple Private IP Addresses

🔗 Each virtual HTTPS virtual host must listen on its own private IP address



🔗 Associate a public Elastic IPs with each private IP used by the instance

🔗 Setup networking on the instance to recognize all required interfaces

For Ubuntu 14.04

ifconfig -a

cd /etc/network/interfaces.d

sudo cp eth0.cfg eth1.cfg

sudo vi eth1.cfg

sudo ifup eth1

ifconfig -a

🔗 Setup routing for the second interface

Multiple IP addresses on Amazon EC2

provide a different route for the second ip

Print routing table


This returns the instance public IP

curl --interface ifconfig.me

This does not return anything and should timeout

curl --interface ifconfig.me

Apache virtual hosts seems to be up and running correctly:



Add the route

sudo ip rule add from table default

sudo ip route add default via dev eth1 table default

sudo ip route flush cache