Jump to content

Login to server A or server B ?


omniowner

Recommended Posts

I currently have a website running (ex. www.site.com) and I want to add a second server for load balancing.

 

What I would like to do, is when someone logs into my site.com they choose which server they would like to log into. Server A or Server B.

 

I have seen this done on plenty of websites and I am just not sure how to go about it.

 

Also, I would like to keep the domain the same but I would not mind using a sub-domain (server1.site.com) or I have also seen something like this (www.site.com?server=1).

 

I am not sure what I have to add to my existing login page to do this and I am not sure how I should go about the DNS (a-record/nameservers.)

 

Note: I know how to remotely connect to my database from another server, I managed to figure that out so far. I am just wondering how I can modify the code or whatever I have to do so that a user can simply choose which server they would like to login to.

 

Any help would be greatly appreciated! Thanks in advance!

 

 

 

Link to comment
Share on other sites

I currently have a website running (ex. www.site.com) and I want to add a second server for load balancing.

 

What I would like to do, is when someone logs into my site.com they choose which server they would like to log into. Server A or Server B.

 

I have seen this done on plenty of websites and I am just not sure how to go about it.

 

Also, I would like to keep the domain the same but I would not mind using a sub-domain (server1.site.com) or I have also seen something like this (www.site.com?server=1).

 

I am not sure what I have to add to my existing login page to do this and I am not sure how I should go about the DNS (a-record/nameservers.)

 

Note: I know how to remotely connect to my database from another server, I managed to figure that out so far. I am just wondering how I can modify the code or whatever I have to do so that a user can simply choose which server they would like to login to.

 

Any help would be greatly appreciated! Thanks in advance!

 

I could be wrong but allowing remote access opens your database up to a much higher security risk. If this is not absolutely necessary I wouldn't go down this path if I were you. Otherwise you should simply be able to change the connection parameters depending on what server needs to be accessed. The server=1 would be using a GET variable to decide which connection parameters to use. The other way you would just be accessing a different page.

Link to comment
Share on other sites

I currently have a website running (ex. www.site.com) and I want to add a second server for load balancing.

 

What I would like to do, is when someone logs into my site.com they choose which server they would like to log into. Server A or Server B.

 

I have seen this done on plenty of websites and I am just not sure how to go about it.

 

Also, I would like to keep the domain the same but I would not mind using a sub-domain (server1.site.com) or I have also seen something like this (www.site.com?server=1).

 

I am not sure what I have to add to my existing login page to do this and I am not sure how I should go about the DNS (a-record/nameservers.)

 

Note: I know how to remotely connect to my database from another server, I managed to figure that out so far. I am just wondering how I can modify the code or whatever I have to do so that a user can simply choose which server they would like to login to.

 

Any help would be greatly appreciated! Thanks in advance!

 

I could be wrong but allowing remote access opens your database up to a much higher security risk. If this is not absolutely necessary I wouldn't go down this path if I were you. Otherwise you should simply be able to change the connection parameters depending on what server needs to be accessed. The server=1 would be using a GET variable to decide which connection parameters to use. The other way you would just be accessing a different page.

 

Thanks for the quick response :)

 

I am fairly certain that the method I am using to remotely connect to my database on Server A from Server B is secure. However, I will look into it.

 

What I am wondering is how can I make it so that when someone chooses which Server to login to that only that Server's resources are being used.

 

Using a get variable to identify the Server (server=A or server=B) would work fine. However I am not sure what I would actually code to make sure I was actually logging into Server A or B to make sure that only Server A or B's resources would be used (as both Server A and B will have the same domain name.)

 

I am thinking.. if I made s1.site.com and s2.site.com (having the s1 subdomain on server A and the s2 subdomain on server B) that then I could just re-direct the user to either sub-domain depending on what they selected.

 

Anyone think this might work? Any other suggestions?

Link to comment
Share on other sites

To do this properly, you need the load balancing set up on the router these servers are running off. Otherwise you have to choose which one is handling the initial request, and doing the switching.

 

With the router doing it, the actual load balancing is entirely transparent

Link to comment
Share on other sites

To do this properly, you need the load balancing set up on the router these servers are running off. Otherwise you have to choose which one is handling the initial request, and doing the switching.

 

With the router doing it, the actual load balancing is entirely transparent

 

 

I am using 2 VPS servers. I do not have access to a physical router, nor physical access to either server. I don't know if a router solution is going to help me much unless there is a way I can configure them without having physical access? Not sure as I don't know much about "router switching" (not sure if that is what its called)

 

There is a way to do what I am trying to via Round Robin DNS. However this solution is not the best nor will it work for me in my specific case. Perhaps "load balancing" is something different and now what I am completely trying to do. It's all new to me.

 

 

My main objective is to allow users to select which server they want to log into.

 

If someone logs into server A, it will bring them to pages on server A, thus using server A's resources.

If someone logs into server B, it will bring them pages on server B, thus using server B's resources.

 

The real question is how do I make it if the domain name is the same for both A and B to tell the login script which server to go to?

 

Some kind of connection method? I normally would just tell the login script to go to main.php but since main.php is the same on both server A and server B how will it know which one to choose? example (site.com/main.php on server A and site.com/main.php on server B .. how will it know which one to choose because they address's are identical??)

 

This why I thought sub-domains might work. serverA.site.com/main.php will go to server A and serverb.site.com/main.php will go to server B.

 

Of course, your solution about using a router to determine which one to use would work perfect. Is there a way I can do this remotely? Should I contact my host?

 

Also, from what I know using the same domain on more than one server works fine. Anyone who knows DNS know how to do this? I plan to just add more name servers to the A record with different IPs.. that might work??

 

Maybe on server B i could do put serverb.site.com - IP address in the arecord and that will work okay? Not entirely sure because I haven't played with it

 

Thanks for the suggestion and any more ideas/help welcome!

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.