{
	admin off
	auto_https off
}

:PORT

@protected path / /index.html /css/* /js/* /ro /ro/* /jsonrpc

basicauth @protected {
	ARIA2_USER ARIA2_PWD_ENCRYPT
}

redir /ui / 301
redir /ui/ / 301
redir /rclone /rclone/ 301
redir /files /files/ 301
redir /ro /ro/ 301

reverse_proxy /jsonrpc 127.0.0.1:6800

route /rclone/* {
	uri strip_prefix /rclone
	reverse_proxy 127.0.0.1:5572
}

route /files/* {
	uri strip_prefix /files
	reverse_proxy 127.0.0.1:8080
}

route /ro/* {
	uri strip_prefix /ro
	root * /data
	file_server {
		browse "{$CADDY_FILE_SERVER_BROWSE_HTML}"
	}
}

route /ping {
	respond "app version: {env.APP_VERSION}"
}

root * /usr/local/www/aria2
file_server

encode gzip
log {
	output stderr
}
