IP Info page with geoip detection. Written in PHP, built with Twig, Bootstrap and GeoIP2. Supports CloudFlare.
PHP | Composer | geoip2/geoip2 | twbs/bootstrap | twig/twig | Globe Africa icon by Icons8
- Install Composer (PHP modules required: curl, mbstring, openssl, phar)
- Download required libraries:
php composer.phar update
- Download GeoIP2 Lite database, edit config.php and change the path to the GeoLite2-City.mmdb file respectively.
- Edit manifest.json and change
start_url
for PWA.
git clone https://github.com/c0m4r/ip-info-page.git
cd ip-info-page
wget https://getcomposer.org/download/2.7.9/composer.phar
echo "b6de5e65c199d80ba11897fbe1364e063e858d483f6a81a176c4d60f2b1d6347 composer.phar" | sha256sum -c || rm composer.phar
php composer.phar update
Now available on the Docker Hub
Quick setup:
docker run --name ipp -p 127.0.0.1:8080:80 -d c0m4r/ip-info-page
With GeoIP module:
docker run --name ipp -v ./GeoLite2-City.mmdb:/var/www/html/GeoLite2-City.mmdb -p 127.0.0.1:8080:80 -d c0m4r/ip-info-page
You can also build it yourself:
git clone https://github.com/c0m4r/ip-info-page.git
cd ip-info-page
wget https://getcomposer.org/download/2.7.9/composer.phar
echo "b6de5e65c199d80ba11897fbe1364e063e858d483f6a81a176c4d60f2b1d6347 composer.phar" | sha256sum -c || rm composer.phar
php composer.phar update
docker compose up -d
If request is sent using curl or wget, it will print IP info in JSON:
{
"ip": "127.0.0.1",
"geoip": true,
"country": "Poland",
"region": "Masovian Voivodeship",
"city": "Warsaw",
"postal": "00-022",
"ua": "curl\/8.5.0"
}
In the case of being unable to read the geoip data, it will set geoip => false
and print only IP and UA information.
When behind CloudFlare it will use CF-Connecting-IP HTTP Header for IP detection. While using curl keep in mind that things like Bot Fight Mode and Browser Integrity Check will most likely prevent you from reading anything, due to the altered javascript challenge page.
For other proxies X-Forwarded-For is used.
MIT License
Copyright (c) 2023 c0m4r
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
If you found this software helpful, please consider making donation to a charity on my behalf. Thank you.