Install your own IPlookup tool

1 minute read

When you want to know your public IP address, you will probably use a tool like

However if we don’t want to rely entirely on an external service and we don’t feel like giving our IP address to unknown strangers we might want to self-host.

To do this we use echoip, a self-hosted IP lookup solution written in Go.

Docker-compose

We use the docker container provided by echoip’s maintainer to deploy the tool. Here is our docker-compose file :

version: '2'
services:
  echoip:
    container_name: 'echoip'
    image: 'mpolden/echoip:latest'
    restart: unless-stopped
    ports:
      - '8085:8080'

Now we just have to start it with docker-compose up -d. Of course, we need Docker and docker-compose installed for it to work.

Nginx config

Now we want to serve our service through ifconfig.domain.com. To do so we configure our subdomain with our domain provider and configure Nginx with a reverse proxy.

Here is the Nginx configuration in the file /etc/nginx/sites-available/ifconfig.domain.com:

server {
    listen *:80;
    server_name eifconfig.domain.com www.ifconfig.domain.com;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://127.0.0.1:8085;
    }
}

We then deploy a certificate for this subdomain with Let’s Encrypt

sudo certbot --nginx -d ifconfig.domain.com -d www.ifconfig.domain.com

And finally we can activate the site :

sudo ln -s /etc/nginx/sites-available/ifconfig.domain.com /etc/nginx/sites-enabled
sudo nginx reload