Fix x-forwarded-for resolution in http logging

This commit is contained in:
calzoneman 2014-08-20 10:56:36 -05:00
parent daec397015
commit edac89b204

View file

@ -14,6 +14,9 @@ var cookieParser = require("cookie-parser");
var static = require("serve-static");
var morgan = require("morgan");
const LOG_FORMAT = ':real-address - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"'
morgan.token("real-address", ipForRequest);
/**
* Extracts an IP address from a request. Uses X-Forwarded-For if the IP is localhost
*/
@ -203,7 +206,7 @@ module.exports = {
init: function (app) {
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(morgan("combined", {
app.use(morgan(LOG_FORMAT, {
stream: require("fs").createWriteStream(path.join(__dirname, "..", "..",
"http.log"), {
flags: "a",