# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# THIS IS AN EXPERIMENTAL FEATURE
# DO NOT USE THIS IN PRODUCTION, YOU HAVE BEEN WARNED.
{
	metrics
	frankenphp {
		num_threads 192
		max_threads 256
		# max_requests 500
	}
}

localhost {
	php_server {
		worker {
			file index.php
			num 32
			watch
			match /index.php/*
		}
		worker {
			file remote.php
			num 32
			watch
			match /remote.php/*
		}
		worker {
			file ocs/v1.php
			num 32
			watch
			match /ocs/v1.php/*
			match /ocs/v2.php/*
		}
	}

	log {
		level ERROR
		output stderr
	}

	encode gzip

	redir /.well-known/carddav /remote.php/dav 301
	redir /.well-known/caldav /remote.php/dav 301

	# Rule: Maps most RFC 8615 compliant well-known URIs to our main frontend controller (/index.php) by default
	@wellKnown {
		path "/.well-known/"
		not {
			path /.well-known/acme-challenge
			path /.well-known/pki-validation
		}
	}
	rewrite @wellKnown /index.php

	rewrite /ocm-provider/ /index.php

	@forbidden {
		path /.htaccess
		path /data/*
		path /config/*
		path /db_structure
		path /.xml
		path /README
		path /3rdparty/*
		path /lib/*
		path /templates/*
		path /occ
		path /build
		path /tests
		path /console.php
		path /autotest
		path /issue
		path /indi
		path /db_
		path /console
	}
	respond @forbidden 404
}
