Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAProxy: Backend with subdirectory / subpath / subfolder?

I am trying to achieve this:

http://front-end       --> http://back-end/app-1
http://front-end/app-2 --> http://back-end/app-2-another-path

So that requests will be handled this way:

http://front-end/do-this       --> http://back-end/app-1/do-this
http://front-end/app-2/do-that --> http://back-end/app-2-another-path/do-that

How can I do this? Thank you.

like image 644
Tung Nguyen Avatar asked Mar 06 '14 08:03

Tung Nguyen


1 Answers

You can achieve this "http://front-end/app-2/do-that --> http://back-end/app-2-another-path/do-that" with the following configuration:

frontend http   
   #match url ending with /xxxxx/do-that
   acl do-that path_end -i /app-2/do-that

   use_backend server1 if do-that

backend server1
   reqirep ^([^\ :]*)\ /app-2/(.*)     \1\ /app-2-another-path/\2
   server server 168.192.X.X

Here is more information on reqirep.

like image 172
Gooner Avatar answered Sep 18 '22 11:09

Gooner