D
D
dimjkee902021-08-10 14:47:36
HAproxy
dimjkee90, 2021-08-10 14:47:36

How to redirect a request to haproxy?

Good afternoon!
Tell me how to implement the trace scheme in haproxy, it was possible to do this through Nginx, but you need to do it through Haproxy, which is not very strong

Request like https://1.1.1.1/partner/transparent
Redirect to
https://2.2.2.2/my.FrontEnd. ServiceProvider2/partn...
parameters must be passed as is, for example, the request

https://1.1.1.1/partner/transparent?partner_id=111...

should be executed

https://2.2.2.2/my.FrontEnd.ServiceProvider2/partn ...

I turned to the Haproxy documentation, tried the options but something didn’t work out, I got the page looping
, there is also a location /status

frontend stats
bind *: 9000
stats enable
stats uri /stats
stats refresh 10s
stats admin if LOCALHOST

frontend IN

bind *:443 ssl crt /etc/haproxy/ssl/cert.pem
mode http
option httplog
# redirect scheme https if !{ ssl_fc }

acl host_status path_beg /status
acl host_partner path_beg /partner/transparent

# http-request redirect code 301 prefix /status unless host_status
# http-request add-header X-Forwarded-For %[src] unless host_status
# http-request redirect code 301 prefix /partner/transparent unless host_partner

use_backend status if host_status
use_backend partner if host_partner

#===========================backend===================== =#

backend status
mode http
option forwardfor
http-request redirect location https://2.2.2.2/my.FrontEnd.ServiceProvider2/status

backend partner
mode http
option forwardfor
http-request redirect location https://2.2.2.2/my.FrontEnd .ServiceProvider2/partn...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dimjkee90, 2021-08-10
@dimjkee90

this worked for me
frontend IN
bind *:443 ssl crt /etc/haproxy/ssl/cert.pem
mode http
option httplog
acl host_status path_beg /status
http-request redirect code 301 location %[url,regsub(^/status, https: //2.2.2.2/my.FrontEnd.ServiceProvider2/status ,)] if { path_beg /status }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question