According to the apache docs, when hosting multiple named servers with dynamic IP I should create my virtual hosts on *:80 e.g. DocumentRoot /www/example1 ServerName www.example1.com
DocumentRoot /www/example2 ServerName www.example2.org
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. 1. How do I setup *:80 through virtualmin 2. 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.
Any help greatly appreciated
Howdy,
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?
-Eric
Thanks for the reply
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.
Howdy,
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.
-Eric
Hi Eric
Thanks, just tested this any it works perfectly :)
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.
Thanks again
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.
Howdy,
Are there other NameVirtualHost entries in your Apache config? If there's others in there, it may just be looking at the wrong one.
-Eric
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_virtualAny solution here?
I unfortunately haven't been able to reproduce the problem you're seeing...
With the correct NameVirtualhost lines in there, it really should do what you want.
Maybe you could look for entries in your other Apache config files -- what does this command output:
find /etc/httpd/ | xargs grep -i NameVirtualhost
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
[#588]: pwd; grep "<VirtualHost \*:80>" *.conf | wc -l
/etc/apache2/sites-available
44
However, now whenever we create a new VirtualHost the block gets defined with the external IP address: 1.2.3.4:80
The interesting thing is that Virtualmin insists on re-adding a NameVirtualHost block to my apache config.
I go in and manually edit the config so that it looks like
Listen 443
Listen 80
NameVirtualHost *:80
NameVirtualHost 1.2.3.4:443
And then when I create a new virtualserver the config has changed to
Listen 443
Listen 80
NameVirtualHost *:80
NameVirtualHost 1.2.3.4:443
NameVirtualHost 1.2.3.4:80
Any idea on what's going on?
Is it worth me downgrading back to 3.92 to see if it happens there as well?
I did not try downgrading, for now I will remain on 3.93 with the ugly hacks I have in place.
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.
-Eric
Got the same problems after upgrading, downgrading to 3.92 solve the problem.
Will this issue fixed in new versions? If not, can you describe some workaround for this via new way in current and future versions?
Seems that this issue is fixed in 3.94, for me all works well after upgrading.