Caddyfile:
example.com {
respond "{remote_host}"
}
[0] https://caddyserver.com/docs/caddyfile/directives/respond[1] https://caddyserver.com/docs/caddyfile/concepts#placeholders
I work in IT (was a sysadmin for years, still administer my own servers) and I hated the configuration of the web servers (first Apache, then nginx) - mostly because I was too lazy to read the docs from beginning to end.
This changed with caddy. It is simple, fast, reliable, HTTPS first with LE. Great.
def lambda_handler(event, context):
return {
'statusCode': '200',
'headers': None,
'body': event.get('requestContext', {}).get('identity', {}).get('sourceIp', 'unknown')
}
I do this, though my lambda is a bit more complex in practice, since I have some triggers that say "if this thing reports a new IP, do something".Of course, AWS provides this basic service as checkip.amazonaws.com
Between that and Mosh, I barely even notice when I change networks.
listen whatismyip
bind :::80 # listen on ipv4/ipv6
bind :::443 ssl crt /etc/haproxy/ssl/fullchain.pem
mode http
http-request return status 200 content-type "text/plain" lf-string "%[src]" if { path /ip }
http-request return status 200 content-type "application/json" lf-string "{\"ip\":\"%[src]\"}" if { path /json_ip }
http-request denyThat said, do you know of any software library that exposes the Geoip database (or at least Geoip Lite which you one easily obtain for free) in a nice API? Like how a lot of programming languages have tzinfo/tzdata libraries for querying the Tz database.
So it has ruined my second favorite wordpress security plugin - and MaxMind not really usable like it once was (?)
https://dev.maxmind.com/geoip/geoip2/geolite2/
In practice it's good enough for many purposes. It's actually the version of the database that ifconfig.co uses.
For the benefit of anyone interested: for a "self-hosted" solution, you can do this entirely within Nginx. Here's an example config: