diff --git a/README.md b/README.md index 9abc87f..48887a1 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,24 @@ http-request set-header Forwarded for=%[src] - Weighted/Normal LeastConn - Weighted/Normal Hash URI - First Available + +## Content Switching on URL Path +Fetch methods and What they do +- path exact string match +- path_beg URL begins with string +- path_dir subdirectory match +- path_end suffix match +- path_len length match +- path_reg regex match +- path_sub substring match + +## Content Switching on URL Params +- ``acl iswest url_param(region) -i -m str west`` Exact match `` http://mysite.com/?region=west `` and `` -i `` means case-insensitive +- Match multiple strings : `` acl iswest url_param(region) -i -m str west westcoast wc `` +- Regex Matching : `` acl iswest url_param(west) -m reg .+ `` + +## Content Switching on HTTP Headers +- `` acl ismobile req.hdr(User-Agent) -i -m reg (android|iphone) `` Filter the Mobile User-Agents and use a seperate backend for them. reg says contains android or iphone +- Filter based on the Host Header : `` acl ischeapshoes req.hdr(Host) -i -m str www.cheapshoes.com ``, `` acl isexpensiveshoes req.hdr(Host) -i -m str www.expensiveshoes.com `` +- Match more host on on ACL Rule : `` acl ischeapshoes req.hdr(Host) -i -m str cheapshoes.com www.cheapshoes.com `` +- \ No newline at end of file diff --git a/haproxy.csw.cfg b/haproxy.csw.cfg new file mode 100644 index 0000000..282619a --- /dev/null +++ b/haproxy.csw.cfg @@ -0,0 +1,28 @@ +frontend www-http + bind *:81 + mode http + acl is_api path_beg -i /api + use_backend apache2 if is_api + # Exact match : acl jansale path -i /super_sale/january/15 + # Subdirectory : acl isshirts path_dir -i /shirts + # End in : acl isimage path_end -i .jpg .png + # Length of URI: acl exactlyfour path_len 4 + # Regex: acl isimage path_reg (png|jpg|jpeg|gif)$ + # Contains sub-string: acl onsale path_sub -i sale + + default_backend apache + +backend apache + description Our Apache Web servers + mode http + balance roundrobin + server web1 127.0.0.1:8081 + server web5 127.0.0.1:8085 + server web6 127.0.0.1:8086 + +backend apache2 + mode http + balance roundrobin + server web1 127.0.0.1:8082 + server web3 127.0.0.1:8083 + server web4 127.0.0.1:8084 \ No newline at end of file