How to get real client ip when using lxd to forward port 80

That should be the proxy protocol (also in the second link that @roka wrote earlier),
http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt (implementations in Section 3 or https://www.haproxy.com/blog/haproxy/proxy-protocol/).

There are two versions, 1 (textual) and 2 (binary).
Here is a Go implementation of both versions, GitHub - pires/go-proxyproto: A Go library implementation of the PROXY protocol, versions 1 and 2. (Apache License 2.0).