How to make HAProxy redirect traffic via a certain sub-proxy depending on URL?
from maximalian@sopuli.xyz to programming@programming.dev on 22 Jun 18:29
https://sopuli.xyz/post/14090301

I have a server (S-1) with HAProxy and a number of residential proxies (PR-s) as login-passwords-port. There’re multiple users who will connect to the internet via S-1.

I want to have HAProxy to forward incomming traffic of the users via a random proxy amoung PR-s with 2 conditions:

  1. only when there’s certain, pre-defined keyword in the URL, traffic must be routed via a proxy.
  2. In all other cases, it must go to a requested resource directly as is, without a proxy

How would I implement this?


(1) client -> HaProxy -> if keyword --> sub-proxy (random) -> website

(2) client -> HaProxy -> if no keyword --> website

#programming

threaded - newest

colonelp4nic@lemmy.world on 22 Jun 20:47 collapse

Maybe have two cases:
For the (matched keyword) case, something like this: serverfault.com/…/reg-exp-for-url-in-haproxy

For the (random routing) case, something like: haproxy.com/…/haproxy-configuration-basics-load-b…

I am a little confused on your question, though. It sounds like you maybe want 3 cases? Can you try wording it differently?

maximalian@sopuli.xyz on 22 Jun 23:21 collapse

  1. client -> HaProxy -> if keyword --> sub-proxy (random) -> website
  2. client -> HaProxy -> if no keyword --> website
colonelp4nic@lemmy.world on 22 Jun 23:37 collapse

Cool, I think that first link will work for you. Then you can just ‘redirect’ for the no-keyword case: www.haproxy.com/documentation/…/http-redirects/

Remember, SSL/HTTPS does encrypt the URL path, so if the final website requires HTTPS, your proxy will need to have its certificate trusted by your clients

maximalian@sopuli.xyz on 23 Jun 17:34 collapse

will try, thx