I've been setting up Amazon EC2 instances for an upcoming project which will involve hosting multiple websites on multiple web servers. They are all micro instances, running Ubuntu Server 64bit.
Here's what I have so far:
- Web Server -- Apache
- Database Server -- MySQL
- Development Server -- Apache & MySQL
- File Server -- SVN & Bacula (backups are done to S3 buckets)
Currently there's only one Web server, but I've made an image of it, so once the project starts I can launch as many instances as I need and configure them individually.
Everything has been going smoothly, but I've hit some snags.
My problem is I'd like to run multiple web server instances, but with Amazon's restriction to 5 Elastic IP address, I know that won't be enough. I was researching how to host websites on multiple web servers from a single IP address and ran across mod_proxy for Apache. I haven't tried it yet, but I think that's what I need. I'd just like someone to confirm that I'm on the right track.
Has anyone used Apache with mod_proxy? Does it truly allow you to host multiple websites from multiple using a single IP address?
Assuming I'm on the right track here, all I should need is one Elastic IP address pointing to an EC2 instance running Apache, is that right?
what you asked is a very common situation where in applications may not be running on Gateway and they may be running on some server in LAN but to the world it appears it is coming from requested_url.com
I run 4 websites with Apaches mod proxy and at least 15 different services on these 4 different websites depend upon them.I do not have an experience of Amazon EC2 but Amazon EC2 uses Xen as its backend. Let us say the main machine which faces internet and has a public IP be called dom0 now read in the following terminology
I am assuming you have a local dns on Dom0 (or some where in your network ) which knows the DomU IPs with names.(If not life will be difficult) then in apache2.conf ( httpd.conf on Fedora type systems)
This way is one way to achieve the things which you asked (how ever not very recommended) if you upgrade the server (i.e. Dom0) the update may over write apache2.conf or httpd.conf what ever be the case. So once you understand what the above entries mean (Check it for your requirements I have struggled a long time back with some thing similar you want hence I gave an easy solution but not recommended). Once you understand the above ProxyPass then create different Virtual Host configurations in sites-available directory if it is a Ubuntu/Debian system or in Red Hat based it will be still possible (you will have to search) I am showing you one so it helps you rest 4-5 you can make on your own
Call this /etc/apache2/sites-enabled/myinterna1.conf it looks as follows
The above virtualhost will be defined on Dom0 so that all requests are served from an internal server server1.com.The way it will work is some one on internet will type in their browser
Now this request reaches Dom0 and Apache Virtual Host on Dom0 checks the Proxy Configuration and finds that /domu1 is mapped to an internal server so it forwards that to the machine which actually has to serve.To the user on internet all this is hidden.
How ever one word of caution while doing so the Apache on Ubuntu system serves the virtual hosts in alphabetical name of vhost file (not server name I am referring to name of file like sorting.c the Apache virtual host file) (that is why there is a file 000-default) on Ubuntu systems so make sure that you have one host more than the number of websites you are to serve (which will serve as error page).This is a standard practise.
Why not run them all on the same IP address and use Apache virtual hosting (i.e. Host-header based virtual hosting) to have the web server select the right site on a per-request basis?
That would only consume one IP address and Amazon's load balancing could do the rest.