We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I create my app and serve it on a nginx proxy config.
my gin app:
package main import ( "net/http" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() r.GET("/ip", func(c *gin.Context) { c.String(http.StatusOK, c.ClientIP()) }) r.Run(":9000") }
my nginx config:
location / { proxy_pass http://localhost:9000; proxy_set_header Host $http_host; proxy_set_header X-Forward-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Appengine-Remote-Addr $remote_addr; add_header Access-Control-Allow-Origin *; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_set_header Accept-Encoding gzip; }
my /etc/hosts config
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
request result:
curl -s http://test.beanbest.net/ip 10.10.10.123 curl -s http://test.beanbest.net/ip ::1 curl -s http://test.beanbest.net/ip 10.10.10.123 curl -s http://test.beanbest.net/ip ::1 curl -s http://test.beanbest.net/ip 10.10.10.123 curl -s http://test.beanbest.net/ip ::1
I expect that it return 10.10.10.123 everytime,But it return ::1 and 10.10.10.123 alternately.
10.10.10.123
::1
The text was updated successfully, but these errors were encountered:
There is a temporary solution below, I will create a new PR to fix this.
You should set the bind address to a IPv4 value:
func main() { r := gin.Default() r.GET("/ip", func(c *gin.Context) { c.String(http.StatusOK, c.ClientIP()) }) r.Run("127.0.0.1:9000") }
Or give a IPv4 upstream address in nginx:
nginx
location / { proxy_pass http://127.0.0.1:9000; proxy_set_header Host $http_host; proxy_set_header X-Forward-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Appengine-Remote-Addr $remote_addr; add_header Access-Control-Allow-Origin *; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_set_header Accept-Encoding gzip; }
Sorry, something went wrong.
Yes, the above method can be used to temporarily circumvent this problem.
And looking forward, Gin will solve this problem completely.
Hi, #2967 has been merged, you can close this issue.
No branches or pull requests
I create my app and serve it on a nginx proxy config.
my gin app:
my nginx config:
my /etc/hosts config
request result:
I expect that it return
10.10.10.123
everytime,But it return::1
and10.10.10.123
alternately.Environment
The text was updated successfully, but these errors were encountered: