Issue
i have a nodejs/express application and am logging with morgan:
var morgan = require ("morgan");
var app = express();
app.use(morgan(':date[iso] :remote-addr :method :url :status :res[content-length] - :response-time ms'));
but in my logfiles (redirected from 'npm start') i find lines like this:
2014-12-21T10:02:59.365Z 127.0.0.1 GET / 304 - - 2.389 ms
showing 127.0.0.1 as remote address for all requests. i do use angular's $routeProvider after the index.html is loaded but even the / request returns 127.0.0.1.
app.get('/partials/:name', routes.partials);
app.get('*', function (req, res) {
res.setHeader('Content-type', 'text/html');
res.charset = 'UTF-8';
res.sendFile(__dirname + '/pub/index.html');
});
am i missing something? shouldn't the actual requester be logged here?
Solution
Is your server behind a proxy?
Try:
app.enable("trust proxy");
(Insert line before using morgan middleware)
Answered By - pasimako
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.