Skip to content

Instantly share code, notes, and snippets.

@sebble
Last active September 11, 2015 03:02
Show Gist options
  • Save sebble/f3b21711524313090b7a to your computer and use it in GitHub Desktop.
Save sebble/f3b21711524313090b7a to your computer and use it in GitHub Desktop.
Nginx Remote IP
map $http_user_agent $mode {
default 'plain';
~*(Mozilla) 'html';
}
map $http_user_agent $html {
default '';
~*(Mozilla) '<title>$remote_addr</title>';
}
server {
listen 80;
server_name example.com;
location = /ip {
more_set_headers 'Content-Type: text/$mode';
echo -n $html;
echo -n $remote_addr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment