Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure Caddyfile inside a Standalone application ? #413

Closed
NicolasDierick opened this issue Dec 19, 2023 · 2 comments · Fixed by #494
Closed

How to configure Caddyfile inside a Standalone application ? #413

NicolasDierick opened this issue Dec 19, 2023 · 2 comments · Fixed by #494

Comments

@NicolasDierick
Copy link

NicolasDierick commented Dec 19, 2023

Hello,

first of all, thank you for the 1.0.0 release of FrankenPHP.

I have made some tests and sucessfully built a standalone applications, but i found no documentations on how to configure the embedded Caddyfile.

I mean, i want to deploy the standalone application as a docker image, but when i set Environment variables, it seems that they are not used at all.

So, the question is how to configure this ?

It seems that this default Caddyfile is used:

{
	{$CADDY_GLOBAL_OPTIONS}

	frankenphp {
		#worker /path/to/your/worker.php
		{$FRANKENPHP_CONFIG}
	}

	# https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
	order mercure after encode
	order vulcain after reverse_proxy
	order php_server before file_server
	order php before file_server
}

{$CADDY_EXTRA_CONFIG}

{$SERVER_NAME:localhost} {
	log {
		# Redact the authorization query parameter that can be set by Mercure
		format filter {
			wrap console
			fields {
				uri query {
					replace authorization REDACTED
				}
			}
		}
	}

	root * public/
	encode zstd gzip

	# Uncomment the following lines to enable Mercure and Vulcain modules
	#mercure {
	#	# Transport to use (default to Bolt)
	#	transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
	#	# Publisher JWT key
	#	publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
	#	# Subscriber JWT key
	#	subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
	#	# Allow anonymous subscribers (double-check that it's what you want)
	#	anonymous
	#	# Enable the subscription API (double-check that it's what you want)
	#	subscriptions
	#	# Extra directives
	#	{$MERCURE_EXTRA_DIRECTIVES}
	#}
	#vulcain

	{$CADDY_SERVER_EXTRA_DIRECTIVES}

	php_server
}

Starting the application with this should set the Caddy server name, but it is not working.

SERVER_NAME=test.com:80 ./my-app php-server

(i saw that there was a "./my-app php-server --domain localhost" in the documentation, but would like to understand how to set other things)

Thank you for your help

@dunglas
Copy link
Owner

dunglas commented Dec 21, 2023

Currently, embedding Caddyfile isn't supported and you're limited to the options available through the command line.
However, adding support for Caddyfile at the root of the app directory should be easy enough. I'll try to work on this soon (PR welcome if someone is quicker).

@denwald
Copy link

denwald commented Dec 31, 2023

I tried to run frankenphp standalone with a Caddyfile at the root of my project. I can't make the standalone binary to pick up the Caddyfile for configuration.

Is there a CLI option I need to use? I could not find anything in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants