I need to have different IP addresses pointing to an specific ip address and port on a EC2 instance, where i have running multiple sites on Apache virtual hosts
For example:
xx.xx.xx.xx -> 107.22.56.213:8080
yy.yy.yy.yy -> 107.22.56.213:8081
Is this posible on AWS?
EDIT 1:
Ok I have attached two different IP addresses to a single instance. But I am having problems configuring the reverse proxy, my 000-default.conf it is like this:
<VirtualHost 54.158.187.139:80>
ProxyPass / 127.0.0.1:8080
ProxyPassReverse / 127.0.0.1:8080
</VirtualHost>
<VirtualHost 35.153.37.243:80>
ProxyPass / 127.0.0.1:8081
ProxyPassReverse / 127.0.0.1:8081
</VirtualHost>
But it is still showing the default 000-default site, and I have already restarted the apache2 service
2
Answers
You can attach multiple elastic network interfaces on your ec2 server and attach each ENI with elastic IP, you can configure your aoache virtual to listen to specific IP and specific port:
This is a very useful blog
https://aws.amazon.com/blogs/aws/multiple-ip-addresses-for-ec2-instances-in-a-virtual-private-cloud/
https://vannstudios.com/how-to-set-up-multiple-elastic-ip-for-amazon-ec2-instance
for Proxy the URL below has a similar case to you:
https://serverfault.com/questions/557478/apache-reverse-proxy-forwarding-different-source-ip-ranges-to-different-destinat
I know it is not 100% what you asked, but it’s easy to put a NGINX server in front of Apache one, and it performs better most of the time.
Nginx config (with caching) is as simple as …
I did this with many of my servers and it works nicely, and at your source server, you can specify cache headers, so that the upper NGINX server will cache them for as long as you specify:
With a similar config, my stats show pages load in 0.250 seconds, from 0.800 seconds.