0

I have a need to transform the following url (not on the client/browser, but rather between the frontend and backend):

from:

http://myhost.com/opt-in/<some_long_guid>.html

to:

http://myhost.com/api/distributions/<some_long_guid>/opt-in

And then at this point choose an appropriate backend. My haproxy.conf file looks like so:

frontend www-ssl
   #re-write the url from /opt-in/<dist_id>.html to /api/distributions/<dist_id>/opt-in

   acl url_opt-in path_beg /opt-in
   reqrep ^([^\ :]*)\ /opt-in/(.*)\.html     \1\ /api/distributions/\2/opt-in if url_opt-in

   acl url_api path_beg /api/

   #choose the api backend if the path starts with /api
   use_backend api-backend if prod url_api

backend api-backend
   server app-1 10.132.93.224:8080 check
   #get rid of the /api part when forwarding to the backend
   reqrep ^([^\ :]*)\ /api/(.*)     \1\ /\2

I have confirmed that hitting http://myhost.com/api/distributions/<some_long_guid>/opt-in directly works.

However hitting http://myhost.com/opt-in/<some_long_guid>.html gives a 505 - The server does not support the HTTP protocol version used in the request.

Can anyone see why I might be facing this problem?

EDIT: I confirmed that my backend is receiving the request and it is reporting back this 505. I'm trying to see if I can dump the raw-request to see what's happening.

1 Answer 1

1

My reqrep statement was chopping off the HTTP/1.1 after the path. So what was sent to my backend was:

GET /distributions/038c0abb-8873-457d-889c-0b7c32b5f5c0/opt-in

instead of:

/distributions/038c0abb-8873-457d-889c-0b7c32b5f5c0/opt-in HTTP/1.1

I changed the reqrep statement to be:

reqrep ^([^\ :]*)\ /opt-in/(.*)\.html(.*) \1\ /distributions/\2/opt-in\3

Note the: \3 at the end, which will add on the HTTP/1.1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .