whatsmyip type of web application written in Python with Flask framework
-
Run as a stand-alone container
docker run -d -p 8080:8080 prestigen/ipask
-
Run with nginx reverse proxy
git clone https://github.com/pnedkov/ipask.git cd ipask/ CN=yordomain.com ./resources/generate_cert.sh docker compose -f compose.yaml up -d
-
If
ipaskis running as a stand-alone application on the default port8080:$ curl <host>:8080 $ wget -qO - <host>:8080
Or navigate to
http://<host>:8080from your browser. -
If
ipaskis running with nginx reverse proxy:$ curl -kL <host> $ wget --no-check-certificate -qO - <host>
Or navigate to
<host>from your browser. It will automatically redirect to https. -
Available URL paths:
Path Alias Description /ipIP address /host/hHostname or FQDN (if REVERSE_DNS_LOOKUPis enabled)/xffX-Forwarded-For header /city/ciCity (if GEOIPis enabled)/region/regRegion (if GEOIPis enabled)/country/coCountry (if GEOIPis enabled)/location/locGPS Coordinates (if GEOIPis enabled)/uaUser-Agent request header /headers/heAll headers /version/verApplication version (commit hash)
-
Install Git and Python:
sudo pacman -S git python -
Clone the git repository:
git clone https://github.com/pnedkov/ipask.git cd ipask/ -
Create and activate the Python virtual environment:
python -m venv .venv source .venv/bin/activate -
Install the required Python packages:
pip install -r requirements.txt
-
(Optional) Download the GeoIP database:
The GeoIP feature is toggled with the
GEOIPenvironment variable which is disabled by default. EnablingGEOIPwould not do any good if the client's IP address is from a private network. TheGeoLite2-City.mmdbfile is being included in the container - check theDockerfile.Credit: https://github.com/P3TERX/GeoLite.mmdb
- wget:
wget git.io/GeoLite2-City.mmdb -P resources/ - curl:
curl -L git.io/GeoLite2-City.mmdb -o resources/GeoLite2-City.mmdb
- wget:
-
Environment variables:
Environment variable Default value GEOIP falseREVERSE_DNS_LOOKUP false
-
Run using
run.py:python run.py
Example:
REVERSE_DNS_LOOKUP=true python run.py
-
Run using
run.sh(recommended):This will run the application with the Python WSGI HTTP Server - gunicorn:
./run.sh
Gunicorn-specific environment variables:
Environment variable Default value GUNICORN_SERVER ipaskGUNICORN_WORKERS CPU Cores * 2 + 1GUNICORN_THREADS 1Example:
REVERSE_DNS_LOOKUP=true GUNICORN_WORKERS=3 ./run.sh
sudo pacman -S git docker docker-compose docker-buildx
sudo usermod -aG docker $USER
sudo systemctl enable --now docker.service
git clone https://github.com/pnedkov/ipask.git
cd ipask/-
Build:
docker build -t ipask . -
Run:
docker run -d -p 8080:8080 ipask
-
Generate a self-signed test key-pair utilized by nginx
CN=yourdomain.com ./resources/generate_cert.sh
-
Build and run
docker compose up -d