Using HAProxy I'm trying to proxy a site where the URL doesn't match the path of the proxied destination server. Right now I'm able to use reqrep to edit the path and at my browser I end up fetching the index.html however it doesn't load any of it's support files (.css, .js ext) even though they are listed by reference.

For example www.mysite.com/maps --haproxy--> www.backend-server.com. In my config I remove /maps so we end up at the web-server root of www.backend-server.com and are able to fetch index.html but now when the .css & .js try to load they can't as they are referencing www.mysite.com/icons/text.gif when I'm guessing they should be referencing www.mysite.com/maps/icons/text.gif. Also I can't just make a rule saying .css & .js goto somebackend because I have different app's which all have this problem and pull their .js & .css files from different places. How do I do this the right way? Here's my config:

    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

frontend dev
    bind xxx.xx.x.30:80
    option forwardfor except

    #Routing based on Web App
    acl filebrowser url_beg /maps
    use_backend dev.maps if maps

backend dev.maps
        option httpclose
        option forwardfor
        reqrep ^([^\ ]*\ /)maps[/]?(.*)     \1\2
        server maps maps.backend-server.com:80 check
  • I don't see your reqrep statements.. Can you post the full config?
    – GregL
    Oct 8 '15 at 14:52
  • Sorry bad copy paste added.
    – Nimjox
    Oct 8 '15 at 15:02
  • Are the locations wrong in the HTML being returned from the backends, or is HAProxy just not dealing with them properly?
    – GregL
    Oct 8 '15 at 17:50
  • so after checking the returned .css & .js type files are absolute paths, like /css/mycss.css. I'm guessing as long as its like that there is nothing the proxy can do to direct those files to the correct place, right?
    – Nimjox
    Oct 8 '15 at 19:13
  • Indeed, it can only manipulate headers and such. Nothing to do with the body. I know there's an Nginx module that can do that though.
    – GregL
    Oct 8 '15 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.