0

I am using HAProxy 1.8, I need to make redirection rules, but I do not know the tool well, I have tried but it fails me in some particular cases with different clients.

Client Applications: Adobe Flex 3 (Web) and .Net (Web, WebServices and Desktop).

Necessary redirection example:

Current URL: http://oldsite.com/WS/WSInfo/WSDataClient

URL redirection: http://web1.site.com/WS/WSInfo/WSDataClient

I must perform several redirects (so I have to repeat the rule many times), I can not redirect all "olsite.com" to "web1.site.com", since both balancers will have concurrent calls, not all services, "http://oldsite.com" will stop being used.

The rule of HAProxy:

###----SERV_WSInfo_WSDataClient_test acl withwsdl_SERV_WSInfo_WSDataClient url /WS/WSInfo/WSDataClient_test?wsdl acl notwsdl_SERV_WSInfo_WSDataClient path_beg /WS/WSInfo/WSDataClient_test http-request redirect location http://web1.site.com/WS/WSInfo/WSDataClient?%[query] code 301 if withwsdl_SERV_WSInfo_WSDataClient http-request redirect location http://web1.site.com/WS/WSInfo/WSDataClient code 301 if notwsdl_SERV_WSInfo_WSDataClient 

This works in the Flex applications that consume it, but not in the .Net point, I have been able to detect that:

Flex calls WSDL twice from the service (I suspect that by the redirect of the rule), but it works. .Net, on the other hand, never asks for the WSDL and the service returns error, blank response.

  1. Someone can recommend how would be the correct way to implement the rule to achieve the necessary redirection.
  2. To redirect an HTTPS with that same URL, should I add more logic?

  3. They think that I'm not using the necessary tool to do it, they can recommend another one (currently HAProxy is used but if I manage to make it work in another Proxy, I could ask to evaluate).

I thank you for your help since I do not use the tool and I am not from the network area.

2
  • Can you confirm that the their a seperate HA Proxy for oldsite.com and web1.site.com (as in the rules wont interfere) Commented Mar 16, 2018 at 2:52
  • Hello Nico, they are different balancers, one is a server where I have services in 1 technology and the other server in a different one, I am migrating them but I must do it for each WS (in batches) so they generated a HAProxy and left the roll of the oldsite to the servers olsite1 and oldsite2, leaving the rules in the same HAProxy. It is understood? Thanks for your question. Commented Mar 16, 2018 at 2:57

1 Answer 1

1

Given they are both on different HAProxy servers makes it a bit easier as you dont need to worry about an acl for the new domain. Here is a simple acl that doesnt worry about the querystring at all.

acl is_SERV_TEST url_beg -i /WS/WSInfo/WSDataClient

This acl checks the beginning of the url (case insensitive with the -i) against our url we need to redirec the prefix (host).

http-request redirect code 301 prefix http://web1.site.com if is_SERV_TEST

The redirection simply changes the prefix and maintains the remainder of the URL. For this reason we dont need to worry about the query string etc.

Full Code

acl is_SERV_TEST url_beg -i /WS/WSInfo/WSDataClient http-request redirect code 301 prefix http://web1.site.com if is_SERV_TEST 

SSL Question

For SSL related rewrites this is a double edge sword, and this is against the requirement of the company. For example if you want all request from http://oldsite.com to go to the SSL (HTTPS) url for web1.site.com then you should be doing that in your 301 redirect.

So you would simply change the rewrite prefix to https://web1.site.com.

Finally if you also need to mange the 301 redirect for ssl (ie over port 443) you should create another listener frontend binding to :443 and use the same rules as your port :80 listener.

Sign up to request clarification or add additional context in comments.

4 Comments

I understand I should do 2 ACL one for when the WSDL comes and another for when it does not come in the url. I will try to do what you say with the network administrator and comment. Thank you very much for your time and help.
No need to worry about the query string as that is irrelevant to the redirect (meaning they both end up at the same destination). You will only need the 1 acl as the url_beg matches the begining of the url and instead of redirecting the entire URL we only change the prefix (hostname)
Very clear thank you very much Nico, just have the tests, I comment here and give you your points for help. Thank you again.
Hi Nico, same effect, do you know where I can check, what's the problem shooting?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.