@@ -21,7 +21,7 @@ use Test::Nginx;
21
21
select STDERR ; $| = 1;
22
22
select STDOUT ; $| = 1;
23
23
24
- my $t = Test::Nginx-> new()-> has(qw/ http proxy/ )-> plan(9 );
24
+ my $t = Test::Nginx-> new()-> has(qw/ http proxy/ )-> plan(10 );
25
25
26
26
$t -> write_file_expand(' nginx.conf' , <<'EOF' );
27
27
@@ -120,6 +120,65 @@ $t->stop();
120
120
121
121
# ##############################################################################
122
122
123
+ $t -> write_file_expand(' nginx.conf' , <<'EOF' );
124
+
125
+ %%TEST_GLOBALS%%
126
+
127
+ daemon off;
128
+
129
+ events {
130
+ }
131
+
132
+ http {
133
+ %%TEST_GLOBALS_HTTP%%
134
+
135
+ log_format connect '$remote_addr - $remote_user [$time_local] "$request" '
136
+ '$status $body_bytes_sent var:$connect_host-$connect_port-$connect_addr';
137
+
138
+ access_log %%TESTDIR%%/connect.log connect;
139
+
140
+ server {
141
+ listen 8081;
142
+ listen 8082;
143
+ access_log off;
144
+ location / {
145
+ return 200 "hello $remote_addr $server_port\n";
146
+ }
147
+ }
148
+
149
+ server {
150
+ listen 127.0.0.1:8080;
151
+ server_name localhost;
152
+
153
+ # forward proxy for CONNECT method
154
+
155
+ proxy_connect;
156
+ proxy_connect_allow all;
157
+
158
+ proxy_connect_connect_timeout 10s;
159
+ proxy_connect_read_timeout 10s;
160
+ proxy_connect_send_timeout 10s;
161
+ proxy_connect_send_lowat 0;
162
+
163
+ proxy_connect_address 127.0.0.1:8082;
164
+ # proxy_connect_bind 127.0.0.3;
165
+
166
+ location / {
167
+ proxy_pass http://127.0.0.1:8081;
168
+ }
169
+ }
170
+ }
171
+
172
+ EOF
173
+
174
+
175
+ $t -> run();
176
+ like(http_connect_request(' address.com' , ' 8081' , ' /' ), qr / hello 127.0.0.1 8082/ , ' set remote address without nginx variable' );
177
+ $t -> stop();
178
+
179
+ # ##############################################################################
180
+
181
+
123
182
sub http_connect_request {
124
183
my ($host , $port , $url ) = @_ ;
125
184
my $r = http_connect($host , $port , <<EOF );
0 commit comments