Where does the Go language library file be placed? How to get the remote address correctly after using Nginx proxy

Source: Internet
Author: User

  

/usr/local/cellar/go/1.5.1/libexec/src/

Where is his remoteaddr obtained?

Func (c *conn) remoteaddr () Addr {if!c.ok () {return Nil}return c.fd.raddr}

The use of the remote address of the Nginx agent is not correct, both 127.0.0.1, the solution needs to configure Nginx

Server {Listen the;        server_name localhost; Location/{root HTML;                            Index index.html index.htm; Proxy_pass http://backend;Proxy_redirect off;           Proxy_set_header Host $host; Proxy_set_header X-real-IP $remote _addr; Proxy_set_header X-forwarded-For $proxy _add_x_forwarded_for; # Proxy_set_header X-forwarded-For $http _x_forwarded_for; } scenario 1nginx here is an assignment operation, as follows: Proxy_set_header X-real-IP $remote _addr, where this x-REAL-IP is a custom variable name, the name can be arbitrarily taken, so that after the user's real IP is placed in the variable X-real-ip, and then, on the web side can be obtained:

The previous head map has

map[user-agent:[apache-httpclient/4.2.6 (Java 1.5)] connection:[keep-alive] Content-type:[application/json] Accept-encoding:[gzip] content-length:[99]

After adding the configuration, there is

: Map[connection:[close] content-length:[99] Content-type:[application/json] Accept-encoding:[gzip] User-Agent:[ apache-httpclient/4.2.6 (Java 1.5)] x-real-ip:[192.168.100.103] x-forwarded-for:[192.168.100.103]


Where does the Go language library file be placed? How to get the remote address correctly after using Nginx proxy

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.