3 ms·
If you want, you can set up a similar service yourself by adding the following lines to an NGINX config: location = /ip { default_type text/pla
by Seirdy 5y ago
If you want, you can set up a similar service yourself by adding the following lines to an NGINX config:
location = /ip {
default_type text/plain;
return 200 '$remote_addr';
}
Requesting "yoursite.tld/ip" will then return your IP address. I set up something like this on all my servers and recommend that others do the same. It's easy to do the same for Apache and Caddy configs. That should help spread the load.
I'm curious as to what other overused utilities can be trivially done with pure server configs.
- jacobmischka 5y agoIs it easy to do the same for Apache? The best solution I found was some hacky way with an ErrorDocument directive which seems pretty gross.
- Ayesh 5y agoYou can use SSI, and echo the remote IP: https://httpd.apache.org/docs/2.4/howto/ssi.html https://httpd.apache.org/docs/2.4/howto/ssi.html ``` <!--#echo var="REMOTE_ADDR" --> ```
- lsiebert 5y agoDoing this for HN asks you to login as an administrator.
- zie 5y agoIf you want JSON instead: 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'; }