In the golang gin controller
c.ClientIP()
Gets the IP of the request, but gets 127.0.0.1.
Presumably Nginx was not configured when it forwarded the request to golang process.
Solutions
Just add two lines to the configuration.
location /go/ {
proxy_set_header X-Forward-For $remote_addr;
proxy_set_header X-real-ip $remote_addr;
proxy_pass http://127.0.0.1:8080/go/;
}
reload nginx, test, OK.