5

I am using HAProxy for load balancing a couple of web servers (HTTP mode). The web servers are strictly dynamic, ie, there isnt any static content, only web services.
The URLs of the type (analogous)

http://192.168.5.10:8080/small http://192.168.5.10:8080/medium http://192.168.5.10:8080/large 

Now, when i configure HAProxy to forward the incoming requests to these 3 urls on couple of machines, I'm specifying the url_path using acl and path_end/path_beg, but upon placing the request I get Not Found on Accelerator error, which is making it harder to pin point the problem.

Below is the configuration that I'm using. Also, it is not logging any errors.

 global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 4096 user haproxy group haproxy daemon defaults log global mode http option httplog option dontlognull retries 3 option redispatch maxconn 2000 contimeout 5000 clitimeout 10000 srvtimeout 10000 frontend http_proxy bind 192.168.5.9:8888 acl is_small path_end -i small acl is_medium path_end -i medium acl is_large path_end -i large use_backend web_server_small if is_small use_backend web_server_medium if is_medium use_backend web_server_large if is_large backend web_server_small mode http balance roundrobin option httpclose server web_1 192.168.5.10:8080 check server web_2 192.168.5.11:8080 check backend web_server_medium mode http balance roundrobin option httpclose server web_1 192.168.5.12:8080 check server web_2 192.168.5.13:8080 check backend web_server_large mode http balance roundrobin option httpclose server web_1 192.168.5.14:8080 check server web_2 192.168.5.15:8080 check 

Is it possible to send the request from HAProxy to the web_server with the url_path?.

If HAProxy receives it as http://192.168.5.2:80/small, then send the request to the webserver as http://192.168.5.10:8080/small

2 Answers 2

5

As your path is contained to the start of the URL why not use path_beg, the recommended use for path_end is for file name extensions.

 acl is_small path_beg -i /small acl is_medium path_beg -i /medium acl is_large path_beg -i /large 
5
  • Good point. Unfortunately, that doesnt seem to solve the problem. Commented Jan 20, 2014 at 6:18
  • Have you checked manually from the haproxy server whether you can connect to the backend machines on those URL's? Commented Jan 20, 2014 at 6:24
  • Do you mean to ask whether the backend servers are up? Those are running and the corresponding URLs are functional as well. Commented Jan 20, 2014 at 6:29
  • You need to be on the haproxy server and test whether you can access the servers/URL's from there. Commented Jan 20, 2014 at 6:35
  • Well, that is the problem. If I host a server without any url_path, say http://192.168.5.10:8080 and not http://192.168.5.10:8080/small, then it forwards the request. But I'm not able to forward it with the url_path. Atleast none of the configurations that I tried worked. Any idea how to include the url path with the forwarded request? Commented Jan 20, 2014 at 7:45
3

The path of a HTTP request is always handed to the backend server, i.e.

GET /small HTTP/1.1 

will be visible behind HAproxy as just that request. If you suspect that this somehow is truncated to

GET / HTTP/1.1 

on the server behind HAproxy, you should check for this using

tcpdump -i any port 8080 -As1024 | grep GET 

on that server and watch the inbound GET requests.

I'm going on a limb and assume that you expect HAproxy to insert something in the front of the URI, like

 server web_1 192.168.5.14:8080/my/path check 

would turn a request for /small into a request for /my/path/small. This can be achieved by using the reqrep option, see the documentation for details.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.