IPInfo
Basic IP and Hostname checker
Returns external IPs and Hostnamse for the client when called in JSON format
Parses request Headers X-Forwarded-For and X-Real-IP as well as RemoteAddr and returns a JSON list if multiple IPs are discovered.
Private and Loopback addresses are ignored and not returned
Quickstart
Local testing
podman run -p 8080 registry.gitlab.com/jandourekjaroslav/ipinfo:latest
curl -H "X-Forwarded-For: 1.1.1.1" localhost:8080
Deployment
-
Start the service as a container To change the port from the default 8080 pass
SERVICE_PORTas ENVpodman run -d -p 8080 registry.gitlab.com/jandourekjaroslav/ipinfo:latest -
Create an nginx conf file to direct traffic to it
server { server_name ip.yourhostnamehere.com www.ip.yourhostnamehere.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:8080; } listen [::]:80 ; listen 80; } -
Test your config and restart nginx
nginx -t && systemctl restart nginx -
Test it out
curl http://ip.yourhostnamehere.comThe expected output should look something like this:
[ { "ip": "1.1.1.1", "hostnames": ["one.one.one.one."] } ]