gitlab mail
jj jj

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

  1. Start the service as a container To change the port from the default 8080 pass SERVICE_PORT as ENV

    podman run -d -p 8080 registry.gitlab.com/jandourekjaroslav/ipinfo:latest
    
  2. 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;
    
    }
    
  3. Test your config and restart nginx

    nginx -t && systemctl restart nginx
    
  4. Test it out

    curl http://ip.yourhostnamehere.com
    

    The expected output should look something like this:

    [
      {
        "ip": "1.1.1.1",
        "hostnames": ["one.one.one.one."]
      }
    ]
    
source url ssh clone url http clone url