Hi, I am a rookie for operation of computer networks. I am trying to utilize haproxy to do load balance according to a client's location. I have found some tool to get the client location by the client himself. I hope the client can periodically send the information of his location to haproxy, and then the haproxy can do load balance according to the information. I hope the client can send information of the location by using web browser such as IE.
My plan to achieve this goal is as follows. Would you like to give some suggestion or correction for the plan. 1. the tool i found to derive client's location is javascript object(a js file). The way to use this file is to write a webpage that using this javascript object and put the webpage on a web server. When the client connect to the web server, the client loads the webpage and derives his location. 2. By using haproxy as a load balance mechanism, i hope the haproxy can give the client the webpage aforementioned when the client connects to the haproxy at the first time. When the client executes the webpage, the client will derive his location and save the location as a cookie. Then, the client sends the cookie to the haproxy. 3. Upon the location information in the cookie, the haproxy can do load balance. My method to accomplish the plan is that a. When a client connects to the haproxy, the haproxy sends a response first. This response contains information of the webpage. When a client connect to the haproxy at the first time, I have traceed analysers of a request (s->req->analysers) to AN_REQ_HTTP_XFER_BODY. I think this may be the step that the haproxy accomplish the procedure that handles a request. Therefore, i design a function int oliwad_http_active_geolocpage(struct session *s) { buffer_auto_read(s->rep->prod->ib); buffer_abort(s->rep->prod->ib); buffer_auto_close(s->rep->prod->ib); buffer_erase(s->rep->prod->ib); printf("OLIWAD AN_REQ_HTTP_XFER_BODY_2"); buffer_cut_tail(s->rep->prod->ob); if (likely(&(oliwad_msg_active_geolocpage_chunk) && oliwad_msg_active_geolocpage_chunk.len)) buffer_write(s->rep->prod->ob, oliwad_msg_active_geolocpage_chunk.str, oliwad_msg_active_geolocpage_chunk.len); s->rep->prod->ob->wex = tick_add_ifset(now_ms, s->rep->prod->ob->wto); buffer_auto_read(s->rep->prod->ob); buffer_auto_close(s->rep->prod->ob); buffer_shutr_now(s->rep->prod->ob); return 1; } ,where oliwad_msg_active_geolocpage_chunk is const struct chunk oliwad_msg_active_geolocpage_chunk = { .str = (char *)&oliwad_msg_active_geolocpage, .len = sizeof(oliwad_msg_active_geolocpage)-1 }; and const char oliwad_msg_active_geolocpage[]= "HTTP/1.0 200 OK\r\n" "Cache-Control: no-cache\r\n" "Connection: close\r\n" "Content-Type: text/html\r\n" "\r\n" "<html><head><title>Geolocation</title></head><body>" "<script type=\"text/javascript\" src=\"../gears_init.js\"></script>" "</body></html>\n"; The function i design is to replace the following original code if (!http_request_forward_body(s, s->req, AN_REQ_HTTP_XFER_BODY)) break; UPDATE_ANALYSERS(s->req->analysers, ana_list, ana_back, AN_REQ_HTTP_XFER_BODY); However it doesn't work. Would you like to give me some suggestion or correction of my design function and my plan. Thank you very much.