Skip to content

Commit

Permalink
Content Switching is initiated
Browse files Browse the repository at this point in the history
  • Loading branch information
Gharib110 committed Mar 6, 2024
1 parent 901ae2d commit f64d0d8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ``
-
28 changes: 28 additions & 0 deletions haproxy.csw.cfg
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f64d0d8

Please sign in to comment.