Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Different subdomains to different local (virtual) machines?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Different subdomains to different local (virtual) machines?

ultrakommultrakomm Member
edited January 2012 in Help

Hello!

I'm wondering if it is at all possible to "bind" different subdomains (vm1.domain.com, vm2.domain.com) to different machines on my local network (192.168.1.11, 192.168.1.12)?

Something like this:

            vm0.domain.com ->
Internet -> vm1.domain.com -> vm0 (83.226.176.x) <-> vm1.domain.com (192.168.1.11)
            vm2.domain.com ->                    <-> vm2.domain.com (192.168.1.12)

I hope you understand what I mean.

Thanks so very much in advance!

Comments

  • Mon5t3rMon5t3r Member
    edited January 2012

    no i'm not. :(

    please fix the "code" tag first.. maybe with pre tag?

  • ultrakommultrakomm Member
    edited January 2012

    I understand that the code-block doesn't make a lot of sense.

    What I want to do, basically, is to bind different subdomains to different virtual machines on my local network. Similar to how web server vHosts work.

    The reason I want to do this is because I only have access to one external IP.

    Could this maybe be done with some sort of DNS server magic?

  • Mon5t3rMon5t3r Member
    edited January 2012

    ow,, ok.. :D sorry.. hehehe

    yes with proxy/port forwarding.. please take a look on my another post here http://www.lowendtalk.com/discussion/comment/16897#Comment_16897 (just see in nginx section)

    i've done that in Xen HVM with Curl"already in the deadpool"Host.

    Thanked by 1ultrakomm
  • Does that only work for web sites? Or all sorts of traffic?

  • I've never try that.. sorry :(
    I only forward the web site and SSH.

    but maybe you can share me which "traffic" you considering to put this on? or maybe someone have another best options for you. just wait for a while..

    Thanked by 1ultrakomm
  • In practice, I would probably only need SSH and HTTP forwarding. But I would like to be able to forward other types of traffic such as game servers, etc. Would this be possible to also forward such traffic?

  • Just add:

    192.168.1.11 vm1.domain.com
    192.168.1.12 vm2.domain.com
    

    on /etc/hosts
    Or am I getting it wrong?

  • fanovpnfanovpn Member
    edited January 2012

    When you tell a generic client to connect to a server, like vm0.domain.com, the client will look up the IP address of vm0.domain.com, and then send all traffic to that IP address. There is nothing about that traffic that indicates what name the client looked up, only the final IP address. So the server isn't actually able to tell if a client thinks it is talking to vm0.domain.com, vm1.domain.com, or any other name pointing at the same IP, unless the client's protocol specifies that the name is to be sent.

    For any protocol that does send a name, your goal is possible. You run a program on vm0 which starts talking to the client, learns the name the client is looking for, and then forwards (proxies) the client's traffic on to the internal machine. There isn't any sort of generic, protocol-forwarding program that can pick out host names, it will have to be a specific forwarder/proxy for each protocol.

    HTTP (version 1.1+) does send the name of the server it's asking for, in the Host header. There's tons of options for reverse proxies for HTTP, squid (http://wiki.squid-cache.org/ConfigExamples/Reverse/MultipleWebservers) is the decades-old standard for proxying, varnish is popular, I know nginx supports it, and the first hit I found on google uses Apache: http://www.raskas.be/blog/2006/04/21/reverse-proxy-of-virtual-hosts-with-apache-2/

    But most other protocols, like SSH or most games, do not include any information about hostnames/subdomains at all, they expect every machine to be addressable by a unique IP. Since you only have the one external IP, you'll have to instead assign every machine on the inside a unique port on that same external IP, and then specify which machine you're trying to talk to via port, not subdomain name. E.g. vm0 could run SSH on port 22, vm1 on port 2222, and vm2 on port 2223. Then, vm0.domain.com:22 will always get you SSH on vm0 (but vm1.domain.com:22 and vm2.domain.com:22 will also get you vm0's SSH). vm*.domain.com:2222 will always get you vm1, etc.

    That technique is usually called "port forwarding" and is supported by pretty much every cable modem, wifi access point, etc. around, so you don't actually have to dedicate vm0 to it, if you've got any sort of consumer NAT device already. You can always do it with a packet filtering / NAT setup on vm0 too, though.

    Thanked by 1ultrakomm
  • I see. Then I know. :)

    Your post was very much appreciated and cleared everything up!

Sign In or Register to comment.