Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAProxy redirect requests from one port to another

I'm using HAProxy version 1.6.

How would I modify the config to redirect requests from: localhost:8081/myapp

to: localhost:8111/myapp

Thanks!

like image 508
ddelponte Avatar asked Oct 26 '25 16:10

ddelponte


2 Answers

frontend weblb
bind *:8081
acl if is_seller url_beg /myapp  
use_backend sellerserver if is_seller

backend sellerserver
balance source
server web1 127.0.0.1:8111 maxconn 1024 weight 3 check inter 2000 rise 2 fall 3
like image 155
lanni654321 Avatar answered Oct 29 '25 18:10

lanni654321


You could try using replace-value on the Host header:

http-request replace-value Host localhost:8081 localhost:8111

Which is nice because it also supports regexes:

http-request replace-value Host (.*):8081 \1:8111
like image 21
den-chan Avatar answered Oct 29 '25 19:10

den-chan