HAProxy可以用来重写相当的url吗?

当HAProxy将请求传递给Web服务器时,HAProxy是否可以将“domain.com/cool/url”中的URI重写为“domain.com/index.php/cool/url”?

谢谢。

reqrep <search> <string> reqirep <search> <string> (ignore case) Replace a regular expression with a string in an HTTP request line May be used in sections : defaults | frontend | listen | backend no | yes | yes | yes Arguments : <search> is the regular expression applied to HTTP headers and to the request line. This is an extended regular expression. Parenthesis grouping is supported and no preliminary backslash is required. Any space or known delimiter must be escaped using a backslash ('\'). The pattern applies to a full line at a time. The "reqrep" keyword strictly matches case while "reqirep" ignores case. <string> is the complete line to be added. Any space or known delimiter must be escaped using a backslash ('\'). References to matched pattern groups are possible using the common \N form, with N being a single digit between 0 and 9. Please refer to section 6 about HTTP header manipulation for more information. 

HAProxy 1.3文档


编辑:这是(显然)由你决定是否select使用HAProxy实现重写,但是,我强烈build议你考虑使用mod_rewrite (或类似的)来代替。

HAProxy的重写function旨在促进负载平衡活动,并且从维护的angular度来看,Web服务器行为不应该与负载平衡器configuration相结合 – 也就是说,如果将负载平衡器从主机configuration中移除,则单个Web服务器响应与给定URI的请求相同的内容(而不是404错误)。