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
.htaccessfile in the public http folder corresponding to the domain you want to serve the app from - adjust the unix socket path in the
.htaccessfile and.serviceunit
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
Metadata
Release files for FlaskEchoIP 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flaskechoip-2.0.0.tar.gz | 39.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| FlaskEchoIP-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 66.5 kB
Release files / flaskechoip-2.0.0.tar.gz
| Download URL | flaskechoip-2.0.0.tar.gz |
|---|---|
| Size | 39.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
659a0abbcb904e8fafd891dfc7df9e6565361463b2d5860d25f5ea98b7a66d9b
|
|
BLAKE2b-256 checksum How to use checksums |
858c1bed096234026a3462771d8847f126073688f075446f084d90ebc82cb202
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.7
|
Release files / FlaskEchoIP-2.0.0-py3-none-any.whl
| Download URL | FlaskEchoIP-2.0.0-py3-none-any.whl |
|---|---|
| Size | 27.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e6b1b4d88c589049d24770d2896df22e2a19e371068d09202d6a0915a6b8a48
|
|
BLAKE2b-256 checksum How to use checksums |
d9da7bb07191e8c4daa1b714e603d95c3ed7114e495100b3e41f1babcf1b8cc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.7
|