Skip to content

Instantly share code, notes, and snippets.

@artickl
Created March 13, 2024 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artickl/f3ea3642500d38a392b7d8bf200d868e to your computer and use it in GitHub Desktop.
Save artickl/f3ea3642500d38a392b7d8bf200d868e to your computer and use it in GitHub Desktop.
NGINX My IP Page
# simple way to show public IP address of the client
# anyone can access it in the browser (like https://ip.example.com)
# or can be used in some scripting (like "curl ip.example.com")
# simply on NGINX functionality without any kind of additional tools or plugins
# just place this nginx config to /etc/nginx/sites-available/ip
# make a link in /etc/nginx/sites-enabled/ ($ ln /etc/nginx/sites-available/ip)
# reload nginx ($ service nginx reload)
server {
server_name ip.*;
listen 80;
listen [::]:80;
#listen [::]:443 ssl;
#listen 443 ssl;
#ssl_certificate %certificate%
#ssl_certificate_key %key%
root /dev/null;
gzip on;
access_log /var/log/nginx/ip.access.log;
error_log /var/log/nginx/ip.error.log crit;
location / {
default_type text/plain;
return 200 "$remote_addr\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment