Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to proxy all requests to /static/pdfs to a cdn that has the same filenames but doesn't have the /static/pdfs prefix. I can do this easily with nginx like this:

location ^~ /static/pdfs/ {
  rewrite /static/pdfs/(.*) http://mycdn.com/$1;

Is it possible to do the same thing with haproxy?

share|improve this question

1 Answer 1

You will have to use a frontend /backend configuration. For example:

frontend http_proxy
  acl is_cnd path_beg /static/pdfs/
  use_backend cdn if is_cdn
  default_backend mysite

backend cdn
  server mycdn.com

backend mysite
  server regular-site.com

I'm doing this from memory so it might not be exactly right, but if not then it's pretty close.

share|improve this answer
It is pretty close. In fact, it is correct ;) –  Leandro López Nov 20 '10 at 3:16
No, it is not correct, because it leaves /static/pdfs prefix, which he wants to be removed. I need the same thing :D –  Dalibor Filus Apr 19 '12 at 13:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.