Skip to content
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

Access to the websocket request object #323

Closed
abachman opened this issue Sep 9, 2019 · 0 comments
Closed

Access to the websocket request object #323

abachman opened this issue Sep 9, 2019 · 0 comments

Comments

@abachman
Copy link
Contributor

abachman commented Sep 9, 2019

There have been a few issues requesting help with getting the remote IP address of the connected client, but they all assume aedes is not behind a reverse proxy. Specifically, the conn.socket._socket.remoteAddress value on websocket connections for aedes instances behind a reverse proxy always returns the address of the proxy, not the X-Forwarded-For header the proxy adds to all requests.

We're using proxywrap to handle raw TCP requests in proxy-protocol format, but Aedes drops the HTTP request object for websocket requests, so we're not able to access headers and get the X-Forwarded-For value.

I submitted pull request #322 to add the original HTTP request to the Aedes Client object.

No tests, but there's almost no new functionality 🤷‍♂.

The resulting code looks something like this:

const broker = new Aedes(opts);
broker.on('client', (client) => {
  if (client.req) {
    console.log(client.req.headers['x-forwarded-for'])
  }
})

Is there a better way to get this functionality without changing aedes?

related to #222

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

No branches or pull requests

2 participants