WSGIEchoIP
$ curl -L ip.jb2170.com
12.34.56.78
A simple WSGI 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!
This is a useful 'just-werks' app, and demonstrates using WSGI without a framework such as Flask. The only thing to really be aware of in raw WSGI is that strings are bytes decoded as Latin-1, as per PEP-3333, when in reality there's a 99% chance the bytes should've been decoded as UTF-8. Therefore if one is concerned about Unicode headers etc the WSGI environment strings should be corrected with .encode("latin1").decode("utf8"). This is one of the many reasons to use a framework like Flask in a production app.
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/WSGIEchoIP, and source it $ pip install WSGIEchoIP 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
- FlaskEchoIP, a Flask version of this app that I also made, which is why this one is now archived
Metadata
Release files for WSGIEchoIP 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wsgiechoip-1.1.1.tar.gz | 40.2 kB | Without provenance | Details for wsgiechoip-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| WSGIEchoIP-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for WSGIEchoIP-1.1.1-py3-none-any.whl |
Total release size: 68.1 kB
Release files / wsgiechoip-1.1.1.tar.gz
| Download URL | wsgiechoip-1.1.1.tar.gz |
|---|---|
| Size | 40.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ac7d44ded524e0e4d2b088252a3b9aad0802e04b273e5b3b592c35faa86de6a
|
|
BLAKE2b-256 checksum How to use checksums |
cc770ac41bcb37ca3d04bb63978033e7a8f358ee163cecd00220bf4a4962628a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.7
|
Release files / WSGIEchoIP-1.1.1-py3-none-any.whl
| Download URL | WSGIEchoIP-1.1.1-py3-none-any.whl |
|---|---|
| Size | 27.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad5770eafcdf9513a37c1dd080fed01f3ce5596432bb6197fe6399f366b6a0e9
|
|
BLAKE2b-256 checksum How to use checksums |
182cc29e97a8fafbcf19374ff2d4ec7ac3419623ba6ff9cf78672b528a0f1cf3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.7
|
Security for WSGIEchoIP 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.