nginx instructions comment
This commit is contained in:
parent
ad6bf412b4
commit
649d6d3858
|
@ -0,0 +1,4 @@
|
||||||
|
Requires
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
in nginx server config
|
||||||
|
|
3
main.go
3
main.go
|
@ -61,6 +61,9 @@ func listen(listenPort, proxyPort int) {
|
||||||
func filter(res http.ResponseWriter, req *http.Request, listenPort, proxyPort int) {
|
func filter(res http.ResponseWriter, req *http.Request, listenPort, proxyPort int) {
|
||||||
ip := req.RemoteAddr
|
ip := req.RemoteAddr
|
||||||
|
|
||||||
|
// requires
|
||||||
|
// proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
// in nginx server config
|
||||||
if realIp := req.Header.Get("X-Real-IP"); realIp != "" {
|
if realIp := req.Header.Get("X-Real-IP"); realIp != "" {
|
||||||
ip = realIp
|
ip = realIp
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue