Skip to content

gin1.7.x经过nginx反代后无法获取真实IP #67

Answered by axiaoxin
axiaoxin asked this question in Q&A
Discussion options

You must be logged in to vote

添加nginx配置:

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;

升级gin到最新版:v1.8.1,修复了之前版本的问题。
webapp无需修改代码,还是和以前一样使用,默认设置了0.0.0.0::为可信proxy,相当于未设置,要进行特殊设置参考gin readme

Replies: 1 comment

Comment options

axiaoxin
Jul 1, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by axiaoxin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant