-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Creating custom cowboy_protocol to deal with proxy protocol #708
Comments
i needed this for stud a while back so i implemented in my fork. I implemented both proxy v1 and v2 (binary) btw I haven't merged with upstream changes in a while (If needed I can quickly do it). |
parse_request is exported specifically so you can do that. |
@essen parse_request expects state record which is private for cowboy_protocol.erl. |
Of course it's private. But it doesn't stop you from passing the required tuple directly or copying init in your code. |
I'll use one of the proposed approaches, thank you. @essen feel free to close the issue. |
Closing then, thanks! |
Hi Khia, Essen, |
You have to create your own protocol that parses the beginning and then calls cowboy_protocol:parse_request. |
Got it, thanks. |
For what it's worth, Heroku has a Ranch transport we use in production with cowboy for proxy protocol support: https://github.com/heroku/ranch_proxy_protocol |
Excellent, thanks Fred. |
@ahmadster @ferd |
yes. |
We use cowboy in combination with sockjs library on aws. We need to find out a client's IP address. However ELB cannot provide it in websocket case. Unless we use proxy protocol. Basically what that protocol does is adding single line before the request. We don't want to reimplement the equivalent of cowboy_protocol.erl. We want to extract first line store it in middleware env for example (ideally we want to put it in http header but this is hard to achieve at this stage of request parsing). We want to pass the rest of the request back to existent cowboy_protocol.erl. Since init of cowboy_protocol calls ranch:accept_ack(Ref) we cannot do Transport:recv from our protocol wrapper module. Since init of cowboy_protocol is blocking and wait_request is private we cannot pass the reminder of a request to cowboy_protocol.
What would be the best way to achieve the goal of supporting proxy protocol?
The text was updated successfully, but these errors were encountered: