Get remoteAddress from service request object

Enonic version: 6.6
OS: OSx El Capitan

Hey guys, I need to know who requested my service, in order to put a whitelist (I only want this service to be accessible from within my server, not from outside), and from the documentation (http://xp.readthedocs.io/en/stable/developer/ssjs/http-request.html) there was supposed to be a remoteAddress field on the request object. However, there’s nothing in it. Any idea why?

The service is accessible via get.

Thanks!

Yes, there should be a remoteAddress String property with the IP address.

function handleGet(req) {
    log.info(req.remoteAddress);

Is it neither present when you connect directly from localhost?

Check if some other front-end server or proxy is setting the HTTP header X-Forwarded-For, that would override the original remoteAddress.