-
Notifications
You must be signed in to change notification settings - Fork 16
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
Catching the PROXY protocol error #11
Comments
Hi @jamix2 , can you please provide a chunk of you source-code where you're implementing We are using it on our production servers without any problems until date, also on We also have a test unit covering the case you're providing. Which version of Hope i can help you, production errors are an headache... x) |
Thank you for a prompt reply @cusspvz! We are using version 0.3.8. Here is an ultra minimal application to reproduce the issue:
Run the application locally and then enter
As you can see, there is no mention of |
Strange... let me dig on it. |
Well, just fixed it on #12 with an option called I'm merging it now and bumping version so you could deploy it to your production servers. Thanks!! :) |
Thank you for addressing this. If I understand it correctly, That said, would it be possible to enable listening for the error event so we can see where the non-PROXY requests are coming from? That would leave processing of the protocol error to the client code, which would either terminate the app or log the error, hopefully along with the origin IP. After all, it's really weird to be getting those non-PROXY requests from behind ELB. |
Exactly, but for that you should keep
That never happened with us, since our production SG are configured to allow only connections from ELB. Maybe you should do the same. :)
You're welcome. We are open to issues since we can improve this module to avoid future problems on our app, thats why open-source rocks!! :) If you want to hear more about our modules, follow me or keep in touch with |
OK, so if we do keep
We do, too, as per Elastic Beanstalk's default configuration. That's what's strange about it.
Done! |
I was thinking about it for a while, could it be related somehow to instance monitoring service?
By listening for server.on( 'connection', function ( socket ) {
socket.on( 'error', function ( err ) {
// ...
});
}); If I was with your scenario in hands, i would prefer to ignore Notice that even if If you're interested on gathering errors from
Thanks! :) |
Yes, that's what I'm inclined to think as well. We'll poke around.
Ah, beautiful! We added the listener and it looks like we won't even need the In the error handler, though, the |
As the connection isn't initialized with PROXY Protocol header, it won't replace |
|
Could you please try the same with |
That has no effect unfortunately. |
You're using |
Here is the updated minimal code:
Upon launching the server and hitting it with a non-PROXY request on port 8080, the error handler outputs |
Don't know why, but inspite of closures are my last resource, they are an awesome resource! 💃 Hope this can help you to find the culprit: var http = require("http");
var proxywrap = require('findhit-proxywrap');
var proxied_http = proxywrap.proxy(http, {
strict: true,
overrideRemote: false
});
var http_server = proxied_http.createServer();
var port = 8080;
http_server.listen(port, function() {
console.log("server listening on port " + port);
});
http_server.on('connection', function (socket) {
var ip = socket._getpeername().address;
socket.on('error', function (err) {
console.log( 'error: blame ' + ip);
});
}); |
Of course! Store all the necessary socket info on the connection stage and reuse it in the error handler. Sometimes we have to be reminded of the basics :) Thank you for all your help, I think we are now well-equipped to find out what is causing the issue! |
You're welcome, glad to help! Cheers ;) |
Done! :) |
Thank you! |
Just a quick update - that indeed was #13. After we updated to 0.3.10, the odd PROXY protocol errors were gone for good. Thanks! |
I'm happy for that! You're welcome! :) |
We have a Node.js application behind ELB that uses proxywrap in strict mode. The application crashes intermittently with the following error:
We have a strong suspicion that this is caused by non-PROXY requests somehow hitting the server because we get the same error if we run proxywrap in strict mode locally and then hit it with a non-PROXY request.
Now, how can we catch that
error
event, apparently emitted by the socket object here, and prevent it from crashing the whole application?The text was updated successfully, but these errors were encountered: