Skip to content

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

License

Notifications You must be signed in to change notification settings

asmarques/fcgipledge

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages