Builds for
1 pipeline
failed
in
0 seconds
리버스프록시 뒤에 있어도 제 ip를 사용하도록 수정
Showing
3 changed files
with
3 additions
and
2 deletions
... | @@ -21,6 +21,7 @@ const hbs = exphbs.create({ | ... | @@ -21,6 +21,7 @@ const hbs = exphbs.create({ |
21 | app.engine('handlebars', hbs.engine); | 21 | app.engine('handlebars', hbs.engine); |
22 | app.set('view engine', 'handlebars'); | 22 | app.set('view engine', 'handlebars'); |
23 | app.set('views', path.join(__dirname, 'views')); | 23 | app.set('views', path.join(__dirname, 'views')); |
24 | +app.set('trust proxy', true); | ||
24 | 25 | ||
25 | fs.readdirSync(path.resolve(__dirname, 'routes')).forEach((name) => { | 26 | fs.readdirSync(path.resolve(__dirname, 'routes')).forEach((name) => { |
26 | require(path.resolve(__dirname, 'routes', name)); | 27 | require(path.resolve(__dirname, 'routes', name)); | ... | ... |
... | @@ -24,6 +24,6 @@ app.post('/board/:bid', async(req, res) => { | ... | @@ -24,6 +24,6 @@ app.post('/board/:bid', async(req, res) => { |
24 | res.status(404).send('그런 판은 우리에게 있을 수 없어.'); | 24 | res.status(404).send('그런 판은 우리에게 있을 수 없어.'); |
25 | } | 25 | } |
26 | let thread = await db.get('thread').insert({board: board._id, title: req.body.title, content: req.body.content, lastUpdated: Date.now(), count: 1}); | 26 | let thread = await db.get('thread').insert({board: board._id, title: req.body.title, content: req.body.content, lastUpdated: Date.now(), count: 1}); |
27 | - await db.get('thread').update(thread._id, {$set: {writer: hash(thread._id, req.ip)}}); | 27 | + await db.get('thread').update(thread._id, {$set: {writer: hash(thread._id, req.get('x-real-ip') || req.ip)}}); |
28 | res.redirect('/thread/' + thread._id); | 28 | res.redirect('/thread/' + thread._id); |
29 | }); | 29 | }); | ... | ... |
... | @@ -22,7 +22,7 @@ module.exports = { | ... | @@ -22,7 +22,7 @@ module.exports = { |
22 | }); | 22 | }); |
23 | socket.on('write', async(content) => { | 23 | socket.on('write', async(content) => { |
24 | console.log(`write ${content}`); | 24 | console.log(`write ${content}`); |
25 | - let subthread = await db.get('subthread').insert({parent: thread._id, writer: hash(thread._id, socket.handshake.address), content, no: ++thread.count}); | 25 | + let subthread = await db.get('subthread').insert({parent: thread._id, writer: hash(thread._id, socket.handshake.headers['x-real-ip'] || socket.handshake.address), content, no: ++thread.count}); |
26 | db.get('thread').update(thread._id, {$set: {count: thread.count, lastUpdated: Date.now()}}); | 26 | db.get('thread').update(thread._id, {$set: {count: thread.count, lastUpdated: Date.now()}}); |
27 | io.to(`thread-${thread._id}`).emit('thread', subthread); | 27 | io.to(`thread-${thread._id}`).emit('thread', subthread); |
28 | console.log(`broadcast thread-${thread._id}`); | 28 | console.log(`broadcast thread-${thread._id}`); | ... | ... |
-
Please register or login to post a comment