Create a FastCGI server in Go restricted using OpenBSD's pledge
.
- OpenBSD 5.9 or later
No restrictions will be applied to the created server when run on any other OS.
go get github.com/asmarques/fcgipledge
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"
}
...