0

the real published website of the backend server is 192.168.1.6:8888/abc and 192.168.1.7:8888/abc , The ip of haproxy is 192.168.1.5 , how can I set in haproxy that user visit 192.168.1.5:8888/abc, the http request will be forwarded to the real backend server(192.168.1.6:8888/abc and 192.168.1.7:8888/abc) ? the default backend server is 192.168.1.8:8088 and 192.168.1.9. (a default nginx website)

+++++++++++++ My configuration is +++++++++++++++

frontend case3
bind 192.168.1.5:8888

acl abc path_beg -i /abc use_backend abc_servers if abc default_backend nginx1 

backend abc_servers

mode tcp balance roundrobin server abc1 192.168.1.6:8888 cookie server abc2 192.168.1.7:8888 cookie 

backend nginx1

balance roundrobin server master1 192.168.1.8:8888 maxconn 1024 weight 5 check server master2 192.168.1.9:80 maxconn 1024 weight 5 check 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

after it take effect, when i visit 192.168.1.5:8888 , it can visit the first server of nginx1. but when i visit 192.168.1.5:8888/abc, it reports :

////////////////////////////////////////////////////////

 404 Not Found nginx/1.17.9 

////////////////////////////////////////////////////////

1
  • Are you sure HaProxy is running with this configuration? Commented May 5, 2020 at 10:36

1 Answer 1

0

A rudimentary configuration would look as follows:

frontend web.jerrywang.org bind 192.168.1.5:8888 use_backend api_servers if { path_beg /abc/ } # default_backend web_servers # The users will get 503 for anything else backend api_servers balance roundrobin cookie SERVERUSED insert indirect nocache option httpchk HEAD / default-server check maxconn 20 server server1 192.168.1.6:8888 cookie server1 server server2 192.168.1.7:8888 cookie server2 
2
  • thanks for your post, i don't know why i get 404 error Commented May 5, 2020 at 10:10
  • Why the "mode tcp" for the abc_servers backend? And shouldn't you specify a name for the server cookies? Commented May 5, 2020 at 10:25

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.