Tung Nguyen
Tung Nguyen

Reputation: 1924

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.

Upvotes: 10

Views: 28929

Answers (1)

Gooner
Gooner

Reputation: 1590

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.

Upvotes: 25

Related Questions