Howdy, Stranger!

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

[Help] How to point a domain to 2 VPS IPs for hostname and web hosting?
New on LowEndTalk? Please Register and read our Community Rules.

[Help] How to point a domain to 2 VPS IPs for hostname and web hosting?

mawrmawr Member

Hey guys,

Is there a way I can point a subdomain to 2 VPS IPs? One IP would be for the hostname so I can ping/connect to the server from the subdomain.

I want to host the website for the same subdomain on a different VPS though, so I want the website to be pointed to that IP.

I do all my DNS redirects through cPanel.

Comments

  • nope

    just do server.subdomain.example.com or something

  • I don't think it would be possible. As @awson mentioned... the subdomains have to be different. May be you can simply try sub.domain.com to your main website and host.sub.domain.com to your host IP.

  • Only way possible is to turn the first vps into a reverse proxy (network level) to the second, forwarding port 80 traffic to the second machine. It's fairly pointless though and you would be better using 2 subdomains

  • EvoEvo Member

    @mawr, I don't think that this would be possible as well. One subdomain cannot have 2 different A records at the same time (round-robin sends just one IP for every query), and even if this configuration does not fail, only one of the IP's will be actually used.

    However, maybe you want 2 different hostnames at 2 different IPs ?

    If yes, you could create 2 A records:

    domain.ext - with A record for the first IP (for example to point to your main server)
    subdomain.domain.ext - with A record for the second IP (for example to point to your second VPS)

    http://NeatLogos.com - Easy, Affordable, Fast - Logo and Web Design

  • It depends what @mawr is trying to achieve, he may just be trying to conceal the true identity of the web server for security/protection reasons so that any attackers/hackers would be one step behind, he can have 1.2.3.4 resolve from domain.com and forward 1.2.3.4:80 to 1.2.3.5:80 this would mean he can upload his website files to 1.2.3.5 but anybody doing lookups on the website would only be pointed towards 1.2.3.4 meaning if they hacked this machine they would have to figure out where the traffic is being reverse proxied too and start hacking this machine aswell. You can do a reverse proxy with just iptable rules, this can have some unwanted effects such as all your site traffic being shown as the same IP etc, if you need a better configuration you will need to use software to act as a reverse proxy which will correct traffic sources for you.

  • Here is the example: http://109.169.7.212

    Note* perhaps a bad example with google since if you apply a domain to it google is coded to redirect to google.com but the raw IP will still work you can use that website for googling and images. see here : http://reverse1.pkr2.com you can however use this method for your own websites/ gameservers etc but it does have some drawbacks.

  • Two ways to do this -

    First option : Set multiple A records so if browser cant load one it will default to next in line.

    Second option : Set a single a record to a vps which has varnish or nginx on it, an then define multiple backends so its load balanced all via one ip thus never revealing the ips of the two backends.

    that is basically your questioned answered

  • Yes @VPSSimon is explaining the software version in his section option :) this works great for websites, if you have other services that are not webservers you will need to use the network method since there arn't many programs that im aware of for reverse proxys (besides websites)

  • s1.domain.com s2.domain.com simple and easy

    Professional lurker

  • mawrmawr Member

    @pkr5770 said:
    It depends what mawr is trying to achieve, he may just be trying to conceal the true identity of the web server for security/protection reasons so that any attackers/hackers would be one step behind, he can have 1.2.3.4 resolve from domain.com and forward 1.2.3.4:80 to 1.2.3.5:80 this would mean he can upload his website files to 1.2.3.5 but anybody doing lookups on the website would only be pointed towards 1.2.3.4 meaning if they hacked this machine they would have to figure out where the traffic is being reverse proxied too and start hacking this machine aswell. You can do a reverse proxy with just iptable rules, this can have some unwanted effects such as all your site traffic being shown as the same IP etc, if you need a better configuration you will need to use software to act as a reverse proxy which will correct traffic sources for you.

    I am trying to have clients use the subdomain to easily ping/connect to a game server, and then have the web hosting be hosted on a seperate VPS.

  • EvoEvo Member

    @mawr, in that case you need 2 different A records, for example:

    gameserver.domain.com  A record to point to your gameserver IP 
    domain.com A record to point to your website (second VPS IP)
    

    http://NeatLogos.com - Easy, Affordable, Fast - Logo and Web Design

  • @mawr Is it a problem to use a subdomain for the gameserver like play.domain.com or does it have to be the exact same?

  • mawrmawr Member

    It was supposed to be the exact same but that doesn't seem possible. Thanks guys!

  • pkr5770pkr5770 Member
    edited August 2013

    @mawr

    Are they both in the same geographic location? what port is the gameserver running on?

  • mawrmawr Member

    @pkr5770 said:
    mawr

    Are they both in the same geographic location? what port is the gameserver running on?

    Yea, though that shouldn't matter.
    Game server is on 27015

  • @mawr What is the IP of the war server and what is the IP of the gameserver?

  • Run the following command on your webserver box, replace IPGAMESERVER and IPWEBSERVER with the correct values and watch the magic work ;)

    sysctl net.ipv4.ip_forward=1;iptables -t nat -A PREROUTING -p udp --dport 27015 -j DNAT --to-destination IPGAMESERVER:27015;iptables -t nat -A POSTROUTING -j SNAT --to-source IPWEBSERVER;service iptables save; service iptables restart

Sign In or Register to comment.