Skip to content

Commit

Permalink
Merge pull request #331 from kinvolk/enhance-getting-requestIP
Browse files Browse the repository at this point in the history
Allow More forgiving X-Forwarded-For handling
  • Loading branch information
joaquimrocha authored Feb 12, 2021
2 parents 00aa799 + 869049c commit 7dac3d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/nebraska/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,8 @@ func (ctl *controller) processOmahaRequest(c *gin.Context) {
//

func getRequestIP(r *http.Request) string {
ips := strings.Split(r.Header.Get("X-FORWARDED-FOR"), ", ")
if ips[0] != "" && net.ParseIP(ips[0]) != nil {
ips := strings.Split(r.Header.Get("X-FORWARDED-FOR"), ",")
if ips[0] != "" && net.ParseIP(strings.TrimSpace(ips[0])) != nil {
return ips[0]
}
ip, _, _ := net.SplitHostPort(r.RemoteAddr)
Expand Down

0 comments on commit 7dac3d4

Please sign in to comment.