1

Just can't seem to find a clue about this one anywhere.

The Story(Diagram of the system) In the company i work in we have 5 IIS servers... In every server there are many websites(In every server the same sited) All the servers are behind a balancer so if you type the hostname you do not know to what server are you going to be directed to.

All the servers and for each server all its virtual websites are in the HOST file If I choose a server and a site in the host file I will be directed to this server and site and every thing is working.

Now my question I'm trying to connect to each of the servers and for each one check a page on it...

What happens is that i am all the time being redirected to the same server, not the different servers...

I am calling this code for each server, where the Url is the name of the page and "((WebPageTest)test).ServerAddress" changes for each server...

        string htmlText = string.Empty;
        try
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.MyDomain.com" + Url);
            request.Host = ((WebPageTest)test).ServerAddress;
            request.UserAgent = "Tests UserAgen";
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            StreamReader reader = new StreamReader(stream);
            htmlText = reader.ReadToEnd();
            htmlText = "OK";

        }
        catch (Exception exp) {
            htmlText = exp.Message;
        }
        return htmlText;

Any one knows maybe how to Connect to the right server and right website in every server so i will be able to check the page in each site?

EDIT: there is no way i can change setting in the balancer or the firewall or any thing like that.... I need to mimic what happen when using a host file. When no server is added to the host file, the balancer decide to which server to send the request to, but when i am using the host file i am directed to a specific server....This is what i need to do in code...Is there any thing to add to the header to do that and I've tried every thing i can think about?

Thank you very much,

Erez

2
  • If you have the IP addresses of all the servers in your farm, why don't you make web requests to each server IP?
    – PabloC
    Sep 12, 2012 at 15:03
  • Because There is no way to access a wesite directly from an IP, in some servers all the sites have the same IP and what changes is the URL that we connect thrue, like all of them have 194.90.5.50 and to connect to one you write "www.MyDomain.com" and to connect to another to write "admin.MyDomain.com" and so on.... not in every server the IPs are deferent...and also when i write the IP in the create method i am getting a "Bad Request"... This is how the system works and i need a way to getbehind this isue, 10x
    – Erez
    Sep 12, 2012 at 15:36

3 Answers 3

2

Since you want to test specific servers, you should bypass the load balancer entirely, or set designated loadbalancer pipes. For example, if your DNS www.mySite.com points to your ip/port (20.20.20.20 port 80), and that gets forwarded to your load balancer, you should have another forwarding for, let's say the port 800 for internal server 1, 801 for internal server 2, ..., that would be redirected by one of the following methods:

  1. Forward to the server directly
  2. Forward to a fake load balancer that balances with only one server.
  3. Forward to the same load balancer, but using a different configuration, that would balance with only one server.
1
  • Thank you, I will lokk into that tommorow and will come up with a solution or answers....But it is will be posible, i think that this will be my direction...10x again...
    – Erez
    Sep 12, 2012 at 17:25
0

I have few questions for you? 1. Are you using Radware? 2. Is there a firewall between the loadbalancer. the firewall can be your default gateway also. 3. Since you are changing the host file, it means your system/default gateway is not able to resolve the IP. Something is wrong with your firewall policy? giving the IP to resolve the URL is not advisable. 4. How the policies are defined on the load balancer. 5. When load balancer is in picture, the client need not worry about which IIS server he is being redirected to. 6. When you define the policy, make sure the it is defined through URL and not the public IP address. 7. Also check the default gateway of the load balancer.

We are also using a load balancer, we have configured it in such a way that it works when the system accessing the web server is on the same network or coming via firewall/proxy.

1
  • I am not in the same network ofcourse, the servers are sroted in an ISPs storage room and i am trying to connect to them. But again, i can connect, there is no problem with that. that problem is that i am always redirected to a one server (not always the same one, but all my connection in the testing app that i am building going to the same one....I think...as there is no way to tell, but we have some that are IIS6 and some that are IIS7 and i see that when i get result from IIS6 it is always from that on for all the tests and when IIS7 getting from the 7)...10x
    – Erez
    Sep 12, 2012 at 17:29
0

In the load balancer there is a setting for this. If you have 3 servers in the pool then it usually goes to one server if the flag is not set. If you are using Radware i can tell you the flag setting.

You must log in to answer this question.