Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
herokuPublic archive

About

PROXY protocol support for ranch

Resources

Stars

48 stars

Watchers

100 watching

Forks

Latest commit

 

History

129 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ranch Proxy Protocol Socket

This module wraps the ranch_tcp module to parse the proxy protocol (version 1) before handing the socket on to the ranch handler.

It has the same API as the ranch_tcp module but with two new functions; connect/4 and proxyname/1.

The transport is called ranch_proxy.

connect/4

connect/4 allows you to connect with to a remote host, and sending the proxy protocol header automatically before going on to use the socket. It's similar to the regular ranch_tcp:connect/3 but accepts a third tuple containing proxy protocol information:

-type proxy_opts() :: [{inet_version, ipv4 | ipv6} |
                       {source_address, inet:ip_address() | inet:hostname()} |
                       {source_port, inet:port_number()} |
                       {dest_address, inet:ip_address() | inet:hostname()} |
                       {source_port, inet:port_number()}].
-spec connect(inet:ip_address() | inet:hostname(),
              inet:port_number(), any(), proxy_opts())
	-> {ok, #proxy_socket{}} | {error, atom()}.

proxyname/1

proxyname/1 gives you the proxy protocol information:

-type proxy_protocol_info() :: [{source_address, inet:ip_address()} |
                                {dest_address, inet:ip_address()} |
                                {source_port, inet:port_number()} |
                                {dest_port, inet:port_number()}].
-spec proxyname(proxy_socket()) ->
                       {ok, proxy_protocol_info()} | {error, atom()}.

Run the tests!

Sure why don't you

$ rebar3 ct

License

See the LICENSE file.

About

PROXY protocol support for ranch

Resources

Stars

48 stars

Watchers

100 watching

Forks

Releases

Packages

Used by

Contributors

Languages