New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve a connection's remote IP address under IISNode #94

Open
agad opened this Issue Dec 7, 2011 · 19 comments

Comments

Projects
None yet
10 participants
@agad

agad commented Dec 7, 2011

I can not seem to retrieve the remote IPAddress of a request using node under IISNode. If I try req.connection.remoteAddress I get undefined. Same script run without IIS provides the remote address without a problem.

@tjanczuk

This comment has been minimized.

Show comment
Hide comment
@tjanczuk

tjanczuk Dec 7, 2011

Owner

The reason for this behavior is that iisnode acts as a reverse proxy between the client and the node process. The req.connection represents the connection between iisnode and node.exe, not between the client's machine and iisnode. Furthermore, the connection between iisnode and node.exe is based on named pipes not TCP, and as such does not expose many of the concepts specific to TCP like the IP address.

It would be possible to propagate selected properties describing the client connection using X-* headers of the HTTP request message. Would such mechanism satisfy your requirement?

Owner

tjanczuk commented Dec 7, 2011

The reason for this behavior is that iisnode acts as a reverse proxy between the client and the node process. The req.connection represents the connection between iisnode and node.exe, not between the client's machine and iisnode. Furthermore, the connection between iisnode and node.exe is based on named pipes not TCP, and as such does not expose many of the concepts specific to TCP like the IP address.

It would be possible to propagate selected properties describing the client connection using X-* headers of the HTTP request message. Would such mechanism satisfy your requirement?

@agad

This comment has been minimized.

Show comment
Hide comment
@agad

agad Dec 7, 2011

Aha, that makes complete sense now. Yes, I believe that a set of X-Headers would be helpful and could follow the standard type of X-headers from proxies such as X-Forwarded-For to cover the IP address info as well as X-Forwarded-Host to cover the original host the client requested.

agad commented Dec 7, 2011

Aha, that makes complete sense now. Yes, I believe that a set of X-Headers would be helpful and could follow the standard type of X-headers from proxies such as X-Forwarded-For to cover the IP address info as well as X-Forwarded-Host to cover the original host the client requested.

@tjanczuk

This comment has been minimized.

Show comment
Hide comment
@tjanczuk

tjanczuk Jan 10, 2012

Owner

