Answer the question
In order to leave comments, you need to log in
Nginx not working with GO over socket?
Nginx does not work with GO via socket, what could be the reason?
//GO
package main
import (
"fmt"
"net"
"net/http"
"net/http/fcgi"
)
func handler(res http.ResponseWriter, req *http.Request) {
fmt.Fprint(res, "Hello World!")
}
func main() {
// For local machine
l, err := net.Listen("unix", "/var/run/go-fcgi.sock")
if err != nil {
return
}
http.HandleFunc("/", handler)
fcgi.Serve(l, nil)
}
//Nginx
server {
listen 122.20.34.85:80;
server_name mysite.com;
access_log off;
error_log /dev/null crit;
location / {
include fastcgi_params;
fastcgi_pass unix:/var/run/go-fcgi.sock;
}
}
Answer the question
In order to leave comments, you need to log in
At the end of the Main function write http.ListenAndServe(":8080", nil) and listen to localhost on port 8080
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question