Question

I use Haproxy as a Layer7 http proxy to transfer a client's requests to one server. As one long connection, before transferring every request to the server, I need to replace some url string to another. For example: reqirep ^([^\ ])\ /test/(.) \1\ /serverfault/\2

I traced and found HAProxy will only process the first request of each connection. In another words, Haproxy only replaces the first POST /test/why to POST /stackoverflow/why. the second,third... doesn't....

The Haproxy Manual said: "When a client communicates with a server, HAProxy will only analyze, log, and process the first request of each connection." Because the next request has something to do with the previous request in the long connection, I want to replace the string and keep alive the connection and let the client close the connection when they want. I have tried "option httpclose" or "option http-server-close" which does not work for me. Does Haproxy not support replace any request with reqirep in one long connection? Is there any option or method to achieve it.

Was it helpful?

Solution

Haproxy does not fully support keep alives yet. It is scheduled to be fully implemented when 1.5 becomes "stable". Having said that, I have been using the 1.5 branch in a very large production environment for almost a year with no issues.

I would suggest using http-server-close which will only close the haproxy server to the backend server (meaning it will allow the client to use keep alives to haproxy). This will fix the issue of haproxy not modifying the 2nd, 3rd, etc request. It sounds like you want the same client to always go to the same backend. If this is the case then you can look at using a stick table or cookie affinity. https://code.google.com/p/haproxy-docs/wiki/cookie

If you really need keep alives all of the way to the back-end you may have to look at using a different product, but from your description I think that you can get away with using the persistence.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top