The fix for this issue is to add support for X-Forwarded-For request header to iisnode (http://en.wikipedia.org/wiki/X-Forwarded-For).

A new configuration property iisnode@enableXFF controls whether iisnode adds or augments the X-Forwarded-For request header. By default the value is false. If set to true, iisnode will either append the IP address and port number of the next hop client to an X-Forwarded-For request header already existing on the HTTP request, or create a new X-Forwarded-For header in its absence. Both IPv4 and IPv6 addresses are supported. Each address will specify a port number as well.

This is how to enable X-Forwarded-For support through web.config:

<configuration>
  <system.webServer>

    <!-- ... -->

    <iisnode enableXFF="true" />

  </system.webServer>
</configuration>

This is an example of the X-Forwarded-For HTTP request header iisnode will add to the request:

X-Forwarded-For: 127.0.0.1:28736

This is the code node.js application can use to read the value of the header:

var http = require('http');

http.createServer(function (req, res) {
    var xff = req.headers['x-forwarded-for'];
    // ...
}).listen(process.env.PORT); 
Owner

tjanczuk commented Jan 10, 2012

The fix for this issue is to add support for X-Forwarded-For request header to iisnode (http://en.wikipedia.org/wiki/X-Forwarded-For).

A new configuration property iisnode@enableXFF controls whether iisnode adds or augments the X-Forwarded-For request header. By default the value is false. If set to true, iisnode will either append the IP address and port number of the next hop client to an X-Forwarded-For request header already existing on the HTTP request, or create a new X-Forwarded-For header in its absence. Both IPv4 and IPv6 addresses are supported. Each address will specify a port number as well.

This is how to enable X-Forwarded-For support through web.config:

<configuration>
  <system.webServer>

    <!-- ... -->

    <iisnode enableXFF="true" />

  </system.webServer>
</configuration>

This is an example of the X-Forwarded-For HTTP request header iisnode will add to the request:

X-Forwarded-For: 127.0.0.1:28736

This is the code node.js application can use to read the value of the header:

var http = require('http');

http.createServer(function (req, res) {
    var xff = req.headers['x-forwarded-for'];
    // ...
}).listen(process.env.PORT); 
@l5oo00

This comment has been minimized.

Show comment
Hide comment
@l5oo00

l5oo00 Mar 12, 2012

Thank you.

l5oo00 commented Mar 12, 2012

Thank you.

@williamkapke

This comment has been minimized.

Show comment
Hide comment
@williamkapke

williamkapke Aug 11, 2012

Can you put the port under X-Forwarded-Port to be inline with other implementations?

Adding it to the Ip requires code forks for IISNode.

williamkapke commented Aug 11, 2012

Can you put the port under X-Forwarded-Port to be inline with other implementations?

Adding it to the Ip requires code forks for IISNode.

@tjanczuk tjanczuk reopened this Aug 11, 2012

@tjanczuk

This comment has been minimized.

Show comment
Hide comment
@tjanczuk

tjanczuk Aug 11, 2012

Owner

I will look into this, reopening.

Owner

tjanczuk commented Aug 11, 2012

I will look into this, reopening.

@crazycactuz

This comment has been minimized.

Show comment
Hide comment
@crazycactuz

crazycactuz Aug 24, 2013

Does this work in azure websites? I read somewhere that azure websites implement some kind of subset of iisnode. I have created a iisnode.yml file with enableXFF: true as only content, restarted the site like 5 time and still it wont show me the IPs..

crazycactuz commented Aug 24, 2013

Does this work in azure websites? I read somewhere that azure websites implement some kind of subset of iisnode. I have created a iisnode.yml file with enableXFF: true as only content, restarted the site like 5 time and still it wont show me the IPs..

@crazycactuz

This comment has been minimized.

Show comment
Hide comment
@crazycactuz

crazycactuz Aug 24, 2013

the site is git deployed from OS X if that matters

crazycactuz commented Aug 24, 2013

the site is git deployed from OS X if that matters

@crazycactuz

This comment has been minimized.

Show comment
Hide comment
@crazycactuz

crazycactuz Aug 24, 2013

My problem was that i used "X-Forwarded-For", not "x-forwarded-for".. works now ;P

crazycactuz commented Aug 24, 2013

My problem was that i used "X-Forwarded-For", not "x-forwarded-for".. works now ;P

@jigneshnavsoft

This comment has been minimized.

Show comment
Hide comment
@jigneshnavsoft

jigneshnavsoft Jan 24, 2014

while i am executing req.connection.socket.remoteAddress

i am getting error below ..

TypeError: Cannot read property 'remoteAddress' of undefined
at module.exports.home (/var/www/html/tablemaster/api/controllers/IndexController.js:36:31)
at wrapperFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:198:5)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at module.exports (/var/www/html/tablemaster/api/policies/flash.js:10:5)
at wrapperFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:198:5)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at /var/www/html/tablemaster/node_modules/sails/lib/hooks/i18n/index.js:27:13
at Object.i18nInit as init
at routes.before./* (/var/www/html/tablemaster/node_modules/sails/lib/hooks/i18n/index.js:25:16)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at routes.before./* (/var/www/html/tablemaster/node_modules/sails/lib/hooks/csrf/index.js:35:6)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at _addResViewMethod (/var/www/html/tablemaster/node_modules/sails/lib/hooks/views/index.js:337:3)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at addSugarMethods (/var/www/html/tablemaster/node_modules/sails/lib/hooks/request/index.js:68:6)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at /var/www/html/tablemaster/node_modules/sails/node_modules/connect-flash/lib/flash.js:21:5
at supportFlashMsgs (/var/www/html/tablemaster/node_modules/sails/lib/hooks/request/index.js:45:32)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:173:5)
at Object.router (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:33:10)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.handle (/var/www/html/tablemaster/node_modules/sails/lib/express/index.js:168:4)
at Context.next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Context.actions.pass (/var/www/html/tablemaster/node_modules/passport/lib/passport/context/http/actions.js:77:8)
at SessionStrategy.authenticate (/var/www/html/tablemaster/node_modules/passport/lib/passport/strategies/session.js:67:10)
at attempt (/var/www/html/tablemaster/node_modules/passport/lib/passport/middleware/authenticate.js:243:16)
at Passport.authenticate (/var/www/html/tablemaster/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Passport.initialize (/var/www/html/tablemaster/node_modules/passport/lib/passport/middleware/initialize.js:70:5)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.methodOverride as handle
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at /var/www/html/tablemaster/node_modules/sails/lib/express/bodyParserRetry.js:46:4
at multipart (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/multipart.js:85:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9
at urlencoded (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:49:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:55:7
at json (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/json.js:43:37)
at bodyParser (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:53:5)
at Object.retryBodyParser as handle
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:192:9)
at multipart (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/multipart.js:85:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9
at urlencoded (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:49:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:55:7
at json (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/json.js:43:37)
at bodyParser (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:53:5)
at Object.handle (/var/www/html/tablemaster/node_modules/sails/lib/express/index.js:118:12)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session.js:312:9)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session.js:329:9
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session/memory.js:55:7
at process._tickDomainCallback (node.js:459:13)

jigneshnavsoft commented Jan 24, 2014

while i am executing req.connection.socket.remoteAddress

i am getting error below ..

TypeError: Cannot read property 'remoteAddress' of undefined
at module.exports.home (/var/www/html/tablemaster/api/controllers/IndexController.js:36:31)
at wrapperFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:198:5)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at module.exports (/var/www/html/tablemaster/api/policies/flash.js:10:5)
at wrapperFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:198:5)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at /var/www/html/tablemaster/node_modules/sails/lib/hooks/i18n/index.js:27:13
at Object.i18nInit as init
at routes.before./* (/var/www/html/tablemaster/node_modules/sails/lib/hooks/i18n/index.js:25:16)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at routes.before./* (/var/www/html/tablemaster/node_modules/sails/lib/hooks/csrf/index.js:35:6)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at _addResViewMethod (/var/www/html/tablemaster/node_modules/sails/lib/hooks/views/index.js:337:3)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at addSugarMethods (/var/www/html/tablemaster/node_modules/sails/lib/hooks/request/index.js:68:6)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js💯7)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at /var/www/html/tablemaster/node_modules/sails/node_modules/connect-flash/lib/flash.js:21:5
at supportFlashMsgs (/var/www/html/tablemaster/node_modules/sails/lib/hooks/request/index.js:45:32)
at _bind.enhancedFn (/var/www/html/tablemaster/node_modules/sails/lib/router/bind.js:375:4)
at callbacks (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:173:5)
at Object.router (/var/www/html/tablemaster/node_modules/sails/node_modules/express/lib/router/index.js:33:10)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.handle (/var/www/html/tablemaster/node_modules/sails/lib/express/index.js:168:4)
at Context.next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Context.actions.pass (/var/www/html/tablemaster/node_modules/passport/lib/passport/context/http/actions.js:77:8)
at SessionStrategy.authenticate (/var/www/html/tablemaster/node_modules/passport/lib/passport/strategies/session.js:67:10)
at attempt (/var/www/html/tablemaster/node_modules/passport/lib/passport/middleware/authenticate.js:243:16)
at Passport.authenticate (/var/www/html/tablemaster/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Passport.initialize (/var/www/html/tablemaster/node_modules/passport/lib/passport/middleware/initialize.js:70:5)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.methodOverride as handle
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at /var/www/html/tablemaster/node_modules/sails/lib/express/bodyParserRetry.js:46:4
at multipart (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/multipart.js:85:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9
at urlencoded (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:49:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:55:7
at json (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/json.js:43:37)
at bodyParser (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:53:5)
at Object.retryBodyParser as handle
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:192:9)
at multipart (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/multipart.js:85:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9
at urlencoded (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:49:37)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:55:7
at json (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/json.js:43:37)
at bodyParser (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:53:5)
at Object.handle (/var/www/html/tablemaster/node_modules/sails/lib/express/index.js:118:12)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at next (/var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session.js:312:9)
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session.js:329:9
at /var/www/html/tablemaster/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session/memory.js:55:7
at process._tickDomainCallback (node.js:459:13)

@rramachand21

This comment has been minimized.

Show comment
Hide comment
@rramachand21

rramachand21 Jan 24, 2014

Collaborator

use "x-forwarded-for" as mentioned above.

Collaborator

rramachand21 commented Jan 24, 2014

use "x-forwarded-for" as mentioned above.

@jigneshnavsoft

This comment has been minimized.

Show comment
Hide comment
@jigneshnavsoft

jigneshnavsoft Jan 24, 2014

i want remote ip address like 220.226.23.254 but when i am executing x-forwarded-for i am getting local ip..
i dont want local ip

jigneshnavsoft commented Jan 24, 2014

i want remote ip address like 220.226.23.254 but when i am executing x-forwarded-for i am getting local ip..
i dont want local ip

@tjanczuk

This comment has been minimized.

Show comment
Hide comment
@tjanczuk

tjanczuk Jan 24, 2014

Owner

@jigneshnavsoft are you running on Windows using iisnode? The stack trace has file paths suggesting a non-Windows environment.

Owner

tjanczuk commented Jan 24, 2014

@jigneshnavsoft are you running on Windows using iisnode? The stack trace has file paths suggesting a non-Windows environment.

@jigneshnavsoft

This comment has been minimized.

Show comment
Hide comment
@jigneshnavsoft

jigneshnavsoft Jan 24, 2014

i am using centos...

On Fri, Jan 24, 2014 at 11:07 PM, Tomasz Janczuk
notifications@github.comwrote:

@jigneshnavsoft https://github.com/jigneshnavsoft are you running on
Windows using iisnode? The stack trace has file paths suggesting a
non-Windows environment.


Reply to this email directly or view it on GitHubhttps://github.com//issues/94#issuecomment-33243840
.

jigneshnavsoft commented Jan 24, 2014

i am using centos...

On Fri, Jan 24, 2014 at 11:07 PM, Tomasz Janczuk
notifications@github.comwrote:

@jigneshnavsoft https://github.com/jigneshnavsoft are you running on
Windows using iisnode? The stack trace has file paths suggesting a
non-Windows environment.


Reply to this email directly or view it on GitHubhttps://github.com//issues/94#issuecomment-33243840
.

@rramachand21

This comment has been minimized.

Show comment
Hide comment
@rramachand21

rramachand21 Jan 24, 2014

Collaborator

if you are directly running node.exe without iisnode (which you must be because you are on Linux/unix env) -- req.connection.socket.remoteAddress only works for HTTPS.
try req.connection.remoteAddress OR req.socket.remoteAddress for HTTP connections.

Collaborator

rramachand21 commented Jan 24, 2014

if you are directly running node.exe without iisnode (which you must be because you are on Linux/unix env) -- req.connection.socket.remoteAddress only works for HTTPS.
try req.connection.remoteAddress OR req.socket.remoteAddress for HTTP connections.

@jigneshnavsoft

This comment has been minimized.

Show comment
Hide comment
@jigneshnavsoft

jigneshnavsoft Jan 24, 2014

i try also that ..
is there any special library needed for that ???

On Fri, Jan 24, 2014 at 11:18 PM, Ranjith Ramachandra <
notifications@github.com> wrote:

if you are directly running node.exe without iisnode (which you must be
because you are on Linux/unix env) -- req.connection.socket.remoteAddress
only works for HTTPS.
try req.connection.remoteAddress OR req.socket.remoteAddress for HTTP
connections.


Reply to this email directly or view it on GitHubhttps://github.com//issues/94#issuecomment-33244737
.

jigneshnavsoft commented Jan 24, 2014

i try also that ..
is there any special library needed for that ???

On Fri, Jan 24, 2014 at 11:18 PM, Ranjith Ramachandra <
notifications@github.com> wrote:

if you are directly running node.exe without iisnode (which you must be
because you are on Linux/unix env) -- req.connection.socket.remoteAddress
only works for HTTPS.
try req.connection.remoteAddress OR req.socket.remoteAddress for HTTP
connections.


Reply to this email directly or view it on GitHubhttps://github.com//issues/94#issuecomment-33244737
.

gravling added a commit to gravling/node-github-hook that referenced this issue Oct 28, 2015

Fixed so that node-github-hook runs under iisnode
Broke since iisnode is not able to resolve remoteAddress. See tjanczuk/iisnode#94 for more information
@Priyankaagrawal

This comment has been minimized.

Show comment
Hide comment
@Priyankaagrawal

Priyankaagrawal Dec 23, 2016

I have try this in web.config


<system.webServer>

<!-- ... -->

<iisnode enableXFF="true" />

</system.webServer>

In node.js, I m trying get the ip using below code

var xff = req.headers['x-forwarded-for'];

xff is showing "undefined". I m using IIS version is 8.5 on windows 2012 r2

Priyankaagrawal commented Dec 23, 2016

I have try this in web.config


<system.webServer>

<!-- ... -->

<iisnode enableXFF="true" />

</system.webServer>

In node.js, I m trying get the ip using below code

var xff = req.headers['x-forwarded-for'];

xff is showing "undefined". I m using IIS version is 8.5 on windows 2012 r2

@mattgaspar

This comment has been minimized.

Show comment
Hide comment
@mattgaspar

mattgaspar Apr 7, 2018

I vote for having enableXFF true as the default!! Any reason it isn't?

mattgaspar commented Apr 7, 2018

I vote for having enableXFF true as the default!! Any reason it isn't?

@ibrahimozgon

This comment has been minimized.

Show comment
Hide comment
@ibrahimozgon

ibrahimozgon Apr 13, 2018

enableXFF worked. Thanks

ibrahimozgon commented Apr 13, 2018

enableXFF worked. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment