Created
January 15, 2021 21:19
-
-
Save lstellway/15cbe998d2625e52462563ef71533e84 to your computer and use it in GitHub Desktop.
Simple NGINX config to return real client IP address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map ":$http_x_forwarded_for" $IP_ADDR { | |
":" $remote_addr; # Forwarded for not set | |
default $http_x_forwarded_for; # Forwarded for is set | |
} | |
server { | |
server_name example.com; | |
listen 80; | |
listen [::]:80; | |
location / { | |
default_type application/json; | |
return 200 "{\"ip\": \"$IP_ADDR\"}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment