A self-hostable API for obtaining your public IP address.
Find a file
2023-11-14 21:22:35 -05:00
tests Version 0.2.0: 2023-11-13 18:31:54 -05:00
utils Version 0.2.0: 2023-11-13 18:31:54 -05:00
.containerignore Initial commit 2023-11-13 15:34:50 -05:00
.dir-locals.el Change app name to IpMe 2023-11-13 18:04:39 -05:00
.editorconfig Initial commit 2023-11-13 15:34:50 -05:00
.env.example Initial commit 2023-11-13 15:34:50 -05:00
.gitignore Initial commit 2023-11-13 15:34:50 -05:00
compose.yaml Change app name to IpMe 2023-11-13 18:04:39 -05:00
Containerfile Version 0.2.0: 2023-11-13 18:31:54 -05:00
deno.json Initial commit 2023-11-13 15:34:50 -05:00
LICENSE.md Initial commit 2023-11-13 15:34:50 -05:00
main.ts Version 0.3.0 2023-11-14 21:05:52 -05:00
README.org fix: Minor edit to README.org 2023-11-14 21:22:35 -05:00
version.ts Version 0.3.0 2023-11-14 21:05:52 -05:00

IpMe

About

A self-hosted API for obtaining your public IP address.

Live API Usage

An implementation of the API is available at ipme.fosterhangdaan.com.

URL Response Type Sample Output
https://ipme.fosterhangdaan.com text 98.207.254.136
https://ipme.fosterhangdaan.com?format=json json {"ip":"98.207.254.136"}
https://ipme.fosterhangdaan.com?format=jsonp jsonp callback({"ip":"98.207.254.136"})
https://ipme.fosterhangdaan.com?format=jsonp&callback=getIp jsonp getIp({"ip":"98.207.254.136"})

Examples using curl

To get your public IP address in plain text:

curl --silent https://ipme.fosterhangdaan.com

For a response in json format:

curl --silent https://ipme.fosterhangdaan.com?format=json

Self-hosting

Requirements

  • Podman or Docker installed
  • Ports 80 and 443 opened
  • A domain name pointing to the server

For reliable IP address identification, the instance should be hosted on an external server outside of your home or local network.

Compose setup

The following compose.yaml can be used as reference:

version: "3.9"

volumes:
  caddy-data:
    external: true
  caddy-config:
    external: true

networks:
  proxy-tier:
    driver: bridge

services:
  ipme:
    image: code.fosterhangdaan.com/foster/ipme:latest
    container_name: ipme
    restart: unless-stopped
    env_file: .env.ipme
    networks:
      - proxy-tier
  caddy:
    image: docker.io/library/caddy:2-alpine
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy-data:/data
      - caddy-config:/config
    networks:
      - proxy-tier

.env.ipme:

RUN_MODE=prod

Caddyfile:

# Replace this domain with your own
https://ipme.mydomain.com {
  reverse_proxy ipme:8000
}

Run the services

Run podman-compose up to start the services.

The API should be available at the domain you selected. For example: https://ipme.mydomain.com.

Contributing

Please send patches and bug reports by email to one of the maintainers. See the Core maintainers section for a list of contacts.

Refer to this guide if you are not familiar with sending Git patches over email.

Core maintainers

License

https://static.fosterhangdaan.com/images/agplv3-logo.svg

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Copyright

Copyright © 2023 Foster Hangdaan