You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FYI we are using the manual graceful shutdown approach.
As a result of not calling prepareTrustedCIDRs, the ClientIP function will never trust the X-Forwarded-For or X-Real-IP headers. We are running in a Kube env and all of our requests are coming from an internal proxy IP, so we need to be able to get at the real client IP.
How can we initialise trustedCIDRs if not using the Run() approach. It's internal to engine and during the RemoteIP() check will always be nil: if c.engine.trustedCIDRs != nil {
How to reproduce
Follow the manual approach here and then c.ClientIP() will never trust the IP that forwards proxy requests.
Expectations
c.ClientIP() returns the IP in X-Forwarded-For or X-Real-IP.
Actual result
c.ClientIP() returns the internal IP of the proxy e.g. 192.168.10.20.
Environment
go version: 1.17
gin version (or commit ref): 1.7.4
operating system: Debian Buster
The text was updated successfully, but these errors were encountered:
MichaelBurgess
changed the title
How can we initialise trustedCIDRs if using TLS or the manual graceful shutdown approach
How can we initialise trustedCIDRs if using TLS or the manual graceful shutdown approach?
Oct 18, 2021
Hi, this issue has been resolved in #2887 , I believe it will be available in version 1.7.5.
Thanks @Bisstocuz - any ideas when 1.7.5 will be released? Need to work out if I can wait, or implement my own logic in the meanwhile.
About when 1.7.5 will be released, it needs maintainer @appleboy 's answer.
At this point, I recommend you to use proxy server Nginx and Engine.Run() instead temporarily.
Description
If we use the
.Run()
function to launch the server, that function initialises trusted CIDRs:However, the
RunTLS
or manual graceful shutdown approaches don't do this:FYI we are using the manual graceful shutdown approach.
As a result of not calling
prepareTrustedCIDRs
, theClientIP
function will never trust theX-Forwarded-For
orX-Real-IP
headers. We are running in a Kube env and all of our requests are coming from an internal proxy IP, so we need to be able to get at the real client IP.How can we initialise
trustedCIDRs
if not using theRun()
approach. It's internal toengine
and during theRemoteIP()
check will always be nil:if c.engine.trustedCIDRs != nil {
How to reproduce
Follow the manual approach here and then
c.ClientIP()
will never trust the IP that forwards proxy requests.Expectations
c.ClientIP()
returns the IP inX-Forwarded-For
orX-Real-IP
.Actual result
c.ClientIP()
returns the internal IP of the proxy e.g.192.168.10.20
.Environment
1.17
1.7.4
Debian Buster
The text was updated successfully, but these errors were encountered: