Skip to content

Commit 63021eb

Browse files
authored
Merge pull request chobits#29 from chobits/enable_rewrite_phase
Enable rewrite phase for CONNECT request
2 parents dca5b25 + 215545c commit 63021eb

File tree

4 files changed

+763
-11
lines changed

4 files changed

+763
-11
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Table of Contents
1616
* [proxy_connect_connect_timeout](#proxy_connect_connect_timeout)
1717
* [proxy_connect_read_timeout](#proxy_connect_read_timeout)
1818
* [proxy_connect_write_timeout](#proxy_connect_write_timeout)
19+
* [proxy_connect_address](#proxy_connect_address)
20+
* [proxy_connect_bind](#proxy_connect_bind)
1921
* [Variables](#variables)
2022
* [$connect_host](#connect_host)
2123
* [$connect_port](#connect_port)
@@ -107,7 +109,11 @@ $ ./configure --add-module=/path/to/ngx_http_proxy_connect_module
107109
$ make && make install
108110
```
109111

110-
Note that `proxy_connect.patch` includes logic in macro NGX_HTTP_RPOXY_CONNECT, and [config](https://github.com/chobits/ngx_http_proxy_connect_module/blob/master/config#L5) script will enable this macro automatically.
112+
Note that `proxy_connect.patch` includes logic in macro NGX_HTTP_RPOXY_CONNECT, and [config](https://github.com/chobits/ngx_http_proxy_connect_module/blob/master/config#L5) script will enable this macro automatically.
113+
114+
This module disables nginx REWRITE phase for CONNECT request by default, which means `if`, `set`, `rewrite_by_lua` and other rewrite directives cannot be used. To enable these, you should use `proxy_connect_rewrite.patch` instead of `proxy_connect.patch`. (`TODO`: merge two patches into one.)
115+
116+
111117

112118
Directive
113119
=========
@@ -174,6 +180,37 @@ Sets a timeout for transmitting a request to the proxied server.
174180
The timeout is set only between two successive write operations, not for the transmission of the whole request.
175181
If the proxied server does not receive anything within this time, the connection is closed.
176182

183+
proxy_connect_address
184+
---------------------
185+
186+
Syntax: **proxy_connect_address `address [transparent] | off`**
187+
Default: `none`
188+
Context: `server`
189+
190+
Specifiy an IP address of the proxied server. The address can contain variables.
191+
The special value off is equal to none, which uses the IP address resolved from host name of CONNECT request line.
192+
193+
NOTE: If using `set $<nginx variable>` and `proxy_connect_address $<nginx variable>` together, you should use `proxy_connect_rewrite.patch` instead, see [Install](#install) for more details.
194+
195+
proxy_connect_bind
196+
------------------
197+
198+
Syntax: **proxy_connect_bind `address | off`**
199+
Default: `none`
200+
Context: `server`
201+
202+
Makes outgoing connections to a proxied server originate from the specified local IP address with an optional port.
203+
Parameter value can contain variables. The special value off is equal to none, which allows the system to auto-assign the local IP address and port.
204+
205+
The transparent parameter allows outgoing connections to a proxied server originate from a non-local IP address, for example, from a real IP address of a client:
206+
207+
```
208+
proxy_connect_bind $remote_addr transparent;
209+
210+
```
211+
212+
NOTE: If using `set $<nginx variable>` and `proxy_connect_bind $<nginx variable>` together, you should use `proxy_connect_rewrite.patch` instead, see [Install](#install) for more details.
213+
177214
Variables
178215
=========
179216

@@ -193,7 +230,6 @@ $connect_addr
193230
IP address and port of the remote host, e.g. "192.168.1.5:12345".
194231
IP address is resolved from host name of CONNECT request line.
195232

196-
197233
Nginx Compatibility
198234
===================
199235

0 commit comments

Comments
 (0)