1. 程式人生 > >Haproxy配置之URL重寫,支持websocket

Haproxy配置之URL重寫,支持websocket

check 文件 位置 nec haproxy pan haproxy配置 url doc

配置文件位置:/etc/haproxy/haproxy.cfg

Reqrep 正則重寫

配置詳情:

 1 Frontend App *:80
 2        acl uri_api             path_beg    /api/
 3        acl uri_web           path_beg    /
 4        acl uri_docs          path_beg    /docs/
 5        acl uri_socket       hdr(Upgrade) -i Websocket
 6        acl uri_socket       hdr_beg(Host) -i ws
7 8 Use_backend api if uri_api 9 Use_backend socket if uri_socket 10 Use_backend web if uri_web 11 Use_backend docs if uri_docs 12 13 Backend api 14 balance roundrobin 15 reqrep ^([^\ ]*\ /)api[/]?(*) \1\2 16 server server1 10.0
.0.1:8080 check 17 18 Backend socket 19 balance roundrobin 20 timeout queue 1h 21 timeout server 1h 22 timeout connect 1h 23 server server1 10.0.0.1:8443 check 24 25 Backend web 26 balance roundrobin 27 server server1 10.0.0.2:8080 check 28 29
Backend docs 30 balance roundrobin 31 server server1 10.0.0.2:8080 check

Haproxy配置之URL重寫,支持websocket