Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
9,334 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# socks-nginx-module | ||
nginx HTTP to SOCKS5 proxy module | ||
|
||
Sample usage: | ||
|
||
``` | ||
location / { | ||
socks_set_header Host $http_host; | ||
socks_set_header Proxy-Connection ''; | ||
socks_pass_header Server; | ||
socks_redirect off; | ||
socks_http_version 1.1; | ||
socks_tunnel_header X-Connect; | ||
socks_buffers 16 16k; | ||
socks_buffer_size 32k; | ||
socks_cache_use_stale error timeout invalid_header updating | ||
http_500 http_502 http_503 http_504; | ||
socks_pass socks5://127.0.0.1:1080; | ||
} | ||
``` | ||
|
||
##socks_tunnel_header | ||
|
||
As nginx HTTP parser doesn't support HTTP CONNECT method, a special header can be set to indicate tunnel connection. | ||
|
||
This directive can be exploited with the following HAProxy configuration: | ||
|
||
``` | ||
frontend local | ||
bind *:8080 | ||
mode http | ||
http-request set-method GET if METH_CONNECT | ||
http-request set-uri https://%[req.hdr(Host)]/ if METH_CONNECT | ||
http-request add-header X-Connect true if METH_CONNECT | ||
default_backend nginx | ||
backend nginx | ||
mode http | ||
server proxy 127.0.0.1:8080 maxconn 100000 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ngx_addon_name=ngx_http_socks_module | ||
|
||
HTTP_MODULES="$HTTP_MODULES ngx_http_socks_module" | ||
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_socks_module.c $ngx_addon_dir/src/ngx_http_socks_upstream.c" | ||
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ngx_http_socks_module.h" | ||
|
||
have=NGX_HTTP_SOCKS_MODULE . auto/have |
Oops, something went wrong.