dotnet

package module
v0.0.0-...-856790d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 22 Imported by: 0

README

Caddy .NET Plugin

This plugin allows Caddy to serve .NET applications directly.

Installation

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:

  1. Ensure you have Go installed on your system (version 1.22.5 or later).

  2. Install xcaddy if you haven't already:

    go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
    
  3. 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.

Usage

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
        }
    }
}
Configuration Options
  • exec_path: Path to your .NET application executable or /usr/bin/dotnet (required)
  • working_dir: Working directory for your .NET application
  • args: Additional arguments to pass to your .NET application or specify .NET application dll when exec_path=/usr/bin/dotnet
  • env_vars: Environment variables to set for your .NET application
  • syslog_output: If present, redirects the .NET application's output to syslog
  • socket: Optional parameter to specify Unix socket path

Notes

  • 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DotNet

type DotNet struct {
	ExecPath     string   `json:"exec_path"`
	Args         []string `json:"args"`
	EnvVars      []string `json:"env_vars"`
	WorkingDir   string   `json:"working_dir"`
	Socket       string   `json:"socket,omitempty"`
	SyslogOutput bool     `json:"syslog_output"`
	// contains filtered or unexported fields
}

DotNet represents the configuration for running a .NET application

func (DotNet) CaddyModule

func (DotNet) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*DotNet) Provision

func (d *DotNet) Provision(ctx caddy.Context) error

Provision sets up the module.

func (DotNet) RoundTrip

func (d DotNet) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

func (DotNet) ServeHTTP

func (d DotNet) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

ServeHTTP implements caddyhttp.MiddlewareHandler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL