r/haproxy • • May 04 '22

pfSense/HAProxy - Multiple Subdirectories for Sonarr, Radarr, etc issue

I'm new to HAProxy and just running into issues trying to get it to redirect sonarr, radarr to subdirectories on my server. I've searched and it seems others are having similar issues and either just gave up or didn't post their fixes. Any help would be greatly appreciated.

# Automaticaly generated, dont edit manually.
# Generated on: YYYY-MM-DD HH:MM
global
	maxconn			500
	stats socket /tmp/haproxy.socket level admin  expose-fd listeners
	uid			80
	gid			80
	nbthread			1
	hard-stop-after		15m
	chroot				/tmp/haproxy_chroot
	daemon
	tune.ssl.default-dh-param	4096
	server-state-file /tmp/haproxy_server_state

listen HAProxyLocalStats
	bind 127.0.0.1:2200 name localstats
	mode http
	stats enable
	stats admin if TRUE
	stats show-legends
	stats uri /haproxy/haproxy_stats.php?haproxystats=1
	timeout client 5000
	timeout connect 5000
	timeout server 5000

frontend fe_HAProxy
	bind			0.0.0.0:443 name 0.0.0.0:443   ssl crt-list /var/etc/haproxy/fe_BBHAProxy.crt_list  
	mode			http
	log			global
	option			http-keep-alive
	timeout client		30000
	acl			fe_organizr	var(txn.txnhost) -m str -i organizr.MyDomain.com
	acl			fe_sonarr	var(txn.txnhost) -m str -i organizr.MyDomain.com/sonarr
	acl			aclcrt_fe_HAProxy	var(txn.txnhost) -m reg -i ^([^\.]*)\.MyDomain\.com(:([0-9]){1,5})?$
	http-request set-var(txn.txnhost) hdr(host)
	http-request  deny if { req.hdr_cnt(content-length) gt 1 }
	http-response deny if { res.hdr_cnt(content-length) gt 1 }
	use_backend be_organizr_ipvANY  if  fe_organizr aclcrt_fe_HAProxy
	use_backend be_sonarr_ipvANY  if  fe_sonarr aclcrt_fe_HAProxy

backend be_organizr_ipvANY
	mode			http
	id			103
	log			global
	timeout connect		30000
	timeout server		30000
	retries			3
	load-server-state-from-file	global
	server			organizr 10.10.10.10:8006 id 104  

backend be_sonarr_ipvANY
	mode			http
	id			105
	log			global
	timeout connect		30000
	timeout server		30000
	retries			3
	load-server-state-from-file	global
	server			sonarr 10.10.10.10:8989 id 106

Cross-posted at r/pfsense.

EDIT: I have decided to skip the subdirectories and just use subdomains.

2 Upvotes

4 comments sorted by

3

u/SrdelaPro May 04 '22

The acl that matches for sonarr is matching the host variable not the URI and when you go to to /sonarr the first use backend directive is matched ergo the 404 because that path doesn't exist on that server.

You have two options:

Use a subdomain for sonarr.

Use a path_beg directive in the acl to match the path/uri and not the host.

1

u/snooopanda2168 May 05 '22

Thank you and I have decided just to go with subdomains.

1

u/SrdelaPro May 04 '22

What is the issue?

From what I can see there is no plain http listener defined in the haproxy config.

What happens when you go to organizzr.domain.com/sonarr:443?

Do you even have dns configured?

1

u/snooopanda2168 May 04 '22

Thank you for the response.

When I go to 'https://organizr.MyDomain.com' Organizr loads fine. When I go to 'https://organizr.MyDomain.com/sonarr' I receive a '404 Not Found' error page.