Hello Chad, List,
Thanks for the nice article
https://www.haproxy.com/blog/introduction-to-haproxy-acls/
However one of the examples that shows how to use cache-store seems flawed..
Attached ive made a little varnishtest, that:
- fails to run success-full when repeated 100 times with the path_beg
acl on 1.8.14 (some requests are send twice to the s1 server, which
stops listening after 1..) but its about 6% of runs that fails..
- produces core dumps with 1.9-dev4-1ff7633
Using the var(txn.path) instead it succeeds on both versions.
I think its important to 'fix' the article (and perhaps include the
cache section declaration also), and perhaps investigate why haproxy
does seem to try and process the fetch it warns about on startup that it
would/should never match..
Regards,
PiBa-NL (Pieter)
# Checks that basic cache is working
varnishtest "Checks that basic cache is working"
feature ignore_unknown_macro
server s1 {
rxreq
txresp -bodylen 50
} -start
syslog Slg_1 -level notice {
recv
expect ~ "Proxy fe1 started"
recv
expect ~ "Proxy b1 started"
recv info
expect ~ "fe1 b1/srv1"
recv info
expect ~ "fe1 b1/<CACHE>"
recv info
expect ~ "fe1 b1/<CACHE>"
recv info
expect ~ "fe1 b1/<CACHE>"
} -start
haproxy h1 -conf {
global
#nbthread 3
log ${Slg_1_addr}:${Slg_1_port} local0
#log :1514 local0
#nokqueue
stats socket /tmp/haproxy.socket level admin
#log /tmp/log local0
defaults
mode http
#option dontlog-normal
log global
option httplog
timeout connect 3s
timeout client 4s
timeout server 4s
cache icons
total-max-size 10
max-age 60
frontend fe1
bind "fd@${fe_1}"
default_backend b1
backend b1
http-request set-var(txn.MyPath) path
#acl WeCanSafelyCacheThatFile var(txn.MyPath) -m beg /icons/
acl WeCanSafelyCacheThatFile path_beg /icons/
http-request cache-use icons if WeCanSafelyCacheThatFile
http-response cache-store icons if WeCanSafelyCacheThatFile
http-response add-header CacheResponse TRUE if WeCanSafelyCacheThatFile
server srv1 ${s1_addr}:${s1_port}
} -start
client c1 -connect ${h1_fe_1_sock} {
timeout 5
txreq -url /icons/
rxresp
expect resp.status == 200
txreq -url /icons/
rxresp
expect resp.status == 200
} -repeat 2 -run
syslog Slg_1 -wait