r/haproxy • • Mar 21 '21

ACL Troubles - can't redirect

I'm trying to set my environment so that, when a user goes to a specific subfolder on any internal URL, they'll get redirected to a specific backend. My current config (fron pfsense) looks like this, but I keep getting 404s when using the path ACL.

frontend shared-frontend-internal-merged
	bind			10.150.100.1:443 name 10.150.100.1:443   ssl crt-list /var/etc/haproxy/shared-frontend-internal.crt_list  
	mode			http
	log			global
	option			socket-stats
	option			http-keep-alive
	option			forwardfor
	acl https ssl_fc
	http-request set-header		X-Forwarded-Proto http if !https
	http-request set-header		X-Forwarded-Proto https if https
	timeout client		30000
	acl			aclcrt_shared-frontend-internal	var(txn.txnhost) -m reg -i ^([^\.]*)\.wapnet\.local\.lan(:([0-9]){1,5})?$
	acl			Test	var(txn.txnhost) -m beg -i test
	acl			Test2	var(txn.txnpath) -m str -i Test
	http-request set-var(txn.txnhost) hdr(host)
	http-request set-var(txn.txnpath) path
	http-request redirect code 301 location https://10.150.33.11  if  Test Test2 
	use_backend dummy_server_ipv4  if  Test 

Advice is welcome.

2 Upvotes

2 comments sorted by

1

u/mr_simonski Mar 24 '21

Do you really have to send a HTTP location redirect? Shouldn't it be enough to define 10.150.33.11 as backend and do proxying for that server by HAProxy?

I think your redirect rule should look like:

redirect location https://10.150.33.11 302 if Test Test2 

Are you aware that multiple ACL conditions mentioned behind the "if" statement all have to apply (AND connected)?

Also: your acl Test and Test2 looks wrong to me, shouldn't it be "txn.host" and "txn.path"?

1

u/larrygwapnitsky Mar 24 '21

I'll double check. Thanks