Skip to content

Commit

Permalink
Get client IP from X-Forwarded-For provided by reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
lavajuno authored Mar 2, 2024
1 parent a0bbf12 commit 2fdd2bc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func socketHandler(w http.ResponseWriter, r *http.Request) {
authenticated := false
if trustedNetworks.Contains(ip) {
// Could be a load balancer, check the X-REAL-IP header
if realIP := r.Header.Get("X-REAL-IP"); realIP != "" {
if realIP := r.Header.Get("X-Forwarded-For"); realIP != "" {
// Check if the real IP is in the trusted network
ip = net.ParseIP(realIP)
if trustedNetworks.Contains(ip) {
Expand Down

0 comments on commit 2fdd2bc

Please sign in to comment.