According to the apache docs, when hosting multiple named servers with dynamic IP I should create my virtual hosts on *:80
e.g.
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
Virtualmin doesn’t seem to allow me to create server with * as the IP address.
I can manually edit httpd.conf to change them to * and restarted apache and webmin with list them as being ‘any’ address (like the default virtual host) however when trying to browse to any of the virtual hosts i get ‘Not Found The requested URL was not found on this server’
SO I guess I have two questions.
How do I setup *:80 through virtualmin
Why isn’t it working?
If I use the private 192.168.x.x IP’s for the sites they spring to life, but they are dynamic IP’s hence the need for *:80.
Virtualmin isn’t designed to work with a server that has a dynamic IP for it’s primary interface – could you instead configure your server to pull in it’s IP address using a static IP?
Unfortunately not - I’m using an amazon ec2 instance which issues a new ip each time the server is started.
The server sits behind nat so even though amazon allows me to associate and fixed ip with the server, the server isn’t aware of it.
I presume I’m missing a trick as there is an official virtualmin amazon server image available, but not sure what the difference would be. I thought virtual min was just a front end for apache amongst other things so was hoping I could follow the apache recommendations - but guess not.
I asked Jamie about how someone might handle that situation… and he said that although he had never run into a circumstance where an EC2 instance was issued a new internal IP, that it is indeed possible to work around that.
All you would need to do is change the existing “NameVirtualHost” line in your Apache config.
Currently, it would read “NameVirtualHost x.x.x.x:80” – where .x.x.x.x is your internal IP.
You can instead change that to read “NameVirtualHost *:80”.
When setting that to *:80, Virtualmin will use that for all new VirtualHosts being added to the server.
Starting / stopping a server is convenient way to save costs as you’re only charged for the instance while it is running. Great for testing and dev scenarios.
Amazon EC2 instances with EBS storage have 3 states: running, stopped, terminated:
When a server is terminated the instance, local IP, public ip and disk image are all destroyed.
When a server is stopped the virtual server instance is destroyed, the local and public IP address are released but the disk image is retained.
When a server is started, new local and public IP’s are allocated (its effectively a new server).
When a sever is rebooted everything is retained inlcuding the local ip and public ip.
*:80 working was the missing ingredient to have everything work perfectly in a fully dynamic environment.
The solution above does not work for me. I set the NameVirtualHost *:80 manually. After I create a new Virtualserver, a new directive NameVirtualHost x.x.x.x:80 is automatically added to the conf file.
Nope there are no other NameVirtualHost entries. There is one NameVirtualHost entry, but its commented, even that is #NameVirtualHost *:80
I was looking at the codes and saw that this stuff is Apache version related.
On my server Apache’s Installed version is 1:2.2.3-53.3.vm
Virtualmin version 3.93.gpl GPL
As a temporary fix, I have hardcoded <VirtualHost *:80> in /usr/libexec/webmin/virtual-server/feature-web.pl and commented out && !$no_star_match); in sub add_name_virtual
find /etc/httpd/ | xargs grep -i NameVirtualhost
/etc/httpd/conf/httpd.conf:#NameVirtualHost *:80
/etc/httpd/conf/httpd.conf:# NOTE: NameVirtualHost cannot be used without a port specifier
/etc/httpd/conf/httpd.conf:NameVirtualHost *:80
I’m seeing similar behaviour with Virtualmin 3.93.gpl.
This instance has been working fine for quite some time until recently when it changed the way it defined virtualhosts.
Up until a little while ago (we don’t create too many new servers here so I can’t recall the specific date this changed) all of the VirtualHost blocks were defined as *:80
I’d love to know if downgrading helps. If it does, then my suggestion would be to file a bug report using the Support link above – and Jamie can work with you to figure out what’s going on there, and get that fixed up.