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

You can implement this yourself in nginx like this:

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

and you will get back a little JSON with everything you want.



Doesn't seem to work right...

    {"ip": "127.0.0.1", ...}
But seriously, of course you can but 99% of people would rather just use a simple site rather than hosting their own server.


Because you were doing it from localhost, the connection came from localhost. It has to be exposed out on the internet for it to return an internet IP :)

Anyways, I agree for 1 off things, whatever, use icanhazip or whatever you want, it doesn't matter if you make 1 request a day or 1 request a month... But if you are doing anything in code that uses it, you should just host it yourself and be a good net citizen.




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

Search: