Skip to main content

A simple Flask app that returns the value of the `X-Forwarded-For` header

Project description

FlaskEchoIP

$ curl -L ip.jb2170.com
12.34.56.78

A simple Flask app that returns the value of the X-Forwarded-For header, so one can get their public IP address.

No more need for $ curl -L -D - ipconfig.org and its unnecessary cookies!

Installing

I run this as a reverse proxy via Apache. Example systemd unit files and friends are in daemon-files of this repo

  • create a venv, say in ~/.local/var/lib/FlaskEchoIP, and source it
  • $ pip install FlaskEchoIP gunicorn
  • place the systemd unit file and shell script into the correct folders, for example I use ~/.local/var/lib/systemd/{etc/user,usr/bin}
  • place the .htaccess file in the public http folder corresponding to the domain you want to serve the app from
  • adjust the unix socket path in the .htaccess file and .service unit

Make sure you have the headers, proxy, and proxy_http modules enabled for Apache!

You can probably figure out the rest, enabling / starting the systemd service...

Customizing

Setting the environment variable FORWARDED_IP_HEADER_NAME=X-Sneed-Chuck makes the app return the X-Sneed-Chuck header value instead. (perhaps nginx uses something different than X-Forwarded-For.)

See also

  • WSGIEchoIP, a raw WSGI version of this app that I also made, now archived, which was the basis for this one
  • FlaskBump, a simple Flask app that counts the number of requests to it

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flaskechoip-2.0.0.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FlaskEchoIP-2.0.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file flaskechoip-2.0.0.tar.gz.

File metadata

  • Download URL: flaskechoip-2.0.0.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.7

File hashes

Hashes for flaskechoip-2.0.0.tar.gz
Algorithm Hash digest
SHA256 659a0abbcb904e8fafd891dfc7df9e6565361463b2d5860d25f5ea98b7a66d9b
MD5 d1fe15136a05958ad287d9ebabd01afc
BLAKE2b-256 858c1bed096234026a3462771d8847f126073688f075446f084d90ebc82cb202

See more details on using hashes here.

File details

Details for the file FlaskEchoIP-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: FlaskEchoIP-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.7

File hashes

Hashes for FlaskEchoIP-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e6b1b4d88c589049d24770d2896df22e2a19e371068d09202d6a0915a6b8a48
MD5 f81dd421cd1ea2778d74cd9ecedd1fba
BLAKE2b-256 d9da7bb07191e8c4daa1b714e603d95c3ed7114e495100b3e41f1babcf1b8cc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page