This plugin allows Caddy to serve .NET applications directly.
To use this plugin, you need to build Caddy with the plugin included. The easiest way to do this is using xcaddy
. Follow these steps:
-
Ensure you have Go installed on your system (version 1.22.5 or later).
-
Install
xcaddy
if you haven't already:go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
-
Build Caddy with the .NET plugin:
xcaddy build --with github.com/zacuke/caddy-dotnet
This command will build a Caddy binary that includes the .NET plugin. The binary will be named caddy
and will be in your current directory. Replace the binary on server to enable plugin.
To use the plugin, you need to configure it in your Caddyfile. Here's a sample configuration:
:80 {
route {
dotnet {
exec_path /usr/bin/dotnet
working_dir /var/www/example
args /var/www/example/example.dll arg2
env_vars ASPNETCORE_ENVIRONMENT=Test KEY2=VALUE2
syslog_output
}
}
}
exec_path
: Path to your .NET application executable or /usr/bin/dotnet (required)working_dir
: Working directory for your .NET applicationargs
: Additional arguments to pass to your .NET application or specify .NET application dll when exec_path=/usr/bin/dotnetenv_vars
: Environment variables to set for your .NET applicationsyslog_output
: If present, redirects the .NET application's output to syslogsocket
: Optional parameter to specify Unix socket path
- This plugin proxies http traffic over Unix socket for communication between Caddy and your .NET application.
- The --urls parameter is added to your .NET application to listen to Unix socket.
- The plugin will start your .NET application automatically when Caddy starts.
- The process runs under caddy user and forking .NET process as www-data (or specified user) is a desired feature but not currently implemented.
- WebSocket support is included.
For more detailed information about Caddy and its configuration, please refer to the official Caddy documentation.