# =============================================================
# GLOBAL OPTIONS
# =============================================================
{
	acme_dns cloudflare {env.CF_API_TOKEN}
}

# =============================================================
# SNIPPETS
# =============================================================
# Reusable matcher — blocks anything not on the LAN.
# Usage: import internal_only inside any site block.
(internal_only) {
	@blocked not remote_ip 192.168.1.0/24
	respond @blocked "Access denied" 403
}

# =============================================================
# FOUNDRY VTT — public
# =============================================================
foundry.ginnoir.com {
	reverse_proxy foundry:30000
}

foundry2.ginnoir.com {
	reverse_proxy foundry2:30000
}

# =============================================================
# TABLETOP TOOLS — public
# =============================================================
5etools.ginnoir.com {
	reverse_proxy 5etools:80
}

pf2e.ginnoir.com {
	root * /srv/aon
	file_server
}

# =============================================================
# FILE STORAGE — public
# =============================================================
files.ginnoir.com {
	reverse_proxy owncloud:8080
}

# =============================================================
# STATIC SITES — public
# =============================================================
ffttsystems.ginnoir.com {
	root * /srv/ffttsystems
	file_server
}

# =============================================================
# MEDIA REQUESTS — public
# =============================================================
requests.ginnoir.com {
	reverse_proxy overseerr:5055
}

# =============================================================
# MEDIA MANAGEMENT — internal only
# =============================================================
sonarr.ginnoir.com {
	import internal_only
	reverse_proxy sonarr:8989
}

radarr.ginnoir.com {
	import internal_only
	reverse_proxy radarr:7878
}

bazarr.ginnoir.com {
	import internal_only
	reverse_proxy bazarr:6767
}

jackett.ginnoir.com {
	import internal_only
	reverse_proxy jackett:9117
}

prowlarr.ginnoir.com {
	import internal_only
	reverse_proxy prowlarr:9696
}

tautulli.ginnoir.com {
	import internal_only
	reverse_proxy tautulli:8181
}

hydra.ginnoir.com {
	import internal_only
	reverse_proxy nzbhydra2:5076
}

# =============================================================
# DOWNLOAD CLIENTS — internal only
# =============================================================
qbittorrent.ginnoir.com {
	import internal_only
	reverse_proxy qbittorrent:3232
}

deluge.ginnoir.com {
	import internal_only
	reverse_proxy deluge:8112
}

nzbget.ginnoir.com {
	import internal_only
	reverse_proxy nzbget:6789
}

whisparr.ginnoir.com {
	import internal_only
	reverse_proxy whisparr:6969
}

stash.ginnoir.com {
	import internal_only
	reverse_proxy stash:6970
}

# =============================================================
# NOTIFICATIONS & RSS — public
# =============================================================
ntfy.ginnoir.com, http://ntfy.ginnoir.com {
	reverse_proxy ntfy:80
	@httpget {
		protocol http
		method GET
		path_regexp ^/([-_a-z0-9]{0,64}$|docs/|static/)
	}
	redir @httpget https://{host}{uri}
}

freshrss.ginnoir.com {
	reverse_proxy freshrss:80
	@httpget {
		protocol http
		method GET
		path_regexp ^/([-_a-z0-9]{0,64}$|docs/|static/)
	}
	redir @httpget https://{host}{uri}
}

# =============================================================
# RESUME / PORTFOLIO — public
# =============================================================
resume.ginnoir.com, https://resume.ginnoir.com {
	reverse_proxy app:3000
	@httpget {
		protocol http
		method GET
		path_regexp ^/([-_a-z0-9]{0,64}$|docs/|static/)
	}
	redir @httpget https://{host}{uri}
}

j-costa.com, https://j-costa.com {
	tls {
            issuer acme {
                disable_tlsalpn_challenge
            }
	}
	redir * https://resume.ginnoir.com/ginnoir/resume permanent
}

storage.j-costa.com, https://storage.j-costa.com {
	tls {
            issuer acme {
                disable_tlsalpn_challenge
            }
	}
	reverse_proxy resume-minio:9000
	@httpget {
		protocol http
		method GET
		path_regexp ^/([-_a-z0-9]{0,64}$|docs/|static/)
	}
	redir @httpget https://{host}{uri}
}

# =============================================================
# MINIO CONSOLE — internal only
# =============================================================
minio.ginnoir.com {
	import internal_only
	reverse_proxy resume-minio:9001
}

# =============================================================
# FAMAPP & AUTH — public
# =============================================================
fam.ginnoir.com {
	reverse_proxy famapp:3000
}

auth.ginnoir.com {
	reverse_proxy authentik-server:9000
}

dev.ginnoir.com {
       reverse_proxy 192.168.1.74:3000
}
