How to get the original client IP inside the docker container to put into the database as a log, while I’m still trying with a simple code. I’m using nodejs express with module type configuration style.
this is my code:
import express from 'express'
import http from 'http'
const app = express()
app.set('port', '0.0.0.0' || '1234')
app.get('/', (req, res) => {
const ipadd = req.socket.remoteAddress
res.send({ status: true, message: `IP: ${ipadd}` })
return
})
http.createServer(app).listen('1234', '0.0.0.0', () => {
console.log(`Server running at http://0.0.0.0:1234/`)
})
i’ve try to run with command bellow
docker run -d --restart unless-stopped --name read-ip-container --publish 1234:1234 read-ip:latest
NOT WORKING TO GET CLIENT IPdocker run --rm -it --net=host read-ip index.js -lkv 0.0.0.0 1234
NOT WORKING TO GET CLIENT IP
please help me solve this problem without request headers like x-forwarded-for