Hacker News new | past | comments | ask | show | jobs | submit login

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.




If 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';
        }


Is 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.


You can use SSI, and echo the remote IP: https://httpd.apache.org/docs/2.4/howto/ssi.html

``` <!--#echo var="REMOTE_ADDR" --> ```


Doing this for HN asks you to login as an administrator.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: