I’ve seen the same question some times now on this forum, but I’ll ask it again to see if there are new developments.
I have a very large amazon instance for heavy traffic for one of my websites.
On boot the machine syncs the website and database and places itselfs in the Amazon ELB (loadbalancer), and disables the machine forwarding all the traffic to my static virtualmin machine.
This works perfectly, except for the fact that the IP address given to the machine changes everytime and Virtualmin only works with the previous, static IP.
The solution would off course be to run the Change IP Addresses script on boot automatically.
Is this possible?
While logging into Virtualmin and handling it there is the simplest way to update the IP, that's not automated... Jamie suggested the following code as an automated way of updating the IP:
newip=`hostname -i`
for dom in `virtualmin list-domains --name-only`; do
virtualmin modify-domain --domain $dom --shared-ip $newip
done
You'd want to test all that though -- in particular, you'd want to make sure that "hostname -i" returns your correct Ip address.
After verifying that the above code does what you want (we haven’t tested it on an EC2 system), you could put it in a shell script, and have that shell script run automatically when your system boots up.
awesome. Today I solved a problem BUT also learned the fantastic fact that a whole script enviroment exists for virtualmin!
I cannot fathom, after using webmin/virtualmin for almost 7 years what a great product it is…
this is the final script btw:
#!/bin/bash
newip=hostname -i
for dom in /usr/sbin/virtualmin list-domains --name-only; do
/usr/sbin/virtualmin modify-domain --domain $dom --shared-ip $newip
done