fcgipledge

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 6 Imported by: 0

README

fcgipledge

Go Reference Build Status

Create a FastCGI server in Go restricted using OpenBSD's pledge.

Requirements

  • OpenBSD 5.9 or later

No restrictions will be applied to the created server when run on any other OS.

Installation

go get github.com/asmarques/fcgipledge

Usage

package main

import (
	"fmt"
	"net/http"

	"github.com/asmarques/fcgipledge"
)

func main() {
	path := "/run/fcgi.sock"

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "Hello world")
	})

	fcgipledge.ListenAndServe(path, nil, nil)
}

To forward requests from OpenBSD's httpd to a running server just add a reference to the socket in httpd.conf:

...

server "www.example.com" {
        ...
        fastcgi socket "/run/fcgi.sock"
}

...

License

MIT

Documentation

Index

Constants

View Source
const (
	Stdio   = "stdio"
	Inet    = "inet"
	Unix    = "unix"
	DNS     = "dns"
	Rpath   = "rpath"
	Wpath   = "wpath"
	Cpath   = "cpath"
	Tmppath = "tmppath"
)

Common promises for pledge()

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(name string, handler http.Handler, config *Config) error

ListenAndServe starts a FastCGI server listening on a Unix domain socket and restricts further operations using OpenBSD's pledge() mechanism. The supplied handler will be used to handle incoming requests. If handler is nil the http.DefaultServeMux will be used. By default the process will be unable to perform any syscalls except for those required to communicate via the created socket (equivalent to supplying "stdio" and "unix" promises).

Types

type Config

type Config struct {
	Promises []string
}

Config represents the server configuration

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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