Coder Social home page Coder Social logo

pnedkov / ipask Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 73 KB

whatsmyip web application written in Python with Flask framework

Home Page: https://ipask.me

License: GNU General Public License v2.0

Dockerfile 2.75% Shell 4.53% Python 58.41% CSS 13.68% HTML 20.62%
docker flask ifconfig kubernetes python whatsmyip

ipask's Introduction

IP Ask

whatsmyip type of web application written in Python with Flask framework

ipask.me


TL;DR

  • 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

Usage

  • If ipask is running as a stand-alone application on the default port 8080:

    $ curl <host>:8080
    $ wget -qO - <host>:8080

    Or navigate to http://<host>:8080 from your browser.

  • If ipask is 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
    /ip IP address
    /host /h Hostname or FQDN (if REVERSE_DNS_LOOKUP is enabled)
    /xff X-Forwarded-For header
    /city /ci City (if GEOIP is enabled)
    /region /reg Region (if GEOIP is enabled)
    /country /co Country (if GEOIP is enabled)
    /location /loc GPS Coordinates (if GEOIP is enabled)
    /ua User-Agent request header
    /headers /he All headers
    /version /ver Application version (commit hash)

Run from the source code

Prerequisites

  • 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 GEOIP environment variable which is disabled by default. Enabling GEOIP would not do any good if the client's IP address is from a private network. The GeoLite2-City.mmdb file is being included in the container - check the Dockerfile.

    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
      
  • Environment variables:

    Environment variable Default value
    GEOIP false
    REVERSE_DNS_LOOKUP false

Run

  • 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 ipask
    GUNICORN_WORKERS CPU Cores * 2 + 1
    GUNICORN_THREADS 1

    Example:

    REVERSE_DNS_LOOKUP=true GUNICORN_WORKERS=3 ./run.sh

Build and run in a container

Prerequisites:

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 and run as a stand-alone container

  • Build:

    docker build -t ipask .
  • Run:

    docker run -d -p 8080:8080 ipask

Build and run with Docker Compose behind nginx reverse proxy

  • Generate a self-signed test key-pair utilized by nginx

    CN=yourdomain.com ./resources/generate_cert.sh
  • Build and run

    docker compose up -d

Run on AWS Elastic Kubernetes Service

k8s/README.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.