Пытаюсь написать простое приложение на GO
package main
import (
"net"
"net/http"
"net/http/fcgi"
"os"
)
func main() {
s := "/tmp/go.sock"
os.Remove(s)
l, err := net.Listen("unix", s)
if err != nil {
os.Exit(2)
}
fs := new(FCgiServer)
fcgi.Serve(l, fs)
}
type (
FCgiServer struct {}
)
func (this *FCgiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
defer func() {
if err := recover(); err != nil {
w.WriteHeader(500)
w.Write([]byte(`500 Server error`))
}
}()
w.Write([]byte(`OK Server<br>text`))
}
конфиг для nginx:
server {
listen 80;
root /home/username/go/src/github.com/i-zemlya/cli/public;
location ~ {
try_files $uri = 404;
fastcgi_pass unix:/tmp/go.sock;
include fastcgi_params;
}
}
в логах nginx`a получаю ошибки:
2019/04/04 12:00:00 [error] 444#444: *1 rewrite or internal redirection cycle while internally redirecting to "404", client: 127.0.0.1, server: 127.0.0.1, request: "GET / HTTP/1.1", host: "127.0.0.1:80"
2019/04/04 12:00:00 [error] 444#444: *2 rewrite or internal redirection cycle while internally redirecting to "404", client: 127.0.0.1, server: 127.0.0.1, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:80", referrer: "http://127.0.0.1:80/"