Sub-server displaying content of parent server on shared external IP address [SOLVED]

14 posts / 0 new
Last post
#1 Tue, 01/10/2017 - 10:08
hbdp

Sub-server displaying content of parent server on shared external IP address [SOLVED]

Hello,

I cannot find out why the sub-server is not displaying the content of its public_html directory but instead the content of the parent server's public_html. Both servers are using a external shared IP address.

Here is my setup (not with the real IPs and domain names though...), in chronological order:

  1. installed 'webmin / virtualmin gpl' on my dedicated server (debian jessie)
  2. bought IP external addresses (from 'ovh') and installed them manually by editing the /etc/network/interface file (following ovh documentation: http://docs.ovh.ca/en/guides-network-ipaliasing.html#debian-derivatives)
  3. created the parent virtual server:
    • domain name: example.com
    • administrative user: examplecom
    • features: apache website and webmin access (no ssl, no mail related feature, no dns)
    • document root: /home/examplecom
    • files for the website in /home/examplecom/public_html/
    • IP address www.xxx.yyy.zzz, already active, external IP address www.xxx.yyy.zzz, already active, no ipv6 address
  4. uploaded the index.html file containing this is example.com in /home/examplecom/public_html/
  5. on my registrar, setup the DNS of example.com to point to www.xxx.yyy.zzz
  6. when I visit http://example.com, it works fine, I can see this is example.com
  7. shared the IP www.xxx.yyy.zzz (Server Configuration > Change IP address, click on Convert Private Address to Shared)
  8. created the sub-server of example.com:
    • domain name: otherdomain.com
    • server configuration template settings for sub-servers
    • parent server: example.com (examplecom)
    • administrative user: examplecom
    • enabled features: apache website and webmin access (no ssl, no mail related feature, no dns)
    • IP address shared on non default IP www.xxx.yyy.zzz , external IP address www.xxx.yyy.zzz, no ipv6 address
  9. uploaded the index.html file containing this is otherdomain.com in /home/examplecom/domains/otherdomain.com/public_html/
  10. on my registrar, setup the DNS of otherdomain.com to point to www.xxx.yyy.zzz

The problem is that when I visit http://otherdomain.com, I see this is example.com and not this is otherdomain.com.

What am I doing wrong?

Tue, 01/10/2017 - 11:14
unborn
unborn's picture

hi, I can see, however no word to mention distro you are using, also are you business ?

Configuring/troubleshooting Debian servers is always great fun

Wed, 01/11/2017 - 03:52 (Reply to #2)
hbdp

I'm using debian jessie, if it is what you were asking. Sorry but I don't understand your question 'are you business?'

Any idea what is missing in my configuration, that would explain why it is not working?

Wed, 01/11/2017 - 04:22
unborn
unborn's picture

hi hbdp, was just curios if that server sits on residential line or business line. difference is dynamic vs static ip, thats all. In your case you using business line (static ip from your hosting provider ...i missed that fact). I would suggest to check bind settings for that host (zone). I've seen that someone had this issue in past in this forums but I do not remember the link. Also did you try to contact ovh support staff?

Configuring/troubleshooting Debian servers is always great fun

Wed, 01/11/2017 - 07:59 (Reply to #4)
hbdp

Thank you very much for your help, unborn.

The thing is that the requests to otherdomain.com do reach the server but I noticed that they don't appear in othercomain.com's apache access logs but in example.com's access logs, so it looks like the IP setup is correct.

I haven't touched anything concerning the DNS settings, I thought that adding a sub-server will have virtualmin setup everything automatically so that the requests from otherdomain.com are directed to its document root's public_html.

Maybe I should change the options I used for creating the sub-server?

Wed, 01/11/2017 - 08:05 (Reply to #5)
hbdp

Oh and regarding DNS, I forgot to mention that I intentionnally didn't select the feature DNS domain enabled? when creating both example.com and otherdomain.com.

So far I haven't needed to setup DNS on the server as I got all my domains (hosted on their own external IPs) working by simply editing the DNS on the side of the registrar, where I bought the domain, and setting them to point to the corresponding external IP address.

Wed, 01/11/2017 - 10:37
hbdp

I actually find a solution to my problem thanks to this answer to a similar problem, which was pointing to Virtualmin's website troubleshooting documentation.

I did the following:

  1. Logged as root with ssh

  2. Listed the IP addresses on the server # /sbin/ifconfig

  3. check what IP addresses apache is expecting and for which domain # grep -i '<virtualhost' /etc/apache2/sites-enabled/*.conf

  4. I got this for otherdomain.com

/etc/apache2/sites-enabled/otherdomain.com.conf:<VirtualHost *:80>

  1. I edited /etc/apache2/sites-enabled/otherdomain.com.conf by replacing <VirtualHost *:80> with <VirtualHost www.xxx.yyy.zzz:80>

  2. I restarted apache2 # service apache2 restart

I visited http://otherdomain.com, and tadaaaa I saw this is otherdomain.com

Hope it can help someone in the same situation as me.

Wed, 01/11/2017 - 14:12
unborn
unborn's picture

Hi hbdp, sorry for late reply but I've managed to spill out my soup on laptop resulting me to strip laptop down and clean up the keyboard. Since I do run Debian my self everywhere not just servers for sure I would say on proper debian setup - on server you should not need to do those things..its should do this automatic for you. - Did you modify any other settings on your server? coz thats just crazy..

Configuring/troubleshooting Debian servers is always great fun

Thu, 01/12/2017 - 08:11 (Reply to #8)
hbdp

Hi unborn,

sorry to hear that. Hope your laptop is still alive... I heard some people say "Never eat next to your computer, period", though I agree it's quite a discipline (that I don't have myself yet...) :)

Anyway, I just installed webmin following a tutorial from digital ocean, nothing fancy.

For the installation wizard I basically skipped anything that was not related to apache, because I wanted to have it running as soon as possible and I don't need neither mail nor DNS nor MySQL, nor anything else...

I wanted to have it just serving static or dynamic (php) content. Plus the DNS configuration have been done on the side of the registrars, simply pointing to the allocated IPs.

So far it has been working good, because I could install new IPs, which I purchased from ovh, my hosting company and I could assign single virtual servers / domains to each of them.

That's only when I wanted to have multiple domains on the same external IP, that I encountered this issue with sub-server content not being displayed but parent content instead.

Any idea where I could edit my config so that the correct IP is assigned by apache on sub-server creation?

I checked the apache configuration and the sub-server template but I didn't see anything that I could edit and that would have that wildcard replaced by the actual shared IP in the sub-server apache configuration file.

Moreover, I'm wondering if it does not come from the fact that I installed the new IPs using the guidelines of ovh, and not through the webmin interface.

Maybe I should be using the webmin interface and share the new external IP address I purchase from the beginning and that could help (althought it could be a bit tedious to add them one by one in the webmin interface)?

By the way, I'm also a big fan of debian myself, hence the choice of the distro... ;)

Wed, 01/11/2017 - 15:49
Joe
Joe's picture

Check the IP addresses assigned to each VirtualHost in the Apache configuration. This can be caused by one having

<VirtualHost *:80>

And the other having:

<VirtualHost 192.168.1.1:80>

This leads to weird behavior as Apache decides what to display (it'll end up showing the "default" site, I think). I've asked Jamie to make this harder to have happen accidentally in Virtualmin. It's a common question. There's an entry in the troubleshooting docs about it here: https://www.virtualmin.com/documentation/web/troubleshooting#toc-the-wro...

--

Check out the forum guidelines!

Thu, 01/12/2017 - 02:53 (Reply to #10)
unborn
unborn's picture

....you only need to do this when you have external dns.. but if you manage dns with bind on your server it will work with <VirtualHost *:80>

Configuring/troubleshooting Debian servers is always great fun

Thu, 01/12/2017 - 08:16 (Reply to #11)
hbdp

Hello again unborn,

but isn't it my case, though? My DNS are not managed by Webmin, I just edit the server IP address on my registrar for the given domain. Could it be the reason why I get <VirtualHost *:80> in the sub-server apache configuration file?

Althought that seems quite weird because I specify the shared IP address when creating the sub-server...

Thu, 01/12/2017 - 12:39 (Reply to #12)
unborn
unborn's picture

hi hbdp, you do not feel weird regards this.. its normal... If you do not manage dns on you own then you should expect some ugly things..(edit - you should tell people in this forums asap... it makes a sense) nothing to worry about but just - you should see it as sysadmin... its all resolved inst it?

Configuring/troubleshooting Debian servers is always great fun

Thu, 01/12/2017 - 08:14 (Reply to #13)
hbdp

Thank you Joe.

Indeed that's how I solved the problem, by replacing the widcard in the apache configuration file by the correct shared IP address.

But as unborn mentionned, it is a bit weird that it has to be done like this. That's the point of Webmin / Virtualmin, to have this kind of things abstracted and done for us. So it looks like it could be a configuration thing that is not or incorrectly setup on my server.

Topic locked