by zie · 3y ago · 0 comments
nginx config example:
location /ip {
add_header Content-Type "application/json";
return 200 '{"host":"$server_name","ip":"$remote_addr","port":"$remote_port","server_ip":"$server_addr","server_port":"$server_port
"}\n';
}Which will return something like this in JSON format:
{"host":"www.example.org","ip":"199.200.200.14","port":"7990","server_ip":"199.200.100.229","server_port":"443"}
This is all done 100% within NGINX, and I include a lot of stuff you probably don't want or care about. Other web servers probably have similar capabilities. example.com {
handle /ip {
header Content-Type application/json
respond `{"host":"{host}","ip":"{remote_host}","port":"{remote_port}"}`
}
}
Though the usefulness of the host (client specified it), remote port (it's random), and server ip/port (it's static and not useful for the client) are questionable.I learned this from: https://news.ycombinator.com/item?id=36383258
https://developers.cloudflare.com/fundamentals/get-started/r...
sni=plaintext
There was a great trial CF ran for a long period with a previous version of encrypted SNI (now ECH). One could get encrypted SNI with any site using CF via modified OpenSSL. But they stopped this experiment. Meanwhile ECH was still not ready.If anyone is getting something other than "sni=plaintext" for a CF domain besides crypto.cloudflare.com, then please let us know how.
With that in mind + the general advancing of hw since then, it wouldn't be too suprising if nginx could handle that load easily. It'd just get more difficult if you wanted to put anything else (ie. metrics) on that endpoint since afaict nginx doesn't have anything to monitor those things if you don't have the Enterprise version of their tools.
In any case you might be misreading the setup for the parent here - the recommendation is just that if you're doing this in the context of a webapp, that this sort of behavior is trivially easy to bounce back in JSON using nginx.
If your use case calls for 400k/reqs a second on what your IP is and you haven't yet figured out how to build out your infrastructure(or pay someone to do it for you), you have bigger problems than figuring our what your public IP is.
.. Ain't 65536 a capital B.
Edit: @toast0: valid point, thanks for the correction.
Chances are you'll never run into that limit for this service, because even if there's a ton of users behind the same IP due to NAT, they don't need to hold long sessions, and you can disable http keep-alive and close connections right away. Chances are you'll have some ip diversity in 400k requests/second though.
https://whatismyip.akamai.com/advanced?debug
https://ipv4.whatismyip.akamai.com
DNS-based
drill whoami.akamai.net
The second one might be useful to verify one is not using local, ISP-provided DNS, or to see whether a DoH provider effectively geolocates its users, e.g., Cloudflare.Send a request to stackexchange.com or any of its subdomains without a user-agent header.
dig ip @dns.toys +shortCNAME for whatismyip.akamai.com is a1524.g.akamai.net
Probably no certitifcate that lists whatismyip.akamai.com
With the parent comment example, all you need is nginx, available as a package on all distros, and a single static config file. With an auto-updating package manager and a service manager, one never needs to write anything else apart from that static config file.
Or did you mean something else with "actually maintainable"?
So that's not a problem. Besides the majority of nginx setups don't rely on too fancy things; most of the stuff that gets changed in updates that affect config files are the fancier nginx modules.