location /ip {
    default_type text/plain;
    return 200 $remote_addr;
}

location /json_ip {
    default_type application/json;
    return 200 "{\"ip\":\"$remote_addr\"}";
}