Trouble with vhost working correctly

Hi all. First time user of virtualmin and webmin. Looks good this far =)

I am on CentOS 6, virtualmin installed trough install.sh from docs. No trouble installing, did use a minimal centos install (almost nothing extra installed), and install.sh took care of all dependencies.

Everything works as expected, exept adding virtualhosts and routing to corrent page.

Server: server1.mydomain.com (/var/www/html/index.php)

Domain 1: mydomain.com (/home/mydomain/public_html/index.php)
Domain 2: myseconddomain.com (/home/myseconddomain/public_html/index.php)

Each index.php have a simple echo ‘domain’; Just to let me know where I am beeing sent by the server.

So now,
If I visit server1.mydomain.com => I will see the echo for DOMAIN 1
else if mydomain.com => I will see the echo DOMAIN 1
else if myseconddomain => I will see the echo DOMAIN 1

Then I deleted the mydomain.com virtualserver in virtualmin.

Now I will see MYSECONDDOMAIN.Com echo on both server1.mydomain.com and myseconddomain.com

I have read trough tons of pages now, trying to figure out what settings are wrong. I have the correct ETH0 and ip adress spesified everytwhere I can find, I have checked that no *:80 is in httpd.conf, I have clicked almost everywhere to find any settings that can cause this problem. But I am stuck =(

Any suggestions where to move on from here?

XEN VPS

# ifconfig eth0 Link encap:Ethernet HWaddr 00:13:3E:F9:22:33 inet addr:xxx.xxx.xxx.xxx Bcast:xxx.xxx.xxx.xxx Mask:255.255.255.128 inet6 addr: fe30::514:3ece:fdd3:2f55/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6265 errors:0 dropped:0 overruns:0 frame:0 TX packets:4071 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:868231 (847.8 KiB) TX bytes:1442665 (1.3 MiB) Interrupt:11

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:305 errors:0 dropped:0 overruns:0 frame:0
TX packets:305 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:39760 (38.8 KiB) TX bytes:39760 (38.8 KiB)

# rpm -qa | grep httpd httpd-tools-2.2.15-15.el6.vm.1.i686 httpd-2.2.15-15.el6.vm.1.i686 # cat /etc/resolv.conf nameserver 127.0.0.1 nameserver 8.8.8.8 nameserver 8.8.4.4 domain localdomain

No /var/log/virtualmin/domain*_error.log, or any other pointers in any other log files.

Any suggestions where and what values to check in the different config files?

Thanks for your assistance, it is appreciated!!

-Tom

It is recommended to use an FQDN for your server (“server1.mydomain.com”) whose domain is NOT under Virtualmin control. You can manage the zone “mydomain.com” in Webmin, but don’t add it to Virtualmin. Doing so could lead to problems like you’re seeing.

When you fix this and still see the wrong domains in Apache, check its virtual host settings in Webmin’s Apache module. All virtual hosts that were created from Virtualmin should have an explicit IP address and port 80.

So if I understand you correctly, I can not create 1 website for mydomain.com (sql,ftp ++) and use the prefix server1.mydomain.com for my server, and display the default website (/var/www/html) for that sub-domain?

httpd.conf => All virtual hosts have server.ip.adress:80 and are not using *:80

I am totally stuck, If I remove all the Virtualhosts, the /var/www/html/index.php display. But if I add any virtualhost to httpd.conf, the vhost /home/user/public_html/index.php will display no mather what url (server1.domain.com, domain2.com, domain3.com ++) I type in my address bar.

Its like the first virtualhost is a “catch-all” vhost, unless I remove all virtualhosts, then the main server is a catch all.

I need a setup like this:
server1.domain1.com => /var/www/html/index.php (catch-all)
domain1.com => /home/user1/public_html/index.php
domain2.com => /home/user2/public_html/index.php
and so on.

I do not know if it is of any importance, but I have only 1 IP for my server.

All help on this is appreciated, as I am almost at the point where I will leave virtualmin for another CP soon.

-Tom

If you wish to have “mydomain.com” controlled by Virtualmin, your server’s FQDN should not be anything under *.mydomain.com", that’s right. It can be done, but is complicated and can lead to problems like you’re seeing.

Better use a separate “administrative domain” for that purpose, like “myhosterdomain.com”, and give your server(s) hostnames under that, like “server1.myhosterdomain.com”. You could even use a free domain from some dynamic dns hoster for that or something, doesn’t matter, as long as it is externally resolvable and not configured in Virtualmin as a virtual server.

Also, you should not try to use the Apache default /var/www for your web pages. Virtualmin uses the scheme /home/domainuser/public_html for the web site files. All of that can be configured of course, but especially as a newbie, you should better not try that. :slight_smile:

If you need a catch-all domain, you can just create a virtual server like normal, and configure it to be the default for the IP address, under “Server Configuration / Website Options”.

Actually. I am not “that” of a neewbie :slight_smile: I run several webservers, with several domains and websites.

I am a neewbie regarding to virtualmin/webmin, never tried it before, BUT it looks like a really good managing software. Except this minor problem getting it working as I would like it to :slight_smile:

I could look into having a separate domain for my server(s), but as all my servers only run web apps, sql and for some clients, email, and I would prefer do have server1, server2 ++ on main-domain.

If you have any example for config setups for this, terminal or oterhwise, let me know.

-Tom

My apologies, I figured the “newbie” part was meant towards webhosting in general. :slight_smile:

Unfortunately I don’t have config examples ready for what you intend to do. I only recall that I tried it when I first started working with Virtualmin, i.e. manage the administrative domain with the FQDNs of my servers through Virtualmin, ran into similar problems as you did, and decided to take the easy way out and manage the administrative zone solely with Webmin’s BIND module (which works without problem). :slight_smile:

I do have the administrative domain active in Virtualmin, but only for Email; the DNS Domain feature is disabled, and it does not host any websites.

It is possible though that the issues you’re seeing are not really caused by that, but stem from your attempts to use /var/www as website directory. You should start by creating all your websites as virtual servers in Virtualmin, following the /home/domainowner/public_html scheme, and setting the one that should be your default domain accordingly, like I wrote before.

Due to lack of experience with that setup though I can’t give precise “do this, then that” hint, sorry.

Okei mr Picard =)

I will try to play around with it and see what I can figure out.

Thanks for your help!!

Anyone else with some more tips on what-to-do, let me know :slight_smile:

-Q

Okei Captain. I got it working as I wanted =)

Here is how:
/etc/httpd/conf/httpd.conf

Listen 80
NameVirtualHost *:80

display /var/www/html/index.php - server1.domain.com

added manually to httpd.conf before creating any vhosts trough virtualmin

<VirtualHost *:80>
Servername localhost.localdomain
Serveradmin TheRealQ@domain.com

display /home/username/public_html/index.php - domain.com

added by virtualmin

<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /home/username/public_html

display /home/username2/public_html/index.php - domain2.com

added by virtualmin

<VirtualHost *:80>
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /home/username2/public_html

… more hosts/domains same way as domain.com

Looks like virtualmin is inserting NameVirtualHost server.ip.adress:80 everytime I add a new vhost, and apache throw me an error when starting apache.

NameVirtualHost server.ip_adress:80 has no VirtualHosts

But I just quote it out and leave NameVirtualHost *:80 in default httpd config and everything is perfect.

So using * instead of ip for all, is working just fine.

Dev should look into this. so that virtualmin does not insert new NameVirtualHost if it already exist.

-Q