Amazon EC2 with Elastic IP - VirtualMin or Cloudmin?

8 posts / 0 new
Last post
#1 Tue, 01/19/2016 - 20:43
dotperformance

Amazon EC2 with Elastic IP - VirtualMin or Cloudmin?

Hi,

I always use VirtualMin on my "normal" VPSes, but am looking at an Amazon EC2 setup, with an Elastic IP.

I have VirtualMin running on it at present, but am having issues with the IPs; in that the public IP where the server, and VirtualMin is accessible is different to the actual Network IP. I cannot assign the public IP to a VirtualHost because 'it doesn't exist' and then within Network Config of VirtualMin I cannot seem to add the public IP because it's not a real IP on the network.

So I came across this:

https://www.virtualmin.com/documentation/cloudmin/vm/ec2-static

Which seems to suggest the solution is available within CloudMin.

Does this mean I need to switch from VirtualMin to CloudMin on this srever? Or can an Amazon Elastic IP be set up in VirtualMin?

I'm not familar with CloudMin at all, compared to VirtualMin which I've used for years.

Thanks in advance Rob

Tue, 01/19/2016 - 21:34
emotler

Hi. You shouldn't need to assign the public IP to a VirtualHost the private one is fine. In the AWS Console map the Elastic Public IP to the running instance and you can then access the Virtualmin server from the public IP.

The public IP is NAT'ed to the private IP of the instance on the VPC. You can set up your VirtualHosts within Virtualmin and they will use the private IP of the instance. Apache will show the private IP. The eth0 interface in Webmin > Networking > Network Configuration > Network Interfaces will also show the private IP, this again is fine.

If you are running BIND 'publicly' make sure that under Virtualmin > System Settings > Virtualmin Configuration > Network Settings that the 'Default IP address for DNS records' is set to 'Other address' and enter the external Elastic Public IP.

If you go to any VirtualHost and look under Server Configuration > Change IP Address you should see that the 'Current IP', 'Shared Address' and 'Real Address' all reflect the private IP. The External Address will have the optional input field showing your Elastic Public IP.

I've been hosting using Virtualmin on EC2 for years without any issues in respect to public / private IP's. On both CentOS 5 and Ubuntu 14.04 at the moment and various other flavours before that!

Go for it.

Wed, 01/20/2016 - 16:15
dotperformance

Hi,

Thanks for the reply.

"You shouldn't need to assign the public IP to a VirtualHost the private one is fine. In the AWS Console map the Elastic Public IP to the running instance and you can then access the Virtualmin server from the public IP."

I can successfully access VirtualMin on the Public IP; this worked fine out of the box.

However the Public IP still is not landing on my newly created VirtualHost - it is still taking me to the default /var/www/html

I have done this:

"Server Configuration > Change IP Address you should see that the 'Current IP', 'Shared Address' and 'Real Address' all reflect the private IP. The External Address will have the optional input field showing your Elastic Public IP."

I've taken some screenshots, please see below.

I've blanked out some parts of the two IPs but to help explain: Private IP = 172.xx.xx.172 Public IP: 52.xx.xx.111

And my virtualhost created is set to sit at /home/virtualhostname/

However, going to the public IP 52.xx.xx.111, I am being sent to the default, which is /var/www/html

Perhaps it's a different issue, as on the public IP on port 80 I DO successfully see the default ubuntu landing page, BUT it's at /var/www/html, and NOT the one VirtualHost I have set up, which is at /home/virtualhostname/public_html -- so somewhere I'm not telling that VirtualHost to be on my public IP. Perhaps as illustrated by the screenshot " View / Edit Virtual Server Info" below, even though the "External IP Address" for this VHost is set to the public one.

Am I missing a step somewhere?

Virtualmin > System Settings > Virtualmin Configuration > Network Settings
Default IP address for DNS = Other ==> Public IP
Screenshot: https://www.dropbox.com/s/xzkqz46etz3admo/networking-settings.png?dl=0

IP Address setting of my VirtualHost:
External IP = Public IP
All other IPs here = Private IP
Screenshot: https://www.dropbox.com/s/jfpp6v3oi0hqher/VH-IP-Address.png?dl=0

View / Edit Virtual Server Info:
IP Address is shown as the Private one
Screenshot: https://www.dropbox.com/s/o1jwfghuar822c2/virtual-server-info.png?dl=0

Many thanks Rob

Wed, 01/20/2016 - 16:16
dotperformance

To note, I am currently wishing to access my new VirtualHost on the Public IP address only, not via a domain, i.e. 52.xx.xx.111:80

Fri, 01/22/2016 - 21:45
emotler

Hi,

OK I think I see what you're trying to achieve. The 3 images all look good by the way, as I'd expect to see them for a server running virtual hosts with a private IP in a VPC and with a public Elastic IP.

If you browse to your server via the public IP only I'd expect it to point to the /var/www/html/ dir this is the default in apache2. That's what it should be doing.

I don't think that the NAT (Network Address Translation) has anything to do with this. Your public and private IP's aren't the issue, they are just doing what they are supposed to, and Apache is listening for a host to map to.

If you want the public IP to translate to a virtual host then you need to change the path of the default host in Apache. The problem with this is that you will immediately get issues with all the things that Virtualmin is good at sorting out. Such as all the Apache directives and modules. That's not something that I'd get involved in, although it's perfectly possible. It's essentially an Apache config issue as I see it.

Virtualmin does what it says, it sets up Virtual Hosts. For your purposes would you be better off just installing a LAMP stack on a static server?

Ed.

Fri, 01/22/2016 - 22:01
Joe
Joe's picture

Getting /var/www/html indicates you don't have any VirtualHosts that match the internal IP and port on which the request is coming in. You also probably want to just get rid of the DocumentRoot directive outside of a VirtualHost section (by default this points to /var/www/html on a CentOS system, but shouldn't on a system installed using our install script, as it should remove that, I think). Regardless of that directive though, once you configure a VirtualHost (using Virtualmin) it should Just Work and should override the DocumentRoot with the right one for the VirtualHost that matches the name, IP, and port.

And, to answer your question about Cloudmin: No. You don't need Cloudmin. It manages virtual machines, cloud computing resources, and containers. It is not related to Apache configuration at all (Cloudmin does not manage websites).

--

Check out the forum guidelines!

Wed, 01/27/2016 - 11:46
dotperformance

Hi,

Thanks for the replies.

I have checked the VirtualHost setup (as per https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-vi...) and it's looking correct; we have the /etc/apache2/sites-available/mysite.conf file, with the correct document root, and apache has been restarted.

Do I somewhere need to add my public/external IP into the VirtulHost file or ports.conf file?

The mywebsite.conf opens with:

The wildcard should allow any host right?

/etc/apache2/ports.conf reads:

Listen 80 Listen 443

So all looks totally correct to me; just suggesting I need to add this external/public IP into a setting somewhere, but not sure where.

Any further guidance would be most appreciated. Thanks

Wed, 01/27/2016 - 12:08
dotperformance

Hi

Solved.

Further to the above, the issue was actually just the "default virtualhost" - I can access the VirtualHost I am after on the server's public IP IF I use a local host file entry, confirming all is working as it should. Awesome.

I had previously set this virtulhost to the "default for this IP" (Server Config / Website Options) but it didn't work... just went through the process again to set this, and it worked!

Awesome.

Thanks

Topic locked