mirror of https://github.com/calzoneman/sync.git
Fix x-forwarded-for resolution in http logging
This commit is contained in:
parent
daec397015
commit
edac89b204
|
@ -14,6 +14,9 @@ var cookieParser = require("cookie-parser");
|
||||||
var static = require("serve-static");
|
var static = require("serve-static");
|
||||||
var morgan = require("morgan");
|
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
|
* 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) {
|
init: function (app) {
|
||||||
app.use(bodyParser.urlencoded({ extended: false }));
|
app.use(bodyParser.urlencoded({ extended: false }));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.use(morgan("combined", {
|
app.use(morgan(LOG_FORMAT, {
|
||||||
stream: require("fs").createWriteStream(path.join(__dirname, "..", "..",
|
stream: require("fs").createWriteStream(path.join(__dirname, "..", "..",
|
||||||
"http.log"), {
|
"http.log"), {
|
||||||
flags: "a",
|
flags: "a",
|
||||||
|
|
Loading…
Reference in New Issue