changeset 974:882267679006

Tests: simplified parallel modifications in tests. Mail tests were simplified in c227348453db.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 12 Jul 2016 17:39:03 +0300
parents 7d7aef8b9f3a
children e17ffab3febc
files access.t access_log.t access_log_variables.t addition.t auth_basic.t auth_request.t auth_request_satisfy.t auth_request_set.t autoindex.t autoindex_format.t body.t body_chunked.t charset.t charset_gzip_static.t config_dump.t dav.t dav_chunked.t debug_connection.t debug_connection_syslog.t debug_connection_unix.t empty_gif.t error_log.t fastcgi.t fastcgi_body.t fastcgi_body2.t fastcgi_buffering.t fastcgi_cache.t fastcgi_header_params.t fastcgi_keepalive.t fastcgi_merge_params.t fastcgi_merge_params2.t fastcgi_request_buffering.t fastcgi_request_buffering_chunked.t fastcgi_split.t fastcgi_unix.t fastcgi_variables.t geo.t gunzip.t gunzip_memcached.t gunzip_perl.t gunzip_ssi.t gunzip_static.t gzip.t gzip_flush.t h2.t h2_cache.t h2_fastcgi_request_buffering.t h2_headers.t h2_limit_conn.t h2_limit_req.t h2_priority.t h2_proxy_protocol.t h2_proxy_request_buffering.t h2_proxy_request_buffering_ssl.t h2_proxy_ssl.t h2_request_body.t h2_request_body_preread.t h2_server_tokens.t h2_ssl.t h2_ssl_verify_client.t h2_variables.t headers.t http_disable_symlinks.t http_error_page.t http_expect_100_continue.t http_host.t http_location.t http_location_auto.t http_location_win32.t http_resolver.t http_resolver_aaaa.t http_resolver_cname.t http_server_name.t http_try_files.t http_variables.t image_filter.t image_filter_finalize.t index.t js.t limit_conn.t limit_conn_complex.t limit_req.t map.t map_complex.t memcached.t memcached_fake.t memcached_keepalive.t memcached_keepalive_stale.t mp4.t not_modified.t not_modified_proxy.t perl.t perl_gzip.t post_action.t proxy.t proxy_bind.t proxy_bind_transparent.t proxy_cache.t proxy_cache_bypass.t proxy_cache_chunked.t proxy_cache_convert_head.t proxy_cache_lock.t proxy_cache_lock_age.t proxy_cache_lock_ssi.t proxy_cache_path.t proxy_cache_range.t proxy_cache_revalidate.t proxy_cache_variables.t proxy_cache_vary.t proxy_chunked.t proxy_cookie.t proxy_force_ranges.t proxy_if.t proxy_keepalive.t proxy_limit_rate.t proxy_merge_headers.t proxy_next_upstream.t proxy_next_upstream_tries.t proxy_noclose.t proxy_non_idempotent.t proxy_pass_request.t proxy_protocol.t proxy_protocol_ipv6.t proxy_protocol_port.t proxy_redirect.t proxy_request_buffering.t proxy_request_buffering_chunked.t proxy_request_buffering_keepalive.t proxy_request_buffering_ssl.t proxy_set_body.t proxy_ssi_body.t proxy_ssl.t proxy_ssl_certificate.t proxy_ssl_keepalive.t proxy_ssl_name.t proxy_ssl_verify.t proxy_store.t proxy_unfinished.t proxy_unix.t proxy_upgrade.t proxy_upstream_cookie.t proxy_variables.t proxy_websocket.t proxy_xar.t random_index.t range.t range_charset.t range_flv.t range_if_range.t range_mp4.t realip.t realip_remote_addr.t realip_remote_port.t referer.t request_id.t rewrite.t rewrite_set.t rewrite_unescape.t scgi.t scgi_body.t scgi_cache.t scgi_gzip.t scgi_merge_params.t secure_link.t server_tokens.t slice.t split_clients.t ssi.t ssi_if.t ssi_include_big.t ssi_waited.t ssl.t ssl_certificate_chain.t ssl_certificates.t ssl_engine_keys.t ssl_password_file.t ssl_proxy_protocol.t ssl_proxy_upgrade.t ssl_sni.t ssl_sni_reneg.t ssl_sni_sessions.t ssl_verify_client.t stream_access.t stream_error_log.t stream_limit_conn.t stream_limit_conn_complex.t stream_limit_rate.t stream_map.t stream_proxy.t stream_proxy_bind.t stream_proxy_next_upstream.t stream_proxy_protocol.t stream_proxy_protocol_ipv6.t stream_proxy_protocol_ssl.t stream_proxy_ssl.t stream_proxy_ssl_certificate.t stream_proxy_ssl_name.t stream_proxy_ssl_verify.t stream_ssl.t stream_ssl_variables.t stream_tcp_nodelay.t stream_udp_limit_conn.t stream_udp_proxy.t stream_udp_upstream.t stream_udp_upstream_hash.t stream_udp_upstream_least_conn.t stream_unix.t stream_upstream.t stream_upstream_hash.t stream_upstream_least_conn.t stream_upstream_zone_ssl.t stream_variables.t stub_status.t sub_filter.t sub_filter_merge.t sub_filter_multi.t sub_filter_multi2.t sub_filter_perl.t sub_filter_ssi.t syslog.t upstream.t upstream_hash.t upstream_hash_memcached.t upstream_ip_hash.t upstream_least_conn.t upstream_zone_ssl.t userid.t uwsgi.t xslt.t xslt_params.t
diffstat 230 files changed, 1411 insertions(+), 1409 deletions(-) [+]
line wrap: on
line diff
--- a/access.t
+++ b/access.t
@@ -38,15 +38,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /inet/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
         }
 
         location /inet6/ {
-            proxy_pass http://[::1]:%%PORT_1%%/;
+            proxy_pass http://[::1]:%%PORT_8081%%/;
         }
 
         location /unix/ {
@@ -56,8 +56,8 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
-        listen       [::1]:%%PORT_1%%;
+        listen       127.0.0.1:8081;
+        listen       [::1]:%%PORT_8081%%;
         listen       unix:%%TESTDIR%%/unix.sock;
 
         location /allow_all {
--- a/access_log.t
+++ b/access_log.t
@@ -38,7 +38,7 @@ http {
     log_format binary $binary_remote_addr;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /combined {
--- a/access_log_variables.t
+++ b/access_log_variables.t
@@ -43,7 +43,7 @@ http {
     log_format pipe          '$uri $pipe';
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /iso8601 {
--- a/addition.t
+++ b/addition.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /regular {
--- a/auth_basic.t
+++ b/auth_basic.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/auth_request.t
+++ b/auth_request.t
@@ -44,7 +44,7 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -94,7 +94,7 @@ http {
             auth_request /auth-proxy;
         }
         location = /auth-proxy {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/auth-basic;
+            proxy_pass http://127.0.0.1:8080/auth-basic;
             proxy_pass_request_body off;
             proxy_set_header Content-Length "";
         }
@@ -104,17 +104,17 @@ http {
         }
 
         location = /proxy-double {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/auth-error;
+            proxy_pass http://127.0.0.1:8080/auth-error;
             proxy_intercept_errors on;
             error_page 404 = /proxy-double-fallback;
             client_body_buffer_size 4k;
         }
         location = /proxy-double-fallback {
             auth_request /auth-proxy-double;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/auth-open;
+            proxy_pass http://127.0.0.1:8080/auth-open;
         }
         location = /auth-proxy-double {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/auth-open;
+            proxy_pass http://127.0.0.1:8080/auth-open;
             proxy_pass_request_body off;
             proxy_set_header Content-Length "";
         }
@@ -123,7 +123,7 @@ http {
             auth_request /auth-proxy-cache;
         }
         location = /auth-proxy-cache {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/auth-basic;
+            proxy_pass http://127.0.0.1:8080/auth-basic;
             proxy_pass_request_body off;
             proxy_set_header Content-Length "";
             proxy_cache NAME;
@@ -134,7 +134,7 @@ http {
             auth_request /auth-fastcgi;
         }
         location = /auth-fastcgi {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_pass_request_body off;
         }
     }
@@ -194,7 +194,7 @@ SKIP: {
 	skip 'win32', 2 if $^O eq 'MSWin32';
 
 	$t->run_daemon(\&fastcgi_daemon);
-	$t->waitforsocket('127.0.0.1:' . port(1));
+	$t->waitforsocket('127.0.0.1:' . port(8081));
 
 	like(http_get('/fastcgi'), qr/ 404 /, 'fastcgi auth open');
 	unlike(http_get('/fastcgi'), qr/INVISIBLE/, 'fastcgi auth no content');
@@ -239,7 +239,7 @@ sub http_post_big {
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/auth_request_satisfy.t
+++ b/auth_request_satisfy.t
@@ -38,7 +38,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/auth_request_set.t
+++ b/auth_request_set.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location = /t1.html {
@@ -80,7 +80,7 @@ http {
         location = /t5.html {
             auth_request /auth;
             auth_request_set $args "setargs";
-            proxy_pass http://127.0.0.1:%%PORT_1%%/t5.html;
+            proxy_pass http://127.0.0.1:8081/t5.html;
         }
 
         location = /t6.html {
@@ -89,15 +89,15 @@ http {
         }
 
         location = /auth {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location = /auth2 {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location = /auth {
--- a/autoindex.t
+++ b/autoindex.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/autoindex_format.t
+++ b/autoindex_format.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         autoindex on;
--- a/body.t
+++ b/body.t
@@ -37,12 +37,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_0%% backup;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8080 backup;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
@@ -51,25 +51,25 @@ http {
             client_body_buffer_size 2k;
             add_header X-Body "$request_body";
             add_header X-Body-File "$request_body_file";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /b {
             client_body_buffer_size 2k;
             client_body_in_file_only on;
             add_header X-Body "$request_body";
             add_header X-Body-File "$request_body_file";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /small {
             client_body_in_file_only on;
             add_header X-Original-Uri "$request_uri";
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
         }
         location /single {
             client_body_in_single_buffer on;
             add_header X-Body "$request_body";
             add_header X-Body-File "$request_body_file";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /discard {
             return 200 "TEST\n";
@@ -80,7 +80,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
@@ -89,7 +89,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%%;
+        listen       127.0.0.1:8082;
         server_name  localhost;
 
         location / {
--- a/body_chunked.t
+++ b/body_chunked.t
@@ -37,12 +37,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_0%% backup;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8080 backup;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
@@ -51,20 +51,20 @@ http {
             client_body_buffer_size 2k;
             add_header X-Body "$request_body";
             add_header X-Body-File "$request_body_file";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /b {
             client_body_buffer_size 2k;
             client_body_in_file_only on;
             add_header X-Body "$request_body";
             add_header X-Body-File "$request_body_file";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /single {
             client_body_in_single_buffer on;
             add_header X-Body "$request_body";
             add_header X-Body-File "$request_body_file";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /discard {
             return 200 "TEST\n";
@@ -75,7 +75,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
@@ -84,7 +84,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%%;
+        listen       127.0.0.1:8082;
         server_name  localhost;
 
         location / {
--- a/charset.t
+++ b/charset.t
@@ -45,7 +45,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -74,7 +74,7 @@ http {
         location /proxy/ {
             charset B;
             override_charset on;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
         }
     }
 }
--- a/charset_gzip_static.t
+++ b/charset_gzip_static.t
@@ -44,7 +44,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /t1 {
@@ -64,21 +64,21 @@ http {
 
         location /p/ {
             charset utf-8;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
             proxy_http_version 1.1;
         }
 
         location /p.ab/ {
             charset A;
             source_charset B;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
             proxy_http_version 1.1;
         }
 
         location /p.aa/ {
             charset A;
             source_charset A;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
             proxy_http_version 1.1;
         }
     }
--- a/config_dump.t
+++ b/config_dump.t
@@ -48,11 +48,11 @@ http {
     }
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / { }
--- a/dav.t
+++ b/dav.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/dav_chunked.t
+++ b/dav_chunked.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
--- a/debug_connection.t
+++ b/debug_connection.t
@@ -40,12 +40,12 @@ http {
     error_log %%TESTDIR%%/debug2.log alert;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
-        listen       [::1]:%%PORT_0%%;
+        listen       127.0.0.1:8080;
+        listen       [::1]:%%PORT_8080%%;
         server_name  localhost;
 
         location /debug {
-            proxy_pass http://[::1]:%%PORT_0%%/;
+            proxy_pass http://[::1]:%%PORT_8080%%/;
         }
     }
 }
--- a/debug_connection_syslog.t
+++ b/debug_connection_syslog.t
@@ -36,16 +36,16 @@ events {
 http {
     %%TEST_GLOBALS_HTTP%%
 
-    error_log syslog:server=127.0.0.1:%%PORT_1_UDP%% alert;
-    error_log syslog:server=127.0.0.1:%%PORT_2_UDP%% alert;
+    error_log syslog:server=127.0.0.1:%%PORT_8081_UDP%% alert;
+    error_log syslog:server=127.0.0.1:%%PORT_8082_UDP%% alert;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
-        listen       [::1]:%%PORT_0%%;
+        listen       127.0.0.1:8080;
+        listen       [::1]:%%PORT_8080%%;
         server_name  localhost;
 
         location /debug {
-            proxy_pass http://[::1]:%%PORT_0%%/;
+            proxy_pass http://[::1]:%%PORT_8080%%/;
         }
     }
 }
@@ -63,10 +63,10 @@ plan(skip_all => 'no inet6 support') if 
 
 ###############################################################################
 
-is(get_syslog('/', port(1)), '', 'no debug_connection syslog 1');
-is(get_syslog('/', port(2)), '', 'no debug_connection syslog 2');
+is(get_syslog('/', port(8081)), '', 'no debug_connection syslog 1');
+is(get_syslog('/', port(8082)), '', 'no debug_connection syslog 2');
 
-my @msgs = get_syslog('/debug', port(1), port(2));
+my @msgs = get_syslog('/debug', port(8081), port(8082));
 like($msgs[0], qr/\[debug\]/, 'debug_connection syslog 1');
 like($msgs[1], qr/\[debug\]/, 'debug_connection syslog 2');
 is($msgs[0], $msgs[1], 'debug_connection syslog1 syslog2 match');
--- a/debug_connection_unix.t
+++ b/debug_connection_unix.t
@@ -40,7 +40,7 @@ http {
     error_log %%TESTDIR%%/debug2.log alert;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         listen       unix:%%TESTDIR%%/unix.sock;
         server_name  localhost;
 
--- a/empty_gif.t
+++ b/empty_gif.t
@@ -38,7 +38,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/error_log.t
+++ b/error_log.t
@@ -41,7 +41,7 @@ http {
     limit_req zone=one;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /debug {
--- a/fastcgi.t
+++ b/fastcgi.t
@@ -39,15 +39,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_param REQUEST_URI $request_uri;
         }
 
@@ -61,7 +61,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -73,14 +73,14 @@ unlike(http_head('/'), qr/SEE-THIS/, 'no
 
 like(http_get('/stderr'), qr/SEE-THIS/, 'large stderr handled');
 
-like(http_get('/var?b=127.0.0.1:' . port(1)), qr/SEE-THIS/,
+like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/,
 	'fastcgi with variables');
 like(http_get('/var?b=u'), qr/SEE-THIS/, 'fastcgi with variables to upstream');
 
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_body.t
+++ b/fastcgi_body.t
@@ -35,11 +35,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_param REQUEST_URI $request_uri;
             fastcgi_param CONTENT_LENGTH $content_length;
         }
@@ -49,7 +49,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -141,7 +141,7 @@ sub fastcgi_respond($$$$) {
 sub fastcgi_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/fastcgi_body2.t
+++ b/fastcgi_body2.t
@@ -42,12 +42,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%% max_fails=0;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081 max_fails=0;
+        server 127.0.0.1:8082;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -71,12 +71,12 @@ http {
 
 EOF
 
-$t->run_daemon(\&fastcgi_daemon, port(1));
-$t->run_daemon(\&fastcgi_daemon, port(2));
+$t->run_daemon(\&fastcgi_daemon, port(8081));
+$t->run_daemon(\&fastcgi_daemon, port(8082));
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
-$t->waitforsocket('127.0.0.1:' . port(2));
+$t->waitforsocket('127.0.0.1:' . port(8081));
+$t->waitforsocket('127.0.0.1:' . port(8082));
 
 ###############################################################################
 
@@ -116,7 +116,7 @@ sub fastcgi_daemon {
 		read(STDIN, my $body, $ENV{'CONTENT_LENGTH'});
 		my $len = length $body;
 
-		sleep 3 if $port == port(1);
+		sleep 3 if $port == port(8081);
 
 		print <<EOF;
 Location: http://localhost/redirect
--- a/fastcgi_buffering.t
+++ b/fastcgi_buffering.t
@@ -41,11 +41,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_param REQUEST_URI $request_uri;
             fastcgi_buffering off;
         }
@@ -64,7 +64,7 @@ EOF
 
 $t->run()->plan(2);
 
-$t->run_daemon(\&fastcgi_daemon)->waitforsocket('127.0.0.1:' . port(1));
+$t->run_daemon(\&fastcgi_daemon)->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -74,7 +74,7 @@ like(http_get('/inmemory.html'), qr/set:
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_cache.t
+++ b/fastcgi_cache.t
@@ -42,11 +42,11 @@ http {
                          keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_param REQUEST_URI $request_uri;
             fastcgi_cache NAME;
             fastcgi_cache_key $request_uri;
@@ -58,7 +58,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -79,7 +79,7 @@ like(http_get('/stderr'), qr/SEE-THIS.*^
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_header_params.t
+++ b/fastcgi_header_params.t
@@ -39,11 +39,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_param HTTP_X_BLAH "blah";
         }
     }
@@ -52,7 +52,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -92,7 +92,7 @@ EOF
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_keepalive.t
+++ b/fastcgi_keepalive.t
@@ -35,12 +35,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream backend {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
         keepalive 1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -53,7 +53,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_test_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -138,7 +138,7 @@ sub fastcgi_respond($$) {
 sub fastcgi_test_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/fastcgi_merge_params.t
+++ b/fastcgi_merge_params.t
@@ -46,22 +46,22 @@ http {
     fastcgi_param       HTTP_X_BLAH  "blah";
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         fastcgi_cache  NAME;
 
         location / {
-            fastcgi_pass    127.0.0.1:%%PORT_1%%;
+            fastcgi_pass    127.0.0.1:8081;
         }
 
         location /no/ {
-            fastcgi_pass    127.0.0.1:%%PORT_1%%;
+            fastcgi_pass    127.0.0.1:8081;
             fastcgi_cache   off;
         }
 
         location /custom/ {
-            fastcgi_pass    127.0.0.1:%%PORT_1%%;
+            fastcgi_pass    127.0.0.1:8081;
             fastcgi_param   HTTP_X_BLAH  "custom";
         }
     }
@@ -70,7 +70,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -112,7 +112,7 @@ EOF
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_merge_params2.t
+++ b/fastcgi_merge_params2.t
@@ -46,17 +46,17 @@ http {
     # no fastcgi_param at all, cache switched on at server level
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         fastcgi_cache  NAME;
 
         location / {
-            fastcgi_pass    127.0.0.1:%%PORT_1%%;
+            fastcgi_pass    127.0.0.1:8081;
         }
 
         location /no/ {
-            fastcgi_pass    127.0.0.1:%%PORT_1%%;
+            fastcgi_pass    127.0.0.1:8081;
             fastcgi_cache   off;
         }
     }
@@ -65,7 +65,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -96,7 +96,7 @@ EOF
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_request_buffering.t
+++ b/fastcgi_request_buffering.t
@@ -43,7 +43,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
@@ -53,17 +53,17 @@ http {
 
         location / {
             client_body_buffer_size 2k;
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
         }
         location /single {
             client_body_in_single_buffer on;
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
         }
         location /preread {
-            fastcgi_pass 127.0.0.1:%%PORT_2%%;
+            fastcgi_pass 127.0.0.1:8082;
         }
         location /error_page {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             error_page 404 /404;
             fastcgi_intercept_errors on;
         }
@@ -76,7 +76,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -103,7 +103,7 @@ like(http_get_body('/', '0123456789' x 1
 
 # interactive tests
 
-my $s = get_body('/preread', port(2), 10);
+my $s = get_body('/preread', port(8082), 10);
 ok($s, 'no preread');
 
 SKIP: {
@@ -116,7 +116,7 @@ like($s->{http_end}(), qr/200 OK/, 'no p
 
 }
 
-$s = get_body('/preread', port(2), 10, '01234');
+$s = get_body('/preread', port(8082), 10, '01234');
 ok($s, 'preread');
 
 SKIP: {
@@ -341,7 +341,7 @@ sub log2c { Test::Nginx::log_core('||', 
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_request_buffering_chunked.t
+++ b/fastcgi_request_buffering_chunked.t
@@ -44,7 +44,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
@@ -53,17 +53,17 @@ http {
 
         location / {
             client_body_buffer_size 2k;
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
         }
         location /single {
             client_body_in_single_buffer on;
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
         }
         location /preread {
-            fastcgi_pass 127.0.0.1:%%PORT_2%%;
+            fastcgi_pass 127.0.0.1:8082;
         }
         location /error_page {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             error_page 404 /404;
             fastcgi_intercept_errors on;
         }
@@ -76,7 +76,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -103,7 +103,7 @@ like(http_get_body('/', '0123456789' x 1
 
 # interactive tests
 
-my $s = get_body('/preread', port(2));
+my $s = get_body('/preread', port(8082));
 ok($s, 'no preread');
 
 SKIP: {
@@ -116,7 +116,7 @@ like($s->{http_end}(), qr/200 OK/, 'no p
 
 }
 
-$s = get_body('/preread', port(2), '01234');
+$s = get_body('/preread', port(8082), '01234');
 ok($s, 'preread');
 
 SKIP: {
@@ -129,7 +129,7 @@ like($s->{http_end}(), qr/200 OK/, 'prer
 
 }
 
-$s = get_body('/preread', port(2), '01234', many => 1);
+$s = get_body('/preread', port(8082), '01234', many => 1);
 ok($s, 'chunks');
 
 SKIP: {
@@ -386,7 +386,7 @@ sub log2c { Test::Nginx::log_core('||', 
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/fastcgi_split.t
+++ b/fastcgi_split.t
@@ -42,12 +42,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -60,13 +60,13 @@ http {
 
 EOF
 
-$t->run_daemon(\&fastcgi_daemon, port(1));
-$t->run_daemon(\&fastcgi_daemon, port(2));
+$t->run_daemon(\&fastcgi_daemon, port(8081));
+$t->run_daemon(\&fastcgi_daemon, port(8082));
 
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
-$t->waitforsocket('127.0.0.1:' . port(2));
+$t->waitforsocket('127.0.0.1:' . port(8081));
+$t->waitforsocket('127.0.0.1:' . port(8082));
 
 ###############################################################################
 
@@ -84,10 +84,10 @@ sub fastcgi_daemon {
 	while( $request->Accept() >= 0 ) {
 		$count++;
 
-		if ($port == port(1)) {
+		if ($port == port(8081)) {
 			print 'BAD';
 		}
-		if ($port == port(2)) {
+		if ($port == port(8082)) {
 			print 'Good: header' . CRLF . CRLF;
 		}
 	}
--- a/fastcgi_unix.t
+++ b/fastcgi_unix.t
@@ -44,11 +44,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/fastcgi_variables.t
+++ b/fastcgi_variables.t
@@ -42,19 +42,19 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header X-Script-Name $fastcgi_script_name;
         add_header X-Path-Info $fastcgi_path_info;
 
         location / {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_index index.php;
         }
 
         location /info {
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_split_path_info ^(.+\.php)(.*)$;
         }
     }
@@ -63,7 +63,7 @@ http {
 EOF
 
 $t->run_daemon(\&fastcgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -76,7 +76,7 @@ like(http_get('/info.php/path/info'), qr
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8081), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/geo.t
+++ b/geo.t
@@ -71,7 +71,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/gunzip.t
+++ b/gunzip.t
@@ -40,12 +40,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             gunzip on;
             gzip_vary on;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_set_header Accept-Encoding gzip;
         }
         location /error {
@@ -55,7 +55,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/gunzip_memcached.t
+++ b/gunzip_memcached.t
@@ -42,14 +42,14 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         gunzip on;
 
         location / {
             set $memcached_key $uri;
-            memcached_pass 127.0.0.1:%%PORT_1%%;
+            memcached_pass 127.0.0.1:8081;
             memcached_gzip_flag 2;
         }
     }
@@ -62,24 +62,24 @@ my @memopts = ();
 
 if ($memhelp =~ /repcached/) {
 	# repcached patch adds additional listen socket
-	push @memopts, '-X', port(2);
+	push @memopts, '-X', port(8082);
 }
 if ($memhelp =~ /-U/) {
 	# UDP port is on by default in memcached 1.2.7+
 	push @memopts, '-U', '0';
 }
 
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(1), @memopts);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8081), @memopts);
 
 $t->run()->plan(2);
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start memcached";
 
 # Put compressed value into memcached.  This requires compress_threshold to be
 # set and compressed value to be at least 20% less than original one.
 
-my $memd = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(1) ],
+my $memd = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8081) ],
 	compress_threshold => 1, connect_timeout => 1.0);
 $memd->set('/', 'TEST' x 10)
 	or die "can't put value into memcached: $!";
--- a/gunzip_perl.t
+++ b/gunzip_perl.t
@@ -38,7 +38,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         gunzip on;
--- a/gunzip_ssi.t
+++ b/gunzip_ssi.t
@@ -40,13 +40,13 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
             gunzip on;
             gzip_vary on;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_set_header Accept-Encoding gzip;
         }
 
@@ -56,7 +56,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/gunzip_static.t
+++ b/gunzip_static.t
@@ -40,7 +40,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             gunzip on;
--- a/gzip.t
+++ b/gzip.t
@@ -36,14 +36,14 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             gzip on;
         }
         location /proxy/ {
             gzip on;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/local/;
+            proxy_pass http://127.0.0.1:8080/local/;
         }
         location /local/ {
             gzip off;
--- a/gzip_flush.t
+++ b/gzip_flush.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         gzip on;
--- a/h2.t
+++ b/h2.t
@@ -44,8 +44,8 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8080 http2;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
@@ -91,26 +91,26 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%% http2;
+        listen       127.0.0.1:8082 http2;
         server_name  localhost;
         return 200   first;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%% http2;
+        listen       127.0.0.1:8082 http2;
         server_name  localhost2;
         return 200   second;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_3%% http2;
+        listen       127.0.0.1:8083 http2;
         server_name  localhost;
 
         http2_max_concurrent_streams 1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_4%% http2;
+        listen       127.0.0.1:8084 http2;
         server_name  localhost;
 
         http2_recv_timeout 1s;
@@ -119,7 +119,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_5%% http2;
+        listen       127.0.0.1:8085 http2;
         server_name  localhost;
 
         http2_idle_timeout 1s;
@@ -127,26 +127,26 @@ http {
 
         location /proxy2/ {
             add_header X-Body $request_body;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_6%% http2;
+        listen       127.0.0.1:8086 http2;
         server_name  localhost;
 
         send_timeout 1s;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_7%% http2;
+        listen       127.0.0.1:8087 http2;
         server_name  localhost;
 
         client_header_timeout 1s;
         client_body_timeout 1s;
 
         location /proxy/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
         }
     }
 }
@@ -187,7 +187,7 @@ like($r, qr!Upgrade: h2c!, 'upgrade - to
 
 # SETTINGS
 
-my $s = Test::Nginx::HTTP2->new(port(0), pure => 1);
+my $s = Test::Nginx::HTTP2->new(port(8080), pure => 1);
 my $frames = $s->read(all => [
 	{ type => 'WINDOW_UPDATE' },
 	{ type => 'SETTINGS'}
@@ -229,11 +229,11 @@ is($frame->{sid}, 0, 'PING stream');
 SKIP: {
 skip 'long tests', 6 unless $ENV{TEST_NGINX_UNSAFE};
 
-push my @s, Test::Nginx::HTTP2->new(port(4), pure => 1);
-push @s, Test::Nginx::HTTP2->new(port(4), pure => 1);
+push my @s, Test::Nginx::HTTP2->new(port(8084), pure => 1);
+push @s, Test::Nginx::HTTP2->new(port(8084), pure => 1);
 $s[-1]->h2_ping('SEE-THIS');
-push @s, Test::Nginx::HTTP2->new(port(5), pure => 1);
-push @s, Test::Nginx::HTTP2->new(port(5), pure => 1);
+push @s, Test::Nginx::HTTP2->new(port(8085), pure => 1);
+push @s, Test::Nginx::HTTP2->new(port(8085), pure => 1);
 $s[-1]->h2_ping('SEE-THIS');
 
 select undef, undef, undef, 2.1;
@@ -497,7 +497,7 @@ is($frame->{headers}->{'location'}, 'tex
 
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
 is($frame->{headers}->{':status'}, 301, 'return 301 relative - status');
-is($frame->{headers}->{'location'}, 'http://localhost:' . port(0) . '/',
+is($frame->{headers}->{'location'}, 'http://localhost:' . port(8080) . '/',
 	'return 301 relative - location');
 
 # return 301 with relative URI and ':authority' request header field
@@ -513,7 +513,7 @@ is($frame->{headers}->{'location'}, 'htt
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
 is($frame->{headers}->{':status'}, 301,
 	'return 301 relative - authority - status');
-is($frame->{headers}->{'location'}, 'http://localhost:' . port(0) . '/',
+is($frame->{headers}->{'location'}, 'http://localhost:' . port(8080) . '/',
 	'return 301 relative - authority - location');
 
 # return 301 with relative URI and 'host' request header field
@@ -529,12 +529,12 @@ is($frame->{headers}->{'location'}, 'htt
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
 is($frame->{headers}->{':status'}, 301,
 	'return 301 relative - host - status');
-is($frame->{headers}->{'location'}, 'http://localhost:' . port(0) . '/',
+is($frame->{headers}->{'location'}, 'http://localhost:' . port(8080) . '/',
 	'return 301 relative - host - location');
 
 # virtual host
 
-$s = Test::Nginx::HTTP2->new(port(2));
+$s = Test::Nginx::HTTP2->new(port(8082));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -626,7 +626,7 @@ is($frame->{headers}->{'content-type'}, 
 TODO: {
 local $TODO = 'not yet' unless $t->has_version('1.9.12');
 
-$s = Test::Nginx::HTTP2->new(port(7));
+$s = Test::Nginx::HTTP2->new(port(8087));
 $sid = $s->new_stream({ path => '/t2.html', split => [35],
 	split_delay => 2.1 });
 $frames = $s->read(all => [{ type => 'RST_STREAM' }]);
@@ -648,7 +648,7 @@ ok($frame, 'client header timeout - PING
 TODO: {
 local $TODO = 'not yet' unless $t->has_version('1.9.12');
 
-$s = Test::Nginx::HTTP2->new(port(7));
+$s = Test::Nginx::HTTP2->new(port(8087));
 $sid = $s->new_stream({ path => '/proxy/t2.html', body_more => 1 });
 $s->h2_body('TEST', { split => [10], split_delay => 2.1 });
 $frames = $s->read(all => [{ type => 'RST_STREAM' }]);
@@ -829,7 +829,7 @@ is($frame->{headers}->{':status'}, 200, 
 
 # write event send timeout
 
-$s = Test::Nginx::HTTP2->new(port(6));
+$s = Test::Nginx::HTTP2->new(port(8086));
 $sid = $s->new_stream({ path => '/tbig.html' });
 $s->h2_window(2**30, $sid);
 $s->h2_window(2**30);
@@ -916,7 +916,7 @@ is($sum, 2**16 + 80, 'multiple - stream2
 
 # http2_max_concurrent_streams
 
-$s = Test::Nginx::HTTP2->new(port(3), pure => 1);
+$s = Test::Nginx::HTTP2->new(port(8083), pure => 1);
 $frames = $s->read(all => [{ type => 'SETTINGS' }]);
 
 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
@@ -994,7 +994,7 @@ is($frame->{headers}->{':status'}, 200, 
 
 # invalid connection preface
 
-$s = Test::Nginx::HTTP2->new(port(0), preface => 'x' x 16, pure => 1);
+$s = Test::Nginx::HTTP2->new(port(8080), preface => 'x' x 16, pure => 1);
 $frames = $s->read(all => [{ type => 'GOAWAY' }]);
 
 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
@@ -1002,7 +1002,7 @@ ok($frame, 'invalid preface - GOAWAY fra
 is($frame->{code}, 1, 'invalid preface - error code');
 
 my $preface = 'PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8;
-$s = Test::Nginx::HTTP2->new(port(0), preface => $preface, pure => 1);
+$s = Test::Nginx::HTTP2->new(port(8080), preface => $preface, pure => 1);
 $frames = $s->read(all => [{ type => 'GOAWAY' }]);
 
 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
@@ -1073,24 +1073,24 @@ is($frame->{value}, 'SEE-THIS', 'unknown
 
 # graceful shutdown with stream waiting on HEADERS payload
 
-my $grace = Test::Nginx::HTTP2->new(port(4));
+my $grace = Test::Nginx::HTTP2->new(port(8084));
 $grace->new_stream({ split => [ 9 ], abort => 1 });
 
 # graceful shutdown with stream waiting on WINDOW_UPDATE
 
-my $grace2 = Test::Nginx::HTTP2->new(port(4));
+my $grace2 = Test::Nginx::HTTP2->new(port(8084));
 $sid = $grace2->new_stream({ path => '/t1.html' });
 $grace2->read(all => [{ sid => $sid, length => 2**16 - 1 }]);
 
 # graceful shutdown waiting on incomplete request body DATA frames
 
-my $grace3 = Test::Nginx::HTTP2->new(port(5));
+my $grace3 = Test::Nginx::HTTP2->new(port(8085));
 $sid = $grace3->new_stream({ path => '/proxy2/t2.html', body_more => 1 });
 $grace3->h2_body('TEST', { body_more => 1 });
 
 # partial request body data frame with connection close after body timeout
 
-my $grace4 = Test::Nginx::HTTP2->new(port(7));
+my $grace4 = Test::Nginx::HTTP2->new(port(8087));
 $sid = $grace4->new_stream({ path => '/proxy/t2.html', body_more => 1 });
 $grace4->h2_body('TEST', { split => [ 12 ], abort => 1 });
 
--- a/h2_cache.t
+++ b/h2_cache.t
@@ -39,17 +39,17 @@ http {
     proxy_cache_path %%TESTDIR%%/cache    keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8080 http2;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location /cache {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_cache NAME;
             proxy_cache_valid 1m;
         }
         location /proxy_buffering_off {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_cache NAME;
             proxy_cache_valid 1m;
             proxy_buffering off;
--- a/h2_fastcgi_request_buffering.t
+++ b/h2_fastcgi_request_buffering.t
@@ -38,12 +38,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
+        listen       127.0.0.1:8080 http2;
         server_name  localhost;
 
         location / {
             fastcgi_request_buffering off;
-            fastcgi_pass 127.0.0.1:%%PORT_1%%;
+            fastcgi_pass 127.0.0.1:8081;
             fastcgi_param REQUEST_URI $request_uri;
             client_body_buffer_size 1k;
         }
@@ -190,7 +190,7 @@ sub get_body {
 	$server = IO::Socket::INET->new(
 		Proto => 'tcp',
 		LocalHost => '127.0.0.1',
-		LocalPort => port(1),
+		LocalPort => port(8081),
 		Listen => 5,
 		Timeout => 3,
 		Reuse => 1
--- a/h2_headers.t
+++ b/h2_headers.t
@@ -38,9 +38,9 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
-        listen       127.0.0.1:%%PORT_1%%;
-        listen       127.0.0.1:%%PORT_2%% http2 sndbuf=128;
+        listen       127.0.0.1:8080 http2;
+        listen       127.0.0.1:8081;
+        listen       127.0.0.1:8082 http2 sndbuf=128;
         server_name  localhost;
 
         http2_max_field_size 128k;
@@ -70,12 +70,12 @@ http {
         location /proxy/ {
             add_header X-UC-a $upstream_cookie_a;
             add_header X-UC-c $upstream_cookie_c;
-            proxy_pass http://127.0.0.1:%%PORT_3%%/;
+            proxy_pass http://127.0.0.1:8083/;
             proxy_set_header X-Cookie-a $cookie_a;
             proxy_set_header X-Cookie-c $cookie_c;
         }
         location /proxy2/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
         }
         location /set-cookie {
             add_header Set-Cookie a=b;
@@ -91,14 +91,14 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_4%% http2;
+        listen       127.0.0.1:8084 http2;
         server_name  localhost;
 
         http2_max_field_size 22;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_5%% http2;
+        listen       127.0.0.1:8085 http2;
         server_name  localhost;
 
         http2_max_header_size 64;
@@ -113,7 +113,7 @@ open OLDERR, ">&", \*STDERR; close STDER
 $t->run();
 open STDERR, ">&", \*OLDERR;
 
-$t->waitforsocket('127.0.0.1:' . port(3));
+$t->waitforsocket('127.0.0.1:' . port(8083));
 
 # file size is slightly beyond initial window size: 2**16 + 80 bytes
 
@@ -660,7 +660,7 @@ cmp_ok($data[-1], '<=', 2**14, 'response
 TODO: {
 local $TODO = 'not yet' unless $t->has_version('1.9.7');
 
-$s = Test::Nginx::HTTP2->new(port(2));
+$s = Test::Nginx::HTTP2->new(port(8082));
 $s->h2_settings(0, 0x5 => 2**17);
 
 $sid = $s->new_stream({ path => '/frame_size?h=' . 'x' x 2**15 });
@@ -679,7 +679,7 @@ is(length join('', @{$frame->{headers}->
 
 # response header block split and sent in parts
 
-$s = Test::Nginx::HTTP2->new(port(2));
+$s = Test::Nginx::HTTP2->new(port(8082));
 $sid = $s->new_stream({ path => '/continuation?h=' . 'x' x 2**15 });
 $frames = $s->read(all => [{ sid => $sid, fin => 0x4 }]);
 
@@ -694,7 +694,7 @@ is(length join('', @{@$frames[-1]->{head
 
 # max_field_size - header field name
 
-$s = Test::Nginx::HTTP2->new(port(4));
+$s = Test::Nginx::HTTP2->new(port(8084));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -717,7 +717,7 @@ ok($frame, 'field name size less');
 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
 ok($frame, 'field name size second');
 
-$s = Test::Nginx::HTTP2->new(port(4));
+$s = Test::Nginx::HTTP2->new(port(8084));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -729,7 +729,7 @@ ok($frame, 'field name size second');
 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
 ok($frame, 'field name size equal');
 
-$s = Test::Nginx::HTTP2->new(port(4));
+$s = Test::Nginx::HTTP2->new(port(8084));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -743,7 +743,7 @@ is($frame, undef, 'field name size great
 
 # max_field_size - header field value
 
-$s = Test::Nginx::HTTP2->new(port(4));
+$s = Test::Nginx::HTTP2->new(port(8084));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -755,7 +755,7 @@ is($frame, undef, 'field name size great
 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
 ok($frame, 'field value size less');
 
-$s = Test::Nginx::HTTP2->new(port(4));
+$s = Test::Nginx::HTTP2->new(port(8084));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -767,7 +767,7 @@ ok($frame, 'field value size less');
 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
 ok($frame, 'field value size equal');
 
-$s = Test::Nginx::HTTP2->new(port(4));
+$s = Test::Nginx::HTTP2->new(port(8084));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -781,7 +781,7 @@ is($frame, undef, 'field value size grea
 
 # max_header_size
 
-$s = Test::Nginx::HTTP2->new(port(5));
+$s = Test::Nginx::HTTP2->new(port(8085));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -804,7 +804,7 @@ ok($frame, 'header size less');
 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
 ok($frame, 'header size second');
 
-$s = Test::Nginx::HTTP2->new(port(5));
+$s = Test::Nginx::HTTP2->new(port(8085));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -816,7 +816,7 @@ ok($frame, 'header size second');
 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
 ok($frame, 'header size equal');
 
-$s = Test::Nginx::HTTP2->new(port(5));
+$s = Test::Nginx::HTTP2->new(port(8085));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -831,7 +831,7 @@ is($frame, undef, 'header size greater')
 # header size is based on (decompressed) header list
 # two extra 1-byte indices would otherwise fit in max_header_size
 
-$s = Test::Nginx::HTTP2->new(port(5));
+$s = Test::Nginx::HTTP2->new(port(8085));
 $sid = $s->new_stream({ headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
@@ -1013,7 +1013,7 @@ sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
 		LocalHost => '127.0.0.1',
-		LocalPort => port(3),
+		LocalPort => port(8083),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/h2_limit_conn.t
+++ b/h2_limit_conn.t
@@ -39,7 +39,7 @@ http {
     limit_conn_zone  $binary_remote_addr  zone=conn:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
+        listen       127.0.0.1:8080 http2;
         server_name  localhost;
 
         location /t.html {
--- a/h2_limit_req.t
+++ b/h2_limit_req.t
@@ -43,8 +43,8 @@ http {
     limit_req_zone   $binary_remote_addr  zone=req:1m rate=1r/s;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8080 http2;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / { }
@@ -56,7 +56,7 @@ http {
             add_header X-Body $request_body;
             add_header X-Body-File $request_body_file;
             client_body_in_file_only on;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             limit_req  zone=req burst=2;
         }
     }
--- a/h2_priority.t
+++ b/h2_priority.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
+        listen       127.0.0.1:8080 http2;
         server_name  localhost;
     }
 }
--- a/h2_proxy_protocol.t
+++ b/h2_proxy_protocol.t
@@ -39,7 +39,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% proxy_protocol http2;
+        listen       127.0.0.1:8080 proxy_protocol http2;
         server_name  localhost;
 
         location /pp {
@@ -59,7 +59,7 @@ EOF
 ###############################################################################
 
 my $proxy = 'PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF;
-my $s = Test::Nginx::HTTP2->new(port(0), proxy => $proxy);
+my $s = Test::Nginx::HTTP2->new(port(8080), proxy => $proxy);
 my $sid = $s->new_stream({ path => '/pp' });
 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -70,7 +70,7 @@ is($frame->{headers}->{'x-pp'}, '192.0.2
 # invalid PROXY protocol string
 
 $proxy = 'BOGUS TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF;
-$s = Test::Nginx::HTTP2->new(port(0), preface => $proxy, pure => 1);
+$s = Test::Nginx::HTTP2->new(port(8080), preface => $proxy, pure => 1);
 $frames = $s->read(all => [{ type => 'GOAWAY' }]);
 
 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
--- a/h2_proxy_request_buffering.t
+++ b/h2_proxy_request_buffering.t
@@ -40,18 +40,18 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
+        listen       127.0.0.1:8080 http2;
         server_name  localhost;
 
         location / {
             proxy_request_buffering off;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             client_body_buffer_size 1k;
         }
         location /chunked {
             proxy_request_buffering off;
             proxy_http_version 1.1;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             client_body_buffer_size 1k;
         }
     }
@@ -169,7 +169,7 @@ sub get_body {
 	$server = IO::Socket::INET->new(
 		Proto => 'tcp',
 		LocalHost => '127.0.0.1',
-		LocalPort => port(1),
+		LocalPort => port(8081),
 		Listen => 5,
 		Timeout => 3,
 		Reuse => 1
--- a/h2_proxy_request_buffering_ssl.t
+++ b/h2_proxy_request_buffering_ssl.t
@@ -41,24 +41,24 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
+        listen       127.0.0.1:8080 http2;
         server_name  localhost;
 
         location / {
             proxy_request_buffering off;
-            proxy_pass https://127.0.0.1:%%PORT_2%%;
+            proxy_pass https://127.0.0.1:8082;
             client_body_buffer_size 512;
         }
         location /chunked {
             proxy_request_buffering off;
             proxy_http_version 1.1;
-            proxy_pass https://127.0.0.1:%%PORT_2%%;
+            proxy_pass https://127.0.0.1:8082;
             client_body_buffer_size 512;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%% ssl;
+        listen       127.0.0.1:8082 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
@@ -66,13 +66,13 @@ http {
 
         location / {
             proxy_request_buffering off;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             client_body_buffer_size 1k;
         }
         location /chunked {
             proxy_request_buffering off;
             proxy_http_version 1.1;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             client_body_buffer_size 1k;
         }
     }
@@ -194,7 +194,7 @@ sub get_body {
 	$server = IO::Socket::INET->new(
 		Proto => 'tcp',
 		LocalHost => '127.0.0.1',
-		LocalPort => port(1),
+		LocalPort => port(8081),
 		Listen => 5,
 		Timeout => 3,
 		Reuse => 1
--- a/h2_proxy_ssl.t
+++ b/h2_proxy_ssl.t
@@ -41,8 +41,8 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
-        listen       127.0.0.1:%%PORT_1%% ssl;
+        listen       127.0.0.1:8080 http2;
+        listen       127.0.0.1:8081 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
@@ -50,7 +50,7 @@ http {
 
         location / { }
         location /proxy_ssl/ {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
         }
     }
 }
--- a/h2_request_body.t
+++ b/h2_request_body.t
@@ -40,8 +40,8 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8080 http2;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
@@ -51,14 +51,14 @@ http {
             add_header X-Body $request_body;
             add_header X-Body-File $request_body_file;
             client_body_in_file_only on;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
         }
         location /client_max_body_size {
             add_header X-Body $request_body;
             add_header X-Body-File $request_body_file;
             client_body_in_single_buffer on;
             client_body_in_file_only on;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             client_max_body_size 10;
         }
     }
--- a/h2_request_body_preread.t
+++ b/h2_request_body_preread.t
@@ -40,8 +40,8 @@ http {
     limit_req_zone   $binary_remote_addr  zone=req:1m rate=30r/m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8080 http2;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         http2_body_preread_size 10;
@@ -49,39 +49,39 @@ http {
         location /t { }
         location / {
             add_header X-Body $request_body;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/t;
+            proxy_pass http://127.0.0.1:8081/t;
 
             location /req {
                 limit_req  zone=req burst=2;
-                proxy_pass http://127.0.0.1:%%PORT_1%%/t;
+                proxy_pass http://127.0.0.1:8081/t;
             }
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%% http2;
+        listen       127.0.0.1:8082 http2;
         server_name  localhost;
 
         http2_body_preread_size 0;
 
         location / {
             add_header X-Body $request_body;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/t;
+            proxy_pass http://127.0.0.1:8081/t;
 
             location /req {
                 limit_req  zone=req burst=2;
-                proxy_pass http://127.0.0.1:%%PORT_1%%/t;
+                proxy_pass http://127.0.0.1:8081/t;
             }
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_3%% http2;
+        listen       127.0.0.1:8083 http2;
         server_name  localhost;
 
         location / {
             add_header X-Body $request_body;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/t;
+            proxy_pass http://127.0.0.1:8081/t;
         }
     }
 }
@@ -144,7 +144,7 @@ is($frame->{code}, 3, 'beyond preread li
 TODO: {
 local $TODO = 'not yet';
 
-$s = Test::Nginx::HTTP2->new(port(2));
+$s = Test::Nginx::HTTP2->new(port(8082));
 $sid = $s->new_stream({ body => 'TEST' });
 $frames = $s->read(all => [{ type => 'RST_STREAM' }], wait => 0.5);
 
@@ -155,7 +155,7 @@ is($frame->{code}, 3, 'zero preread - FL
 
 # zero preread size - limited
 
-$s = Test::Nginx::HTTP2->new(port(2));
+$s = Test::Nginx::HTTP2->new(port(8082));
 $sid = $s->new_stream({ path => '/req', body => 'TEST' });
 $frames = $s->read(all => [{ type => 'RST_STREAM' }]);
 
@@ -165,7 +165,7 @@ is($frame->{code}, 3, 'zero preread limi
 
 # REFUSED_STREAM on request body prior SETTINGS acknowledgement
 
-$s = Test::Nginx::HTTP2->new(port(0), pure => 1);
+$s = Test::Nginx::HTTP2->new(port(8080), pure => 1);
 $sid = $s->new_stream({ body => 'TEST' });
 $frames = $s->read(all => [{ type => 'RST_STREAM' }]);
 
@@ -174,7 +174,7 @@ is($frame->{code}, 7, 'no SETTINGS ack -
 
 # default preread size - no REFUSED_STREAM expected
 
-$s = Test::Nginx::HTTP2->new(port(3), pure => 1);
+$s = Test::Nginx::HTTP2->new(port(8083), pure => 1);
 $sid = $s->new_stream({ body => 'TEST' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
--- a/h2_server_tokens.t
+++ b/h2_server_tokens.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
+        listen       127.0.0.1:8080 http2;
         server_name  localhost;
 
         location /200 {
--- a/h2_ssl.t
+++ b/h2_ssl.t
@@ -44,7 +44,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2 ssl;
+        listen       127.0.0.1:8080 http2 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
@@ -99,7 +99,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_npn() or die; };
 skip 'OpenSSL NPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, npn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, npn => 'h2');
 $sid = $s->new_stream({ path => '/h2' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -114,7 +114,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_alpn() or die; };
 skip 'OpenSSL ALPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, alpn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, alpn => 'h2');
 $sid = $s->new_stream({ path => '/h2' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -129,7 +129,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_npn() or die; };
 skip 'OpenSSL NPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, npn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, npn => 'h2');
 $sid = $s->new_stream({ path => '/sp' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -144,7 +144,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_alpn() or die; };
 skip 'OpenSSL ALPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, alpn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, alpn => 'h2');
 $sid = $s->new_stream({ path => '/sp' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -159,7 +159,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_npn() or die; };
 skip 'OpenSSL NPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, npn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, npn => 'h2');
 $sid = $s->new_stream({ path => '/scheme' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -174,7 +174,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_alpn() or die; };
 skip 'OpenSSL ALPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, alpn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, alpn => 'h2');
 $sid = $s->new_stream({ path => '/scheme' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -189,7 +189,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_npn() or die; };
 skip 'OpenSSL NPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, npn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, npn => 'h2');
 $sid = $s->new_stream({ path => '/https' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
@@ -204,7 +204,7 @@ SKIP: {
 eval { IO::Socket::SSL->can_alpn() or die; };
 skip 'OpenSSL ALPN support required', 1 if $@;
 
-$s = Test::Nginx::HTTP2->new(port(0), SSL => 1, alpn => 'h2');
+$s = Test::Nginx::HTTP2->new(port(8080), SSL => 1, alpn => 'h2');
 $sid = $s->new_stream({ path => '/https' });
 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
 
--- a/h2_ssl_verify_client.t
+++ b/h2_ssl_verify_client.t
@@ -53,7 +53,7 @@ http {
     add_header X-Verify $ssl_client_verify;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl http2;
+        listen       127.0.0.1:8080 ssl http2;
         server_name  localhost;
 
         ssl_client_certificate client.crt;
@@ -62,7 +62,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl http2;
+        listen       127.0.0.1:8080 ssl http2;
         server_name  example.com;
 
         location / { }
@@ -122,7 +122,7 @@ sub get {
 		$s = IO::Socket::SSL->new(
 			Proto => 'tcp',
 			PeerAddr => '127.0.0.1',
-			PeerPort => port(0),
+			PeerPort => port(8080),
 			SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
 			SSL_alpn_protocols => [ 'h2' ],
 			SSL_hostname => $sni,
@@ -139,7 +139,7 @@ sub get {
 		return undef;
 	}
 
-	my $sess = Test::Nginx::HTTP2->new(port(0), socket => $s);
+	my $sess = Test::Nginx::HTTP2->new(port(8080), socket => $s);
 	my $sid = $sess->new_stream({ headers => [
 		{ name => ':method', value => 'GET', mode => 0 },
 		{ name => ':scheme', value => 'http', mode => 0 },
--- a/h2_variables.t
+++ b/h2_variables.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% http2;
+        listen       127.0.0.1:8080 http2;
         server_name  localhost;
 
         location /h2 {
--- a/headers.t
+++ b/headers.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header   X-URI $uri;
--- a/http_disable_symlinks.t
+++ b/http_disable_symlinks.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  s1;
 
         location /on/ {
@@ -123,7 +123,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  s2;
 
         open_file_cache max=16 inactive=60s;
--- a/http_error_page.t
+++ b/http_error_page.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /redirect200 {
@@ -86,7 +86,7 @@ http {
         }
 
         location /auto/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
     }
 }
--- a/http_expect_100_continue.t
+++ b/http_expect_100_continue.t
@@ -36,10 +36,10 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/local;
+            proxy_pass http://127.0.0.1:8080/local;
         }
         location /local {
         }
--- a/http_host.t
+++ b/http_host.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen  127.0.0.1:%%PORT_0%%;
+        listen  127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -55,7 +55,7 @@ EOF
 
 is(http_host_header('www.abcd-ef.g02.xyz'), 'www.abcd-ef.g02.xyz',
 	'domain w/o port (host header)');
-is(http_host_header('abcd-ef.g02.xyz:' . port(0)), 'abcd-ef.g02.xyz',
+is(http_host_header('abcd-ef.g02.xyz:' . port(8080)), 'abcd-ef.g02.xyz',
 	'domain w/port (host header)');
 
 is(http_absolute_path('abcd-ef.g02.xyz'), 'abcd-ef.g02.xyz',
--- a/http_location.t
+++ b/http_location.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location = / {
--- a/http_location_auto.t
+++ b/http_location_auto.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_hide_header X-Location;
@@ -53,7 +53,7 @@ http {
         #
         # Key factor is that "-" is less than "/".
 
-        location /a/  { proxy_pass http://127.0.0.1:%%PORT_0%%/a-a; }
+        location /a/  { proxy_pass http://127.0.0.1:8080/a-a; }
         location /a-a { add_header X-Location a-a; return 204; }
         location /a-b { add_header X-Location a-b; return 204; }
     }
--- a/http_location_win32.t
+++ b/http_location_win32.t
@@ -38,7 +38,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/http_resolver.t
+++ b/http_resolver.t
@@ -39,13 +39,13 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            resolver    127.0.0.1:%%PORT_1_UDP%%;
+            resolver    127.0.0.1:%%PORT_8081_UDP%%;
             resolver_timeout 1s;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
 
             proxy_next_upstream http_504 timeout error;
             proxy_intercept_errors on;
@@ -53,46 +53,46 @@ http {
             error_page 504 502 /50x;
         }
         location /two {
-            resolver    127.0.0.1:%%PORT_1_UDP%% 127.0.0.1:%%PORT_2_UDP%%;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            resolver    127.0.0.1:%%PORT_8081_UDP%% 127.0.0.1:%%PORT_8082_UDP%%;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
         }
         location /valid {
-            resolver    127.0.0.1:%%PORT_1_UDP%% valid=5s;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            resolver    127.0.0.1:%%PORT_8081_UDP%% valid=5s;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
         }
         location /case {
-            resolver    127.0.0.1:%%PORT_1_UDP%%;
-            proxy_pass  http://$http_x_name:%%PORT_0%%/backend;
+            resolver    127.0.0.1:%%PORT_8081_UDP%%;
+            proxy_pass  http://$http_x_name:%%PORT_8080%%/backend;
         }
         location /invalid {
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
         }
         location /long {
-            resolver    127.0.0.1:%%PORT_1_UDP%%;
+            resolver    127.0.0.1:%%PORT_8081_UDP%%;
             resolver_timeout 4s;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
         }
         location /resend {
-            resolver    127.0.0.1:%%PORT_1_UDP%%;
+            resolver    127.0.0.1:%%PORT_8081_UDP%%;
             resolver_timeout 8s;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
         }
         location /bad {
-            resolver    127.0.0.1:%%PORT_4_UDP%%;
+            resolver    127.0.0.1:%%PORT_8084_UDP%%;
             resolver_timeout 1s;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
         }
         location /tcp {
-            resolver    127.0.0.1:%%PORT_3_UDP%% 127.0.0.1:%%PORT_2_UDP%%;
+            resolver    127.0.0.1:%%PORT_8083_UDP%% 127.0.0.1:%%PORT_8082_UDP%%;
             resolver_timeout 1s;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
             proxy_connect_timeout 1s;
             add_header X-IP $upstream_addr;
             error_page 504 502 /50x;
 
             location /tcp2 {
                 resolver_timeout 8s;
-                proxy_pass  http://$host:%%PORT_0%%/backend;
+                proxy_pass  http://$host:%%PORT_8080%%/backend;
             }
         }
 
@@ -107,24 +107,24 @@ http {
 
 EOF
 
-$t->run_daemon(\&dns_daemon, port(1), $t);
-$t->run_daemon(\&dns_daemon, port(2), $t);
+$t->run_daemon(\&dns_daemon, port(8081), $t);
+$t->run_daemon(\&dns_daemon, port(8082), $t);
 
-$t->run_daemon(\&dns_daemon, port(3), $t, tcp => 1);
-$t->waitforfile($t->testdir . '/' . port(3));
-port(3, socket => 1)->close();
+$t->run_daemon(\&dns_daemon, port(8083), $t, tcp => 1);
+$t->waitforfile($t->testdir . '/' . port(8083));
+port(8083, socket => 1)->close();
 
-$t->run_daemon(\&dns_daemon, port(4), $t);
+$t->run_daemon(\&dns_daemon, port(8084), $t);
 
 $t->run()->plan(38);
 
-$t->waitforfile($t->testdir . '/' . port(1));
-$t->waitforfile($t->testdir . '/' . port(2));
-$t->waitforfile($t->testdir . '/' . port(4));
+$t->waitforfile($t->testdir . '/' . port(8081));
+$t->waitforfile($t->testdir . '/' . port(8082));
+$t->waitforfile($t->testdir . '/' . port(8084));
 
 ###############################################################################
 
-my $p0 = port(0);
+my $p0 = port(8080);
 
 # schedule resend test, which takes about 5 seconds to complete
 
@@ -488,7 +488,7 @@ sub reply_handler {
 		push @rdata, rd_addr(0, '127.0.0.1');
 
 	} elsif ($name eq '2.example.net') {
-		if ($port == port(1)) {
+		if ($port == port(8081)) {
 			$state->{twocnt}++;
 		}
 		if ($state->{twocnt} & 1) {
@@ -500,7 +500,7 @@ sub reply_handler {
 		}
 
 	} elsif ($name =~ /tcp2?.example.net/) {
-		$rcode = FORMERR if $port == port(2);
+		$rcode = FORMERR if $port == port(8082);
 		$hdr |= 0x0300 unless $extra{tcp};
 		push @rdata, rd_addr($ttl, $extra{tcp}
 			? '127.0.0.1' : '127.0.0.201') if $type == A;
@@ -536,7 +536,7 @@ sub dns_daemon {
 	my $tcp = 0;
 
 	if ($extra{tcp}) {
-		$tcp = port(3, socket => 1);
+		$tcp = port(8083, socket => 1);
 		$sel->add($tcp);
 	}
 
--- a/http_resolver_aaaa.t
+++ b/http_resolver_aaaa.t
@@ -37,13 +37,13 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
-        listen       [::1]:%%PORT_0%%;
+        listen       127.0.0.1:8080;
+        listen       [::1]:%%PORT_8080%%;
         server_name  localhost;
 
         location / {
-            resolver    127.0.0.1:%%PORT_1_UDP%%;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            resolver    127.0.0.1:%%PORT_8081_UDP%%;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
 
             proxy_next_upstream http_504 timeout error;
             proxy_intercept_errors on;
@@ -52,8 +52,8 @@ http {
             add_header X-Host $upstream_addr;
         }
         location /two {
-            resolver    127.0.0.1:%%PORT_1_UDP%% 127.0.0.1:%%PORT_2_UDP%%;
-            proxy_pass  http://$host:%%PORT_0%%/backend;
+            resolver    127.0.0.1:%%PORT_8081_UDP%% 127.0.0.1:%%PORT_8082_UDP%%;
+            proxy_pass  http://$host:%%PORT_8080%%/backend;
         }
 
         location /backend {
@@ -69,17 +69,17 @@ EOF
 
 $t->try_run('no inet6 support')->plan(72);
 
-$t->run_daemon(\&dns_daemon, port(1), $t);
-$t->run_daemon(\&dns_daemon, port(2), $t);
+$t->run_daemon(\&dns_daemon, port(8081), $t);
+$t->run_daemon(\&dns_daemon, port(8082), $t);
 
-$t->waitforfile($t->testdir . '/' . port(1));
-$t->waitforfile($t->testdir . '/' . port(2));
+$t->waitforfile($t->testdir . '/' . port(8081));
+$t->waitforfile($t->testdir . '/' . port(8082));
 
 ###############################################################################
 
 my (@n, $response);
 
-my $p0 = port(0);
+my $p0 = port(8080);
 
 like(http_host_header('aaaa.example.net', '/'), qr/\[fe80::1\]/, 'AAAA');
 like(http_host_header('cname.example.net', '/'), qr/\[fe80::1\]/, 'CNAME');
@@ -332,7 +332,7 @@ sub reply_handler {
 		}
 
 	} elsif ($name eq '2.example.net') {
-		if ($port == port(1)) {
+		if ($port == port(8081)) {
 			$state->{twocnt}++;
 		}
 		if ($state->{twocnt} & 1) {
--- a/http_resolver_cname.t
+++ b/http_resolver_cname.t
@@ -37,21 +37,21 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /short {
-            resolver    127.0.0.1:%%PORT_1_UDP%%;
+            resolver    127.0.0.1:%%PORT_8081_UDP%%;
             resolver_timeout 2s;
 
-            proxy_pass  http://$host:%%PORT_0%%/t;
+            proxy_pass  http://$host:%%PORT_8080%%/t;
         }
 
         location /long {
-            resolver    127.0.0.1:%%PORT_1_UDP%%;
+            resolver    127.0.0.1:%%PORT_8081_UDP%%;
             resolver_timeout 5s;
 
-            proxy_pass  http://$host:%%PORT_0%%/t;
+            proxy_pass  http://$host:%%PORT_8080%%/t;
         }
 
         location / { }
@@ -60,12 +60,12 @@ http {
 
 EOF
 
-$t->run_daemon(\&dns_daemon, port(1), $t);
+$t->run_daemon(\&dns_daemon, port(8081), $t);
 
 $t->write_file('t', '');
 $t->run();
 
-$t->waitforfile($t->testdir . '/' . port(1));
+$t->waitforfile($t->testdir . '/' . port(8081));
 
 ###############################################################################
 
--- a/http_server_name.t
+++ b/http_server_name.t
@@ -43,7 +43,7 @@ http {
     server_names_hash_bucket_size 64;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -52,7 +52,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  "";
 
         location / {
@@ -61,7 +61,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  www.example.com;
 
         location / {
@@ -70,7 +70,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  ~^EXAMPLE\.COM$;
 
         location / {
@@ -79,7 +79,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  ~^(?P<name>.+)\Q.example.com\E$;
 
         location / {
@@ -89,7 +89,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  "~^(?P<name>www\p{N}+)\.example\.com$";
 
         location / {
@@ -99,7 +99,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  many.example.com many2.example.com;
 
         location / {
@@ -108,7 +108,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  many3.example.com;
         server_name  many4.example.com;
 
@@ -118,7 +118,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  *.wc.example.com;
 
         location / {
@@ -127,7 +127,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  *.pref.wc.example.com;
 
         location / {
@@ -136,7 +136,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  wc2.example.*;
 
         location / {
@@ -145,7 +145,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  wc2.example.com.*;
 
         location / {
@@ -154,7 +154,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  .dot.example.com;
 
         location / {
--- a/http_try_files.t
+++ b/http_try_files.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -79,15 +79,15 @@ http {
         }
 
         location /fallback {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/fallback;
+            proxy_pass http://127.0.0.1:8081/fallback;
         }
         location /fallback-nouri {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/http_variables.t
+++ b/http_variables.t
@@ -39,7 +39,7 @@ http {
     log_format cc "$uri: $sent_http_cache_control";
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         access_log %%TESTDIR%%/cc.log cc;
@@ -57,7 +57,7 @@ http {
 
         location /redefine {
             expires epoch;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/set;
+            proxy_pass http://127.0.0.1:8080/set;
         }
     }
 }
--- a/image_filter.t
+++ b/image_filter.t
@@ -50,7 +50,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /size {
@@ -154,7 +154,7 @@ http {
         location /proxy_buffer {
             image_filter rotate 90;
             image_filter_buffer 20;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_buffering off;
             proxy_buffer_size 512;
         }
@@ -177,7 +177,7 @@ my $black = $im->colorAllocate(0, 0, 0);
 $t->write_file('txt', 'SEE-THIS');
 
 $t->run_daemon(\&http_daemon, $t);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -303,7 +303,7 @@ sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
 		LocalHost => '127.0.0.1',
-		LocalPort => port(1),
+		LocalPort => port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/image_filter_finalize.t
+++ b/image_filter_finalize.t
@@ -43,22 +43,22 @@ http {
     access_log time.log time;
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_0%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8080;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         # this used to cause a segmentation fault before 07f028df3879 (1.3.1)
         # http://nginx.org/pipermail/nginx/2011-January/024703.html
 
         location /t1 {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/bad;
+            proxy_pass http://127.0.0.1:8080/bad;
             proxy_cache cache;
             proxy_cache_valid any 1h;
 
@@ -78,7 +78,7 @@ http {
         # fixed in 07f028df3879 (1.3.1)
 
         location /t2 {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/big;
+            proxy_pass http://127.0.0.1:8080/big;
             proxy_store on;
 
             image_filter_buffer 10m;
@@ -111,7 +111,7 @@ http {
         }
 
         location /upstream {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/empty;
+            proxy_pass http://127.0.0.1:8080/empty;
         }
 
         location /time.log {
@@ -120,7 +120,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
         return 444;
     }
--- a/index.t
+++ b/index.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         add_header   X-URI $uri;
 
--- a/js.t
+++ b/js.t
@@ -58,7 +58,7 @@ http {
                           s;";
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /req_method {
--- a/limit_conn.t
+++ b/limit_conn.t
@@ -42,7 +42,7 @@ http {
     limit_conn_zone  $binary_remote_addr  zone=custom:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location /w {
@@ -51,11 +51,11 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             limit_conn zone 1;
         }
 
@@ -72,7 +72,7 @@ http {
         }
 
         location /custom {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             limit_conn_log_level info;
             limit_conn_status 501;
             limit_conn custom 1;
--- a/limit_conn_complex.t
+++ b/limit_conn_complex.t
@@ -44,7 +44,7 @@ http {
     limit_conn_zone  $binary_remote_addr$arg_c  zone=conn:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -53,7 +53,7 @@ http {
 
         location /w {
             limit_conn conn 1;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/req2;
+            proxy_pass http://127.0.0.1:8080/req2;
         }
 
         location /req {
--- a/limit_req.t
+++ b/limit_req.t
@@ -40,7 +40,7 @@ http {
     limit_req_zone  $binary_remote_addr  zone=fast:1m  rate=1000r/s;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             limit_req    zone=one  burst=1  nodelay;
--- a/map.t
+++ b/map.t
@@ -64,7 +64,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/map_complex.t
+++ b/map_complex.t
@@ -48,7 +48,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/memcached.t
+++ b/memcached.t
@@ -39,18 +39,18 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
             set $memcached_key $uri;
-            memcached_pass 127.0.0.1:%%PORT_1%%;
+            memcached_pass 127.0.0.1:8081;
         }
 
         location /next {
             set $memcached_key $uri;
             memcached_next_upstream  not_found;
-            memcached_pass 127.0.0.1:%%PORT_1%%;
+            memcached_pass 127.0.0.1:8081;
         }
     }
 }
@@ -62,22 +62,22 @@ my @memopts = ();
 
 if ($memhelp =~ /repcached/) {
 	# repcached patch adds additional listen socket
-	push @memopts, '-X', port(2);
+	push @memopts, '-X', port(8082);
 }
 if ($memhelp =~ /-U/) {
 	# UDP port is on by default in memcached 1.2.7+
 	push @memopts, '-U', '0';
 }
 
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(1), @memopts);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8081), @memopts);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start memcached";
 
 ###############################################################################
 
-my $memd = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(1) ],
+my $memd = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8081) ],
 	connect_timeout => 1.0);
 $memd->set('/', 'SEE-THIS')
 	or die "can't put value into memcached: $!";
--- a/memcached_fake.t
+++ b/memcached_fake.t
@@ -36,12 +36,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
             set $memcached_key $uri;
-            memcached_pass 127.0.0.1:%%PORT_1%%;
+            memcached_pass 127.0.0.1:8081;
         }
 
         location /ssi {
@@ -57,7 +57,7 @@ EOF
 $t->run_daemon(\&memcached_fake_daemon);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start fake memcached";
 
 ###############################################################################
@@ -73,7 +73,7 @@ like(`grep -F '[error]' ${\($t->testdir(
 sub memcached_fake_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/memcached_keepalive.t
+++ b/memcached_keepalive.t
@@ -39,24 +39,24 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream memd {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
         keepalive 1;
     }
 
     upstream memd3 {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
         keepalive 1;
     }
 
     upstream memd4 {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
         keepalive 10;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -92,8 +92,8 @@ if ($memhelp =~ /repcached/) {
 	# repcached patches adds additional listen socket memcached
 	# that should be different too
 
-	push @memopts1, '-X', port(3);
-	push @memopts2, '-X', port(4);
+	push @memopts1, '-X', port(8083);
+	push @memopts2, '-X', port(8084);
 }
 if ($memhelp =~ /-U/) {
 	# UDP ports no longer off by default in memcached 1.2.7+
@@ -108,21 +108,21 @@ if ($memhelp =~ /-t/) {
 	push @memopts2, '-t', '1';
 }
 
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(1), @memopts1);
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(2), @memopts2);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8081), @memopts1);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8082), @memopts2);
 
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Unable to start memcached";
-$t->waitforsocket('127.0.0.1:' . port(2))
+$t->waitforsocket('127.0.0.1:' . port(8082))
 	or die "Unable to start second memcached";
 
 ###############################################################################
 
-my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(1) ],
+my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8081) ],
 	connect_timeout => 1.0);
-my $memd2 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(2) ],
+my $memd2 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8082) ],
 	connect_timeout => 1.0);
 
 $memd1->set('/', 'SEE-THIS');
--- a/memcached_keepalive_stale.t
+++ b/memcached_keepalive_stale.t
@@ -41,12 +41,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream memd {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
         keepalive 1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%% sndbuf=32k;
+        listen       127.0.0.1:8080 sndbuf=32k;
         server_name  localhost;
 
         location / {
@@ -65,7 +65,7 @@ if ($memhelp =~ /repcached/) {
 	# repcached patches adds additional listen socket memcached
 	# that should be different too
 
-	push @memopts1, '-X', port(2);
+	push @memopts1, '-X', port(8082);
 }
 if ($memhelp =~ /-U/) {
 	# UDP ports no longer off by default in memcached 1.2.7+
@@ -78,16 +78,16 @@ if ($memhelp =~ /-t/) {
 	push @memopts1, '-t', '1';
 }
 
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(1), @memopts1);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8081), @memopts1);
 
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Unable to start memcached";
 
 ###############################################################################
 
-my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(1) ],
+my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8081) ],
 	connect_timeout => 1.0);
 
 # It's possible that stale events occur, i.e. read event handler called
--- a/mp4.t
+++ b/mp4.t
@@ -40,7 +40,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/not_modified.t
+++ b/not_modified.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/not_modified_proxy.t
+++ b/not_modified_proxy.t
@@ -47,7 +47,7 @@ http {
     proxy_set_header If-None-Match "";
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -58,11 +58,11 @@ http {
         }
 
         location /proxy/ {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
         }
 
         location /cache/ {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
             proxy_cache one;
             proxy_cache_valid 200 1y;
         }
--- a/perl.t
+++ b/perl.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/perl_gzip.t
+++ b/perl_gzip.t
@@ -38,7 +38,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         gzip on;
--- a/post_action.t
+++ b/post_action.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -53,7 +53,7 @@ http {
         }
 
         location /post.remote {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/post.html;
+            proxy_pass http://127.0.0.1:8080/post.html;
         }
     }
 }
--- a/proxy.t
+++ b/proxy.t
@@ -38,15 +38,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             proxy_read_timeout 1s;
             proxy_connect_timeout 2s;
         }
@@ -61,7 +61,7 @@ http {
 EOF
 
 $t->run_daemon(\&http_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -70,7 +70,7 @@ like(http_get('/multi'), qr/AND-THIS/, '
 
 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request');
 
-like(http_get('/var?b=127.0.0.1:' . port(1) . '/'), qr/SEE-THIS/,
+like(http_get('/var?b=127.0.0.1:' . port(8081) . '/'), qr/SEE-THIS/,
 	'proxy with variables');
 like(http_get('/var?b=u/'), qr/SEE-THIS/, 'proxy with variables to upstream');
 
@@ -99,7 +99,7 @@ like(http_get('/', socket => $s), qr/200
 sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_bind.t
+++ b/proxy_bind.t
@@ -40,39 +40,39 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen          127.0.0.1:%%PORT_0%%;
+        listen          127.0.0.1:8080;
         server_name     localhost;
 
         proxy_bind      127.0.0.2;
 
         location / {
             proxy_bind  127.0.0.1;
-            proxy_pass  http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass  http://127.0.0.1:8081/;
         }
 
         location /inherit {
-            proxy_pass  http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass  http://127.0.0.1:8081/;
         }
 
         location /off {
             proxy_bind  off;
-            proxy_pass  http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass  http://127.0.0.1:8081/;
         }
 
         location /var {
             proxy_bind  $arg_b;
-            proxy_pass  http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass  http://127.0.0.1:8081/;
         }
 
         location /port {
             proxy_bind  127.0.0.2:$remote_port;
-            proxy_pass  http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass  http://127.0.0.1:8081/;
             add_header  X-Client-Port $remote_port;
         }
     }
 
     server {
-        listen          127.0.0.1:%%PORT_1%%;
+        listen          127.0.0.1:8081;
         server_name     localhost;
 
         location / {
--- a/proxy_bind_transparent.t
+++ b/proxy_bind_transparent.t
@@ -42,17 +42,17 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen          127.0.0.1:%%PORT_0%%;
+        listen          127.0.0.1:8080;
         server_name     localhost;
 
         location / {
             proxy_bind  127.0.0.2 transparent;
-            proxy_pass  http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass  http://127.0.0.1:8081/;
         }
     }
 
     server {
-        listen          127.0.0.1:%%PORT_1%%;
+        listen          127.0.0.1:8081;
         server_name     localhost;
 
         location / {
--- a/proxy_cache.t
+++ b/proxy_cache.t
@@ -38,14 +38,14 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         gzip on;
         gzip_min_length 0;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
 
             proxy_cache   NAME;
 
@@ -64,7 +64,7 @@ http {
         }
     }
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_cache_bypass.t
+++ b/proxy_cache_bypass.t
@@ -37,11 +37,11 @@ http {
     proxy_cache_path %%TESTDIR%%/cache keys_zone=one:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
 
             proxy_cache one;
             proxy_cache_key $uri;
@@ -60,7 +60,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_cache_chunked.t
+++ b/proxy_cache_chunked.t
@@ -40,11 +40,11 @@ http {
     proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             proxy_http_version 1.1;
             proxy_cache NAME;
             proxy_cache_valid any 1m;
@@ -56,7 +56,7 @@ http {
 EOF
 
 $t->run_daemon(\&http_chunked_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -68,7 +68,7 @@ like(http_get("/"), qr/SEE-THIS.*HIT/s, 
 sub http_chunked_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_cache_convert_head.t
+++ b/proxy_cache_convert_head.t
@@ -39,7 +39,7 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_cache   NAME;
@@ -51,22 +51,22 @@ http {
         add_header X-Cache-Status $upstream_cache_status;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/t.html;
+            proxy_pass http://127.0.0.1:8081/t.html;
             proxy_cache_convert_head   off;
 
             location /inner {
-                proxy_pass http://127.0.0.1:%%PORT_1%%/t.html;
+                proxy_pass http://127.0.0.1:8081/t.html;
                 proxy_cache_convert_head on;
             }
         }
 
         location /on {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/t.html;
+            proxy_pass http://127.0.0.1:8081/t.html;
             proxy_cache_convert_head on;
         }
     }
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_cache_lock.t
+++ b/proxy_cache_lock.t
@@ -38,18 +38,18 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   NAME;
 
             proxy_cache_lock on;
         }
 
         location /timeout {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   NAME;
 
             proxy_cache_lock on;
@@ -57,7 +57,7 @@ http {
         }
 
         location /nolock {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   NAME;
         }
     }
@@ -69,7 +69,7 @@ EOF
 
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
+$t->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -126,7 +126,7 @@ like(http_get('/nolock'), qr/request 3/,
 sub http_fake_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_cache_lock_age.t
+++ b/proxy_cache_lock_age.t
@@ -41,11 +41,11 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   NAME;
 
             proxy_cache_lock on;
@@ -56,8 +56,8 @@ http {
 
 EOF
 
-$t->run_daemon(\&http_daemon, port(1));
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run_daemon(\&http_daemon, port(8081));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
--- a/proxy_cache_lock_ssi.t
+++ b/proxy_cache_lock_ssi.t
@@ -40,11 +40,11 @@ http {
     limit_req_zone $binary_remote_addr zone=one:1m rate=1r/m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   NAME;
 
             proxy_cache_lock on;
@@ -61,7 +61,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
         limit_req zone=one burst=5;
     }
--- a/proxy_cache_path.t
+++ b/proxy_cache_path.t
@@ -43,11 +43,11 @@ http {
                        keys_zone=LEVELS:1m  use_temp_path=off;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
 
             proxy_cache   $arg_c;
 
@@ -58,7 +58,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_cache_range.t
+++ b/proxy_cache_range.t
@@ -38,16 +38,16 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   NAME;
             proxy_cache_valid 200 1m;
         }
         location /min_uses {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass    http://127.0.0.1:8081/;
             proxy_cache   NAME;
             proxy_cache_valid 200 1m;
             proxy_cache_min_uses 2;
@@ -55,7 +55,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_cache_revalidate.t
+++ b/proxy_cache_revalidate.t
@@ -40,11 +40,11 @@ http {
     proxy_cache_revalidate on;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   one;
 
             proxy_cache_valid  200 404  2s;
@@ -54,12 +54,12 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / { }
         location /etag/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_hide_header Last-Modified;
         }
         location /201 {
--- a/proxy_cache_variables.t
+++ b/proxy_cache_variables.t
@@ -41,11 +41,11 @@ http {
                        keys_zone=NAME2:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
 
             proxy_cache   $arg_c;
 
@@ -56,7 +56,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_cache_vary.t
+++ b/proxy_cache_vary.t
@@ -38,36 +38,36 @@ http {
     proxy_cache_key    $uri;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header X-Cache-Status $upstream_cache_status;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass    http://127.0.0.1:8081/;
             proxy_cache   one;
         }
 
         location /replace/ {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass    http://127.0.0.1:8081/;
             proxy_cache   one;
         }
 
         location /revalidate/ {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass    http://127.0.0.1:8081/;
             proxy_cache   one;
             proxy_cache_revalidate on;
         }
 
         location /ignore/ {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass    http://127.0.0.1:8081/;
             proxy_cache   one;
             proxy_ignore_headers Vary;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         gzip on;
--- a/proxy_chunked.t
+++ b/proxy_chunked.t
@@ -40,15 +40,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             proxy_read_timeout 1s;
         }
         location /nobuffering {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             proxy_read_timeout 1s;
             proxy_buffering off;
         }
@@ -64,7 +64,7 @@ EOF
 	'<!--#include virtual="/" set="one" --><!--#echo var="one" -->');
 
 $t->run_daemon(\&http_chunked_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -77,7 +77,7 @@ like(http_get('/inmemory.html'), qr/\x0d
 sub http_chunked_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_cookie.t
+++ b/proxy_cookie.t
@@ -37,11 +37,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
 
             proxy_cookie_domain www.example.org .example.com;
             proxy_cookie_domain .$server_name.com en.$server_name.org;
@@ -55,7 +55,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
@@ -77,7 +77,7 @@ EOF
 
 ###############################################################################
 
-my $port = port(0);
+my $port = port(8080);
 
 is(http_get_set_cookie('/?domain=www.Example.org'),
 	'v=path=domain=; Domain=example.com', 'domain rewrite');
--- a/proxy_force_ranges.t
+++ b/proxy_force_ranges.t
@@ -40,15 +40,15 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
         }
 
         location /cache/ {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass    http://127.0.0.1:8081/;
             proxy_cache   NAME;
             proxy_cache_valid 200 1m;
 
@@ -57,7 +57,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_if.t
+++ b/proxy_if.t
@@ -38,18 +38,18 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
         }
 
         # request was sent to backend without uri changed
         # to '/' due to if
 
         location /proxy-pass-uri {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/replacement;
+            proxy_pass http://127.0.0.1:8081/replacement;
 
             if ($arg_if) {
                 # nothing
@@ -69,7 +69,7 @@ http {
         # nested locations though
 
         location /proxy-pass-uri-lmt {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/replacement;
+            proxy_pass http://127.0.0.1:8081/replacement;
 
             limit_except POST {
                 # nothing
@@ -85,10 +85,10 @@ http {
         }
 
         location /proxy-pass-uri-lmt-different {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/replacement;
+            proxy_pass http://127.0.0.1:8081/replacement;
 
             limit_except POST {
-                proxy_pass http://127.0.0.1:%%PORT_1%%;
+                proxy_pass http://127.0.0.1:8081;
             }
         }
 
@@ -101,7 +101,7 @@ http {
 
             if ($true) {
                 # proxy_pass inside if
-                proxy_pass http://127.0.0.1:%%PORT_1%%;
+                proxy_pass http://127.0.0.1:8081;
             }
 
             if ($true) {
@@ -114,14 +114,14 @@ http {
         # exclusive
 
         location /variables {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/outer/$host;
+            proxy_pass http://127.0.0.1:8081/outer/$host;
 
             if ($arg_if) {
-                proxy_pass http://127.0.0.1:%%PORT_1%%;
+                proxy_pass http://127.0.0.1:8081;
             }
 
             location /variables/inner {
-                proxy_pass http://127.0.0.1:%%PORT_1%%;
+                proxy_pass http://127.0.0.1:8081;
             }
         }
 
@@ -130,21 +130,21 @@ http {
         # be correctly inherited into if's
 
         location /ssl {
-            proxy_pass https://127.0.0.1:%%PORT_2%%/outer;
+            proxy_pass https://127.0.0.1:8082/outer;
 
             if ($arg_if) {
                 # inherited from outer
             }
 
             location /ssl/inner {
-                proxy_pass http://127.0.0.1:%%PORT_1%%;
+                proxy_pass http://127.0.0.1:8081;
             }
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
-        listen       127.0.0.1:%%PORT_2%% ssl;
+        listen       127.0.0.1:8081;
+        listen       127.0.0.1:8082 ssl;
         server_name  localhost;
 
         ssl_certificate localhost.crt;
--- a/proxy_keepalive.t
+++ b/proxy_keepalive.t
@@ -38,12 +38,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream backend {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
         keepalive 1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_http_version 1.1;
@@ -74,7 +74,7 @@ EOF
 $t->run_daemon(\&http_daemon);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start test backend";
 
 ###############################################################################
@@ -215,7 +215,7 @@ like(`grep -F '[error]' ${\($t->testdir(
 sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_limit_rate.t
+++ b/proxy_limit_rate.t
@@ -37,11 +37,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/data;
+            proxy_pass http://127.0.0.1:8080/data;
             proxy_limit_rate 12000;
             add_header X-Msec $msec;
         }
--- a/proxy_merge_headers.t
+++ b/proxy_merge_headers.t
@@ -41,33 +41,33 @@ http {
     proxy_hide_header X-Hidden;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_cache  NAME;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
 
             location /nested/ {
-                proxy_pass   http://127.0.0.1:%%PORT_1%%;
+                proxy_pass   http://127.0.0.1:8081;
                 proxy_pass_header X-Pad;
             }
         }
 
         location /no/ {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   off;
         }
 
         location /setbody/ {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_set_body "body";
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_next_upstream.t
+++ b/proxy_next_upstream.t
@@ -36,17 +36,17 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
     }
 
     upstream u2 {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -67,7 +67,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
@@ -86,7 +86,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%%;
+        listen       127.0.0.1:8082;
         server_name  localhost;
 
         location / {
@@ -105,7 +105,7 @@ EOF
 
 ###############################################################################
 
-my ($p1, $p2) = (port(1), port(2));
+my ($p1, $p2) = (port(8081), port(8082));
 
 # check if both request fallback to a backend
 # which returns valid response
--- a/proxy_next_upstream_tries.t
+++ b/proxy_next_upstream_tries.t
@@ -38,19 +38,19 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8081;
     }
 
     upstream u2 {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_1%% backup;
-        server 127.0.0.1:%%PORT_1%% backup;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8081 backup;
+        server 127.0.0.1:8081 backup;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_next_upstream http_404;
@@ -68,9 +68,9 @@ http {
         }
 
         location /tries/resolver {
-            resolver 127.0.0.1:%%PORT_2_UDP%%;
+            resolver 127.0.0.1:%%PORT_8082_UDP%%;
 
-            proxy_pass http://$host:%%PORT_1%%;
+            proxy_pass http://$host:%%PORT_8081%%;
             proxy_next_upstream_tries 2;
         }
 
@@ -90,9 +90,9 @@ http {
         }
 
         location /timeout/resolver {
-            resolver 127.0.0.1:%%PORT_2_UDP%%;
+            resolver 127.0.0.1:%%PORT_8082_UDP%%;
 
-            proxy_pass http://$host:%%PORT_1%%/w2;
+            proxy_pass http://$host:%%PORT_8081%%/w2;
             proxy_next_upstream_timeout 3800ms;
         }
 
@@ -109,12 +109,12 @@ http {
 
 EOF
 
-$t->run_daemon(\&http_daemon, port(1));
-$t->run_daemon(\&dns_daemon, port(2), $t);
+$t->run_daemon(\&http_daemon, port(8081));
+$t->run_daemon(\&dns_daemon, port(8082), $t);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
-$t->waitforfile($t->testdir . '/' . port(2));
+$t->waitforsocket('127.0.0.1:' . port(8081));
+$t->waitforfile($t->testdir . '/' . port(8082));
 
 ###############################################################################
 
--- a/proxy_noclose.t
+++ b/proxy_noclose.t
@@ -47,16 +47,16 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             proxy_read_timeout 2s;
         }
 
         location /uselen {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
 
             # test will wait only 2s for reply, we it will fail if
             # Content-Length not used as a hint
@@ -69,7 +69,7 @@ http {
 EOF
 
 $t->run_daemon(\&http_noclose_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -90,7 +90,7 @@ like(http_get('/nolen'), qr/SEE-THIS/, '
 sub http_noclose_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_non_idempotent.t
+++ b/proxy_non_idempotent.t
@@ -37,18 +37,18 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%% max_fails=0;
-        server 127.0.0.1:%%PORT_1%% max_fails=0;
+        server 127.0.0.1:8081 max_fails=0;
+        server 127.0.0.1:8081 max_fails=0;
     }
 
     upstream uk {
-        server 127.0.0.1:%%PORT_1%% max_fails=0;
-        server 127.0.0.1:%%PORT_1%% max_fails=0;
+        server 127.0.0.1:8081 max_fails=0;
+        server 127.0.0.1:8081 max_fails=0;
         keepalive 10;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header X-IP $upstream_addr always;
@@ -72,7 +72,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_pass_request.t
+++ b/proxy_pass_request.t
@@ -37,23 +37,23 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_pass_request_headers off;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
 
         location /body {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             proxy_pass_request_headers on;
             proxy_pass_request_body off;
         }
 
         location /both {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             proxy_pass_request_headers off;
             proxy_pass_request_body off;
         }
@@ -63,7 +63,7 @@ http {
 EOF
 
 $t->run_daemon(\&http_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -90,7 +90,7 @@ EOF
 sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_protocol.t
+++ b/proxy_protocol.t
@@ -41,7 +41,7 @@ http {
     log_format pp '$remote_addr $request';
 
     server {
-        listen       127.0.0.1:%%PORT_0%% proxy_protocol;
+        listen       127.0.0.1:8080 proxy_protocol;
         server_name  localhost;
 
         set_real_ip_from  127.0.0.1/32;
--- a/proxy_protocol_ipv6.t
+++ b/proxy_protocol_ipv6.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       [::1]:%%PORT_0%% proxy_protocol;
+        listen       [::1]:%%PORT_8080%% proxy_protocol;
         server_name  localhost;
 
         add_header X-IP $remote_addr;
@@ -54,8 +54,8 @@ http {
 
 stream {
     server {
-        listen      127.0.0.1:%%PORT_0%%;
-        proxy_pass  [::1]:%%PORT_0%%;
+        listen      127.0.0.1:8080;
+        proxy_pass  [::1]:%%PORT_8080%%;
 
         proxy_protocol on;
     }
--- a/proxy_protocol_port.t
+++ b/proxy_protocol_port.t
@@ -40,7 +40,7 @@ http {
     log_format port $proxy_protocol_port;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% proxy_protocol;
+        listen       127.0.0.1:8080 proxy_protocol;
         server_name  localhost;
 
         add_header X-PP-Port $proxy_protocol_port;
--- a/proxy_redirect.t
+++ b/proxy_redirect.t
@@ -37,54 +37,54 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
             set $some_var var_here;
 
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
 
-            proxy_redirect http://127.0.0.1:%%PORT_1%%/var_in_second/
+            proxy_redirect http://127.0.0.1:8081/var_in_second/
                            /$some_var/;
-            proxy_redirect http://127.0.0.1:%%PORT_1%%/$some_var/ /replaced/;
+            proxy_redirect http://127.0.0.1:8081/$some_var/ /replaced/;
 
             proxy_redirect ~^(.+)/regex_w_([^/]+) $1/$2/test.html;
             proxy_redirect ~*re+gexp? /replaced/test.html;
         }
 
         location /expl_default/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/replace_this/;
+            proxy_pass http://127.0.0.1:8081/replace_this/;
             proxy_redirect wrong wrong;
             proxy_redirect default;
         }
 
         location /impl_default/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/replace_this/;
+            proxy_pass http://127.0.0.1:8081/replace_this/;
         }
 
         location /off/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_redirect off;
 
             location /off/on/ {
-                proxy_pass http://127.0.0.1:%%PORT_1%%;
-                proxy_redirect http://127.0.0.1:%%PORT_1%%/off/ /;
+                proxy_pass http://127.0.0.1:8081;
+                proxy_redirect http://127.0.0.1:8081/off/ /;
 
                 location /off/on/on/ {
-                    proxy_pass http://127.0.0.1:%%PORT_1%%;
+                    proxy_pass http://127.0.0.1:8081;
                 }
             }
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
-            add_header Refresh "7; url=http://127.0.0.1:%%PORT_1%%$uri";
-            return http://127.0.0.1:%%PORT_1%%$uri;
+            add_header Refresh "7; url=http://127.0.0.1:8081$uri";
+            return http://127.0.0.1:8081$uri;
         }
     }
 }
@@ -95,7 +95,7 @@ EOF
 
 ###############################################################################
 
-my ($p0, $p1) = (port(0), port(1));
+my ($p0, $p1) = (port(8080), port(8081));
 
 is(http_get_location("http://127.0.0.1:$p0/impl_default/test.html"),
 	"http://127.0.0.1:$p0/impl_default/test.html", 'implicit default');
--- a/proxy_request_buffering.t
+++ b/proxy_request_buffering.t
@@ -39,7 +39,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
@@ -48,25 +48,25 @@ http {
         location / {
             client_body_buffer_size 2k;
             add_header X-Body "$request_body";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /small {
             client_body_in_file_only on;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
         }
         location /single {
             client_body_in_single_buffer on;
             add_header X-Body "$request_body";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /discard {
             return 200 "TEST\n";
         }
         location /preread {
-            proxy_pass http://127.0.0.1:%%PORT_2%%/;
+            proxy_pass http://127.0.0.1:8082/;
         }
         location /error_page {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/404;
+            proxy_pass http://127.0.0.1:8081/404;
             error_page 404 /404;
             proxy_intercept_errors on;
         }
@@ -76,11 +76,11 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/discard;
+            proxy_pass http://127.0.0.1:8080/discard;
         }
         location /404 { }
     }
@@ -127,7 +127,7 @@ like(http_get_body('/small', '0123456789
 
 # interactive tests
 
-my $s = get_body('/preread', port(2), 10);
+my $s = get_body('/preread', port(8082), 10);
 ok($s, 'no preread');
 
 SKIP: {
@@ -140,7 +140,7 @@ like($s->{http_end}(), qr/200 OK/, 'no p
 
 }
 
-$s = get_body('/preread', port(2), 10, '01234');
+$s = get_body('/preread', port(8082), 10, '01234');
 ok($s, 'preread');
 
 SKIP: {
--- a/proxy_request_buffering_chunked.t
+++ b/proxy_request_buffering_chunked.t
@@ -39,7 +39,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
@@ -49,25 +49,25 @@ http {
         location / {
             client_body_buffer_size 2k;
             add_header X-Body "$request_body";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /small {
             client_body_in_file_only on;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
         }
         location /single {
             client_body_in_single_buffer on;
             add_header X-Body "$request_body";
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
         location /discard {
             return 200 "TEST\n";
         }
         location /preread {
-            proxy_pass http://127.0.0.1:%%PORT_2%%/;
+            proxy_pass http://127.0.0.1:8082/;
         }
         location /error_page {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/404;
+            proxy_pass http://127.0.0.1:8081/404;
             error_page 404 /404;
             proxy_intercept_errors on;
         }
@@ -77,11 +77,11 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/discard;
+            proxy_pass http://127.0.0.1:8080/discard;
         }
         location /404 { }
     }
@@ -128,7 +128,7 @@ like(http_get_body('/small', '0123456789
 
 # interactive tests
 
-my $s = get_body('/preread', port(2));
+my $s = get_body('/preread', port(8082));
 ok($s, 'no preread');
 
 SKIP: {
@@ -144,7 +144,7 @@ like($s->{http_end}(), qr/200 OK/, 'no p
 
 }
 
-$s = get_body('/preread', port(2), '01234');
+$s = get_body('/preread', port(8082), '01234');
 ok($s, 'preread');
 
 SKIP: {
@@ -158,7 +158,7 @@ like($s->{http_end}(), qr/200 OK/, 'prer
 
 }
 
-$s = get_body('/preread', port(2), '01234', many => 1);
+$s = get_body('/preread', port(8082), '01234', many => 1);
 ok($s, 'chunks');
 
 SKIP: {
--- a/proxy_request_buffering_keepalive.t
+++ b/proxy_request_buffering_keepalive.t
@@ -37,12 +37,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream backend {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
         keepalive 1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_http_version 1.1;
@@ -56,7 +56,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / { }
--- a/proxy_request_buffering_ssl.t
+++ b/proxy_request_buffering_ssl.t
@@ -40,7 +40,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         client_header_buffer_size 1k;
@@ -49,21 +49,21 @@ http {
         location / {
             client_body_buffer_size 2k;
             add_header X-Body "$request_body";
-            proxy_pass https://127.0.0.1:%%PORT_1%%;
+            proxy_pass https://127.0.0.1:8081;
         }
         location /single {
             client_body_in_single_buffer on;
             add_header X-Body "$request_body";
-            proxy_pass https://127.0.0.1:%%PORT_1%%;
+            proxy_pass https://127.0.0.1:8081;
         }
         location /discard {
             return 200 "TEST\n";
         }
         location /preread {
-            proxy_pass https://127.0.0.1:%%PORT_1%%;
+            proxy_pass https://127.0.0.1:8081;
         }
         location /error_page {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/404;
+            proxy_pass https://127.0.0.1:8081/404;
             error_page 404 /404;
             proxy_intercept_errors on;
         }
@@ -73,7 +73,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
+        listen       127.0.0.1:8081 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
@@ -82,12 +82,12 @@ http {
         location /preread {
             client_body_buffer_size 2k;
             add_header X-Body "$request_body";
-            proxy_pass http://127.0.0.1:%%PORT_2%%/;
+            proxy_pass http://127.0.0.1:8082/;
             proxy_request_buffering off;
         }
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/discard;
+            proxy_pass http://127.0.0.1:8080/discard;
         }
         location /404 { }
     }
@@ -147,7 +147,7 @@ like(http_get_body('/discard', '01234567
 
 # interactive tests
 
-my $s = get_body('/preread', port(2), 10);
+my $s = get_body('/preread', port(8082), 10);
 ok($s, 'no preread');
 
 SKIP: {
@@ -160,7 +160,7 @@ like($s->{http_end}(), qr/200 OK/, 'no p
 
 }
 
-$s = get_body('/preread', port(2), 15, '01234');
+$s = get_body('/preread', port(8082), 15, '01234');
 ok($s, 'preread');
 
 SKIP: {
--- a/proxy_set_body.t
+++ b/proxy_set_body.t
@@ -35,21 +35,21 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/body;
+            proxy_pass http://127.0.0.1:8080/body;
             proxy_set_body "body";
         }
 
         location /p1 {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/x1;
+            proxy_pass http://127.0.0.1:8080/x1;
             proxy_set_body "body";
         }
 
         location /p2 {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/body;
+            proxy_pass http://127.0.0.1:8080/body;
             proxy_set_body "body two";
         }
 
@@ -60,7 +60,7 @@ http {
 
         location /body {
             add_header X-Body $request_body;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/empty;
+            proxy_pass http://127.0.0.1:8080/empty;
         }
 
         location /empty {
--- a/proxy_ssi_body.t
+++ b/proxy_ssi_body.t
@@ -39,14 +39,14 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
         }
 
         location /proxy {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
             client_body_in_file_only on;
             ssi on;
         }
--- a/proxy_ssl.t
+++ b/proxy_ssl.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen 127.0.0.1:%%PORT_1%% ssl;
+        listen 127.0.0.1:8081 ssl;
 
         ssl_certificate_key localhost.key;
         ssl_certificate localhost.crt;
@@ -47,21 +47,21 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /ssl_reuse {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_session_reuse on;
         }
 
         location /ssl {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_session_reuse off;
         }
 
         location /timeout {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_connect_timeout 2s;
         }
     }
--- a/proxy_ssl_certificate.t
+++ b/proxy_ssl_certificate.t
@@ -39,25 +39,25 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_ssl_session_reuse off;
 
         location /verify {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_certificate 1.example.com.crt;
             proxy_ssl_certificate_key 1.example.com.key;
         }
 
         location /fail {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_certificate 2.example.com.crt;
             proxy_ssl_certificate_key 2.example.com.key;
         }
 
         location /encrypted {
-            proxy_pass https://127.0.0.1:%%PORT_2%%/;
+            proxy_pass https://127.0.0.1:8082/;
             proxy_ssl_certificate 3.example.com.crt;
             proxy_ssl_certificate_key 3.example.com.key;
             proxy_ssl_password_file password;
@@ -65,7 +65,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
+        listen       127.0.0.1:8081 ssl;
         server_name  localhost;
 
         ssl_certificate 2.example.com.crt;
@@ -81,7 +81,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%% ssl;
+        listen       127.0.0.1:8082 ssl;
         server_name  localhost;
 
         ssl_certificate 1.example.com.crt;
--- a/proxy_ssl_keepalive.t
+++ b/proxy_ssl_keepalive.t
@@ -40,12 +40,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
         keepalive 1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_http_version 1.1;
@@ -57,7 +57,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
+        listen       127.0.0.1:8081 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
--- a/proxy_ssl_name.t
+++ b/proxy_ssl_name.t
@@ -38,15 +38,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream backend {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     upstream backend2 {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         # session reuse is off, as sessions are cached
@@ -56,13 +56,13 @@ http {
         proxy_ssl_session_reuse off;
 
         location /1 {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_name 1.example.com;
             proxy_ssl_server_name on;
         }
 
         location /2 {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_name 2.example.com;
             proxy_ssl_server_name on;
 
@@ -90,19 +90,19 @@ http {
         }
 
         location /ip {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_server_name on;
         }
 
         #location /ip6 {
-        #    proxy_pass https://[::1]:%%PORT_1%%/;
+        #    proxy_pass https://[::1]:%%PORT_8081%%/;
         #    proxy_ssl_server_name on;
         #}
     }
 
     server {
-        listen 127.0.0.1:%%PORT_1%% ssl;
-        #listen [::1]:%%PORT_1%% ssl;
+        listen 127.0.0.1:8081 ssl;
+        #listen [::1]:%%PORT_8081%% ssl;
         server_name 1.example.com;
 
         ssl_certificate localhost.crt;
--- a/proxy_ssl_verify.t
+++ b/proxy_ssl_verify.t
@@ -37,46 +37,46 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /verify {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_name example.com;
             proxy_ssl_verify on;
             proxy_ssl_trusted_certificate 1.example.com.crt;
         }
 
         location /wildcard {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_name foo.example.com;
             proxy_ssl_verify on;
             proxy_ssl_trusted_certificate 1.example.com.crt;
         }
 
         location /fail {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
             proxy_ssl_name no.match.example.com;
             proxy_ssl_verify on;
             proxy_ssl_trusted_certificate 1.example.com.crt;
         }
 
         location /cn {
-            proxy_pass https://127.0.0.1:%%PORT_2%%/;
+            proxy_pass https://127.0.0.1:8082/;
             proxy_ssl_name 2.example.com;
             proxy_ssl_verify on;
             proxy_ssl_trusted_certificate 2.example.com.crt;
         }
 
         location /cn/fail {
-            proxy_pass https://127.0.0.1:%%PORT_2%%/;
+            proxy_pass https://127.0.0.1:8082/;
             proxy_ssl_name bad.example.com;
             proxy_ssl_verify on;
             proxy_ssl_trusted_certificate 2.example.com.crt;
         }
 
         location /untrusted {
-            proxy_pass https://127.0.0.1:%%PORT_2%%/;
+            proxy_pass https://127.0.0.1:8082/;
             proxy_ssl_verify on;
             proxy_ssl_trusted_certificate 1.example.com.crt;
             proxy_ssl_session_reuse off;
@@ -84,7 +84,7 @@ http {
     }
 
     server {
-        listen 127.0.0.1:%%PORT_1%% ssl;
+        listen 127.0.0.1:8081 ssl;
         server_name 1.example.com;
 
         ssl_certificate 1.example.com.crt;
@@ -94,7 +94,7 @@ http {
     }
 
     server {
-        listen 127.0.0.1:%%PORT_2%% ssl;
+        listen 127.0.0.1:8082 ssl;
         server_name 2.example.com;
 
         ssl_certificate 2.example.com.crt;
--- a/proxy_store.t
+++ b/proxy_store.t
@@ -36,15 +36,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /store- {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
             proxy_store on;
         }
         location /store-string- {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/;
+            proxy_pass http://127.0.0.1:8080/;
             proxy_store %%TESTDIR%%$uri;
         }
         location /ssi.html {
--- a/proxy_unfinished.t
+++ b/proxy_unfinished.t
@@ -49,24 +49,24 @@ http {
                        keys_zone=one:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% sndbuf=32k;
+        listen       127.0.0.1:8080 sndbuf=32k;
         server_name  localhost;
 
         location / {
             sub_filter foo bar;
             sub_filter_types *;
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
 
         location /un/ {
             sub_filter foo bar;
             sub_filter_types *;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_buffering off;
         }
 
         location /cache/ {
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_cache one;
             add_header X-Cache-Status $upstream_cache_status;
         }
@@ -74,7 +74,7 @@ http {
         location /proxy/ {
             sub_filter foo bar;
             sub_filter_types *;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/local/;
+            proxy_pass http://127.0.0.1:8080/local/;
             proxy_buffer_size 1k;
             proxy_buffers 4 1k;
         }
@@ -90,7 +90,7 @@ EOF
 $t->write_file('big.html', 'X' x (1024 * 1024) . 'finished');
 
 $t->run_daemon(\&http_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -163,7 +163,7 @@ sub http_get_11 {
 sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_unix.t
+++ b/proxy_unix.t
@@ -45,7 +45,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/proxy_upgrade.t
+++ b/proxy_upgrade.t
@@ -44,11 +44,11 @@ http {
     access_log %%TESTDIR%%/cc.log test;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "Upgrade";
@@ -65,7 +65,7 @@ my $d = $t->testdir();
 $t->run_daemon(\&upgrade_fake_daemon);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start test backend";
 
 ###############################################################################
@@ -147,7 +147,7 @@ sub upgrade_connect {
 
 	my $s = IO::Socket::INET->new(
 		Proto => 'tcp',
-		PeerAddr => '127.0.0.1:' . port(0),
+		PeerAddr => '127.0.0.1:' . port(8080),
 	)
 		or die "Can't connect to nginx: $!\n";
 
@@ -250,7 +250,7 @@ sub upgrade_read {
 sub upgrade_fake_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_upstream_cookie.t
+++ b/proxy_upstream_cookie.t
@@ -36,17 +36,17 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
             add_header X-Upstream-Cookie $upstream_cookie_tc;
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / {
--- a/proxy_variables.t
+++ b/proxy_variables.t
@@ -36,15 +36,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8081;
     }
 
     log_format time '$upstream_connect_time:$upstream_header_time:'
                     '$upstream_response_time';
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header X-Connect $upstream_connect_time;
@@ -52,7 +52,7 @@ http {
         add_header X-Response $upstream_response_time;
 
         location / {
-            proxy_pass http://127.0.0.1:%%PORT_1%%;
+            proxy_pass http://127.0.0.1:8081;
             access_log %%TESTDIR%%/time.log time;
         }
 
@@ -61,7 +61,7 @@ http {
         }
 
         location /vars {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/stub;
+            proxy_pass http://127.0.0.1:8080/stub;
 
             add_header X-Proxy-Host $proxy_host;
             add_header X-Proxy-Port $proxy_port;
@@ -75,15 +75,15 @@ http {
 EOF
 
 $t->write_file('stub', '');
-$t->run_daemon(\&http_daemon, port(1));
+$t->run_daemon(\&http_daemon, port(8081));
 $t->try_run('no upstream_connect_time')->plan(18);
 
-$t->waitforsocket('127.0.0.1:' . port(1));
+$t->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
 my $re = qr/(\d\.\d{3})/;
-my $p0 = port(0);
+my $p0 = port(8080);
 my ($ct, $ht, $rt, $ct2, $ht2, $rt2);
 
 like(http_get('/vars'), qr/X-Proxy-Host:\s127\.0\.0\.1:$p0/, 'proxy_host');
--- a/proxy_websocket.t
+++ b/proxy_websocket.t
@@ -47,11 +47,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "Upgrade";
@@ -66,7 +66,7 @@ EOF
 $t->run_daemon(\&websocket_fake_daemon);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start test backend";
 
 ###############################################################################
@@ -125,7 +125,7 @@ sub websocket_connect {
 
 	my $s = IO::Socket::INET->new(
 		Proto => 'tcp',
-		PeerAddr => '127.0.0.1:' . port(0)
+		PeerAddr => '127.0.0.1:' . port(8080)
 	)
 		or die "Can't connect to nginx: $!\n";
 
@@ -210,7 +210,7 @@ sub websocket_read {
 sub websocket_fake_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/proxy_xar.t
+++ b/proxy_xar.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         # catch safe and unhandled unsafe URIs,
@@ -47,7 +47,7 @@ http {
         }
 
         location /proxy {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/return-xar;
+            proxy_pass http://127.0.0.1:8080/return-xar;
         }
         location /return-xar {
             add_header  X-Accel-Redirect     $arg_xar;
--- a/random_index.t
+++ b/random_index.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/range.t
+++ b/range.t
@@ -40,7 +40,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /t2.html {
--- a/range_charset.t
+++ b/range_charset.t
@@ -43,18 +43,18 @@ http {
                        keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_cache   NAME;
             proxy_cache_valid 200 1m;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         charset B;
--- a/range_flv.t
+++ b/range_flv.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             flv;
--- a/range_if_range.t
+++ b/range_if_range.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /t2.html {
--- a/range_mp4.t
+++ b/range_mp4.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             mp4;
--- a/realip.t
+++ b/realip.t
@@ -40,7 +40,7 @@ http {
     set_real_ip_from  10.0.1.0/24;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / { }
--- a/realip_remote_addr.t
+++ b/realip_remote_addr.t
@@ -40,7 +40,7 @@ http {
     real_ip_header    X-Forwarded-For;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/realip_remote_port.t
+++ b/realip_remote_port.t
@@ -42,7 +42,7 @@ http {
     set_real_ip_from  ::1/128;
 
     server {
-        listen       [::1]:%%PORT_1%%;
+        listen       [::1]:%%PORT_8081%%;
         listen       unix:%%TESTDIR%%/unix.sock;
 
         location / {
@@ -51,7 +51,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -64,7 +64,7 @@ http {
         }
 
         location /inet6 {
-            proxy_pass http://[::1]:%%PORT_1%%/;
+            proxy_pass http://[::1]:%%PORT_8081%%/;
         }
 
         location /unix {
--- a/referer.t
+++ b/referer.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  another;
 
         valid_referers server_names;
@@ -44,7 +44,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  _;
 
         location / {
@@ -55,7 +55,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost ~bar ~^anchoredre$;
 
         location /blocked {
@@ -117,7 +117,7 @@ EOF
 
 ok(valid('/simple', 'http://www.example.org'), 'simple');
 ok(valid('/simple', 'http://www.example.org/uri'), 'simple uri');
-ok(valid('/simple', 'http://www.example.org:' . port(0) . '/uri'),
+ok(valid('/simple', 'http://www.example.org:' . port(8080) . '/uri'),
 	'simple port uri');
 ok(!valid('/simple', 'localhost'), 'simple invalid');
 ok(valid('/simple', 'https://www.example.org'), 'https');
@@ -144,7 +144,7 @@ ok(!valid('/long', 'http://' . 'a' x 257
 ok(valid('/uri', 'http://www.example.org/uri'), 'uri');
 ok(valid('/uri', 'http://www.example.org/urii'), 'uri prefix');
 ok(!valid('/uri', 'http://www.example.org/uRi'), 'uri case');
-ok(valid('/uri', 'http://www.example.org:' . port(0) . '/urii'), 'uri port');
+ok(valid('/uri', 'http://www.example.org:' . port(8080) . '/urii'), 'uri port');
 ok(!valid('/uri', 'http://www.example.org/ur'), 'uri invalid len');
 ok(!valid('/uri', 'http://www.example.org/urd'), 'uri invalid cmp');
 
--- a/request_id.t
+++ b/request_id.t
@@ -38,7 +38,7 @@ http {
     log_format id $request_id;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header X-Request-Id $request_id;
--- a/rewrite.t
+++ b/rewrite.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/rewrite_set.t
+++ b/rewrite_set.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         ssi on;
--- a/rewrite_unescape.t
+++ b/rewrite_unescape.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /t1 {
--- a/scgi.t
+++ b/scgi.t
@@ -38,15 +38,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            scgi_pass 127.0.0.1:%%PORT_1%%;
+            scgi_pass 127.0.0.1:8081;
             scgi_param SCGI 1;
             scgi_param REQUEST_URI $request_uri;
             scgi_param HTTP_X_BLAH "blah";
@@ -64,7 +64,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -77,7 +77,7 @@ unlike(http_head('/'), qr/SEE-THIS/, 'no
 like(http_get_headers('/headers'), qr/SEE-THIS/,
 	'scgi request with many ignored headers');
 
-like(http_get('/var?b=127.0.0.1:' . port(1)), qr/SEE-THIS/,
+like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/,
 	'scgi with variables');
 like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi with variables to upstream');
 
@@ -116,7 +116,7 @@ EOF
 sub scgi_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/scgi_body.t
+++ b/scgi_body.t
@@ -38,11 +38,11 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            scgi_pass 127.0.0.1:%%PORT_1%%;
+            scgi_pass 127.0.0.1:8081;
             scgi_param SCGI 1;
             scgi_param REQUEST_URI $request_uri;
         }
@@ -52,7 +52,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -104,7 +104,7 @@ EOF
 sub scgi_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/scgi_cache.t
+++ b/scgi_cache.t
@@ -44,11 +44,11 @@ http {
     add_header       X-Cache-Status  $upstream_cache_status;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            scgi_pass 127.0.0.1:%%PORT_1%%;
+            scgi_pass 127.0.0.1:8081;
             scgi_param SCGI 1;
             scgi_param REQUEST_URI $uri;
             scgi_cache one;
@@ -59,7 +59,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -83,7 +83,7 @@ like(http_get('/unfinished'), qr/MISS/, 
 sub scgi_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/scgi_gzip.t
+++ b/scgi_gzip.t
@@ -38,12 +38,12 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
             gzip on;
-            scgi_pass 127.0.0.1:%%PORT_1%%;
+            scgi_pass 127.0.0.1:8081;
             scgi_param SCGI 1;
             scgi_param REQUEST_URI $request_uri;
             scgi_param HTTP_X_BLAH "blah";
@@ -54,7 +54,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -65,7 +65,7 @@ like(http_gzip_request('/'), qr/Content-
 sub scgi_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/scgi_merge_params.t
+++ b/scgi_merge_params.t
@@ -46,22 +46,22 @@ http {
     scgi_param HTTP_X_BLAH "blah";
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         scgi_cache  NAME;
 
         location / {
-            scgi_pass    127.0.0.1:%%PORT_1%%;
+            scgi_pass    127.0.0.1:8081;
         }
 
         location /no/ {
-            scgi_pass    127.0.0.1:%%PORT_1%%;
+            scgi_pass    127.0.0.1:8081;
             scgi_cache   off;
         }
 
         location /custom/ {
-            scgi_pass    127.0.0.1:%%PORT_1%%;
+            scgi_pass    127.0.0.1:8081;
             scgi_param   SCGI 1;
             scgi_param   HTTP_X_BLAH  "custom";
         }
@@ -71,7 +71,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -115,7 +115,7 @@ EOF
 sub scgi_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/secure_link.t
+++ b/secure_link.t
@@ -39,7 +39,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/server_tokens.t
+++ b/server_tokens.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /200 {
--- a/slice.t
+++ b/slice.t
@@ -44,7 +44,7 @@ http {
     fastcgi_cache_key    $uri$is_args$args$slice_range;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / { }
@@ -52,7 +52,7 @@ http {
         location /cache/ {
             slice 2;
 
-            proxy_pass    http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass    http://127.0.0.1:8081/;
 
             proxy_cache   NAME;
 
@@ -66,7 +66,7 @@ http {
         location /fastcgi {
             slice 2;
 
-            fastcgi_pass    127.0.0.1:%%PORT_2%%;
+            fastcgi_pass    127.0.0.1:8082;
 
             fastcgi_cache   NAME2;
 
@@ -81,7 +81,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
 
         location / { }
@@ -228,7 +228,7 @@ SKIP: {
 	skip 'win32', 5 if $^O eq 'MSWin32';
 
 	$t->run_daemon(\&fastcgi_daemon);
-	$t->waitforsocket('127.0.0.1:' . port(2));
+	$t->waitforsocket('127.0.0.1:' . port(8082));
 
 	like(http_get('/fastcgi'), qr/200 OK.*MISS.*^012345678$/ms, 'fastcgi');
 	like(http_get('/fastcgi'), qr/200 OK.*HIT.*^012345678$/ms,
@@ -258,7 +258,7 @@ EOF
 ###############################################################################
 
 sub fastcgi_daemon {
-	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(2), 5);
+	my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8082), 5);
 	my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
 		$socket);
 
--- a/split_clients.t
+++ b/split_clients.t
@@ -43,7 +43,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/ssi.t
+++ b/ssi.t
@@ -40,7 +40,7 @@ http {
                            keys_zone=NAME:1m;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         if ($args = "found") {
@@ -52,10 +52,10 @@ http {
         }
         location /proxy/ {
             ssi on;
-            proxy_pass http://127.0.0.1:%%PORT_0%%/local/;
+            proxy_pass http://127.0.0.1:8080/local/;
         }
         location /cache/ {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/local/;
+            proxy_pass http://127.0.0.1:8080/local/;
             proxy_cache NAME;
             proxy_cache_valid 200 1h;
         }
--- a/ssi_if.t
+++ b/ssi_if.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             ssi on;
--- a/ssi_include_big.t
+++ b/ssi_include_big.t
@@ -40,11 +40,11 @@ http {
     gzip on;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /proxy/ {
-            proxy_pass http://127.0.0.1:%%PORT_0%%/local/;
+            proxy_pass http://127.0.0.1:8080/local/;
         }
         location = /local/blah {
             return 204;
--- a/ssi_waited.t
+++ b/ssi_waited.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
         location / {
             ssi on;
--- a/ssl.t
+++ b/ssl.t
@@ -48,8 +48,8 @@ http {
     ssl_session_tickets off;
 
     server {
-        listen       127.0.0.1:%%PORT_5%% ssl;
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8085 ssl;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         ssl_certificate_key inner.key;
@@ -74,7 +74,7 @@ http {
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8081;
         server_name  localhost;
 
         # Special case for enabled "ssl" directive.
@@ -89,7 +89,7 @@ http {
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%% ssl;
+        listen      127.0.0.1:8082 ssl;
         server_name  localhost;
 
         ssl_session_cache builtin:1000;
@@ -100,7 +100,7 @@ http {
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3%% ssl;
+        listen      127.0.0.1:8083 ssl;
         server_name  localhost;
 
         ssl_session_cache none;
@@ -111,7 +111,7 @@ http {
     }
 
     server {
-        listen      127.0.0.1:%%PORT_4%% ssl;
+        listen      127.0.0.1:8084 ssl;
         server_name  localhost;
 
         ssl_session_cache off;
@@ -150,39 +150,39 @@ my $ctx = new IO::Socket::SSL::SSL_Conte
 
 ###############################################################################
 
-like(http_get('/reuse', socket => get_ssl_socket($ctx, port(5))),
+like(http_get('/reuse', socket => get_ssl_socket($ctx, port(8085))),
 	qr/^body \.$/m, 'shared initial session');
-like(http_get('/reuse', socket => get_ssl_socket($ctx, port(5))),
+like(http_get('/reuse', socket => get_ssl_socket($ctx, port(8085))),
 	qr/^body r$/m, 'shared session reused');
 
-like(http_get('/', socket => get_ssl_socket($ctx, port(1))), qr/^body \.$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body \.$/m,
 	'builtin initial session');
-like(http_get('/', socket => get_ssl_socket($ctx, port(1))), qr/^body r$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body r$/m,
 	'builtin session reused');
 
-like(http_get('/', socket => get_ssl_socket($ctx, port(2))), qr/^body \.$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8082))), qr/^body \.$/m,
 	'builtin size initial session');
-like(http_get('/', socket => get_ssl_socket($ctx, port(2))), qr/^body r$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8082))), qr/^body r$/m,
 	'builtin size session reused');
 
-like(http_get('/', socket => get_ssl_socket($ctx, port(3))), qr/^body \.$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8083))), qr/^body \.$/m,
 	'reused none initial session');
-like(http_get('/', socket => get_ssl_socket($ctx, port(3))), qr/^body \.$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8083))), qr/^body \.$/m,
 	'session not reused 1');
 
-like(http_get('/', socket => get_ssl_socket($ctx, port(4))), qr/^body \.$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8084))), qr/^body \.$/m,
 	'reused off initial session');
-like(http_get('/', socket => get_ssl_socket($ctx, port(4))), qr/^body \.$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8084))), qr/^body \.$/m,
 	'session not reused 2');
 
 # ssl certificate inheritance
 
-my $s = get_ssl_socket($ctx, port(1));
+my $s = get_ssl_socket($ctx, port(8081));
 like($s->dump_peer_certificate(), qr/CN=localhost/, 'CN');
 
 $s->close();
 
-$s = get_ssl_socket($ctx, port(5));
+$s = get_ssl_socket($ctx, port(8085));
 like($s->dump_peer_certificate(), qr/CN=inner/, 'CN inner');
 
 $s->close();
@@ -191,24 +191,24 @@ like($s->dump_peer_certificate(), qr/CN=
 
 select undef, undef, undef, 2.1;
 
-like(http_get('/', socket => get_ssl_socket($ctx, port(1))), qr/^body \.$/m,
+like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body \.$/m,
 	'session timeout');
 
 # embedded variables
 
 my ($sid) = http_get('/id',
-	socket => get_ssl_socket($ctx, port(5))) =~ /^body (\w+)$/m;
+	socket => get_ssl_socket($ctx, port(8085))) =~ /^body (\w+)$/m;
 is(length $sid, 64, 'session id');
 
 unlike(http_get('/id'), qr/body \w/, 'session id no ssl');
 
-like(http_get('/cipher', socket => get_ssl_socket($ctx, port(5))),
+like(http_get('/cipher', socket => get_ssl_socket($ctx, port(8085))),
 	qr/^body [\w-]+$/m, 'cipher');
 
-like(http_get('/client_verify', socket => get_ssl_socket($ctx, port(5))),
+like(http_get('/client_verify', socket => get_ssl_socket($ctx, port(8085))),
 	qr/^body NONE$/m, 'client verify');
 
-like(http_get('/protocol', socket => get_ssl_socket($ctx, port(5))),
+like(http_get('/protocol', socket => get_ssl_socket($ctx, port(8085))),
 	qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol');
 
 ###############################################################################
--- a/ssl_certificate_chain.t
+++ b/ssl_certificate_chain.t
@@ -43,7 +43,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  localhost;
 
         ssl_certificate_key end.key;
@@ -51,7 +51,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
+        listen       127.0.0.1:8081 ssl;
         server_name  localhost;
 
         ssl_certificate_key int.key;
@@ -59,7 +59,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_2%% ssl;
+        listen       127.0.0.1:8082 ssl;
         server_name  localhost;
 
         ssl_certificate_key end.key;
@@ -137,9 +137,9 @@ system("openssl ca -batch -config '$d/ca
 
 ###############################################################################
 
-is(get_ssl_socket(port(0)), undef, 'incomplete chain');
-ok(get_ssl_socket(port(1)), 'intermediate');
-ok(get_ssl_socket(port(2)), 'intermediate server');
+is(get_ssl_socket(port(8080)), undef, 'incomplete chain');
+ok(get_ssl_socket(port(8081)), 'intermediate');
+ok(get_ssl_socket(port(8082)), 'intermediate server');
 
 ###############################################################################
 
--- a/ssl_certificates.t
+++ b/ssl_certificates.t
@@ -47,7 +47,7 @@ http {
     ssl_certificate rsa.crt;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  localhost;
 
         ssl_certificate_key dsa.key;
@@ -108,7 +108,7 @@ sub get_cert {
 		$s = IO::Socket::SSL->new(
 			Proto => 'tcp',
 			PeerAddr => '127.0.0.1',
-			PeerPort => port(0),
+			PeerPort => port(8080),
 			SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
 			SSL_cipher_list => $ciphers,
 			SSL_error_trap => sub { die $_[1] }
--- a/ssl_engine_keys.t
+++ b/ssl_engine_keys.t
@@ -43,8 +43,8 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8081 ssl;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         ssl_certificate_key engine:pkcs11:slot_0-id_00;
@@ -54,7 +54,7 @@ http {
             # index index.html by default
         }
         location /proxy {
-            proxy_pass https://127.0.0.1:%%PORT_1%%/;
+            proxy_pass https://127.0.0.1:8081/;
         }
     }
 }
--- a/ssl_password_file.t
+++ b/ssl_password_file.t
@@ -54,8 +54,8 @@ http {
     ssl_password_file password_http;
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8081 ssl;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         ssl_password_file password;
@@ -66,21 +66,21 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  two_entries;
 
         ssl_password_file password_many;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  file_is_fifo;
 
         ssl_password_file password_fifo;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  inherits;
 
         ssl_certificate_key inherits.key;
@@ -148,7 +148,7 @@ sub get_ssl_socket {
 		alarm(2);
 		$s = IO::Socket::SSL->new(
 			Proto => 'tcp',
-			PeerAddr => '127.0.0.1:' . port(1),
+			PeerAddr => '127.0.0.1:' . port(8081),
 			SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
 			SSL_error_trap => sub { die $_[1] }
 		);
--- a/ssl_proxy_protocol.t
+++ b/ssl_proxy_protocol.t
@@ -47,7 +47,7 @@ http {
     log_format pp '$remote_addr $request';
 
     server {
-        listen       127.0.0.1:%%PORT_0%% proxy_protocol ssl;
+        listen       127.0.0.1:8080 proxy_protocol ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
--- a/ssl_proxy_upgrade.t
+++ b/ssl_proxy_upgrade.t
@@ -51,14 +51,14 @@ http {
     access_log %%TESTDIR%%/cc.log test;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
         ssl_certificate localhost.crt;
 
         location / {
-            proxy_pass    http://127.0.0.1:%%PORT_1%%;
+            proxy_pass    http://127.0.0.1:8081;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "Upgrade";
@@ -91,7 +91,7 @@ foreach my $name ('localhost') {
 $t->run_daemon(\&upgrade_fake_daemon);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start test backend";
 
 ###############################################################################
@@ -173,7 +173,7 @@ sub upgrade_connect {
 
 	my $s = IO::Socket::SSL->new(
 		Proto => 'tcp',
-		PeerAddr => '127.0.0.1:' . port(0),
+		PeerAddr => '127.0.0.1:' . port(8080),
 		SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
 	)
 		or die "Can't connect to nginx: $!\n";
@@ -283,7 +283,7 @@ sub upgrade_read {
 sub upgrade_fake_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/ssl_sni.t
+++ b/ssl_sni.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
@@ -49,7 +49,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  example.com;
 
         ssl_certificate_key example.com.key;
@@ -136,7 +136,7 @@ sub get_ssl_socket {
 		alarm(2);
 		$s = IO::Socket::SSL->new(
 			Proto => 'tcp',
-			PeerAddr => '127.0.0.1:' . port(0),
+			PeerAddr => '127.0.0.1:' . port(8080),
 			SSL_hostname => $host,
 			SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
 			SSL_error_trap => sub { die $_[1] }
--- a/ssl_sni_reneg.t
+++ b/ssl_sni_reneg.t
@@ -58,7 +58,7 @@ http {
     ssl_certificate localhost.crt;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  localhost;
 
         location / { }
@@ -118,7 +118,7 @@ sub get_ssl_socket {
 	my $s;
 
 	my $dest_ip = inet_aton('127.0.0.1');
-	my $dest_serv_params = sockaddr_in(port(0), $dest_ip);
+	my $dest_serv_params = sockaddr_in(port(8080), $dest_ip);
 
 	eval {
 		local $SIG{ALRM} = sub { die "timeout\n" };
--- a/ssl_sni_sessions.t
+++ b/ssl_sni_sessions.t
@@ -39,7 +39,7 @@ http {
     ssl_certificate localhost.crt;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  default;
 
         ssl_session_tickets off;
@@ -51,7 +51,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  nocache;
 
         ssl_session_tickets off;
@@ -63,7 +63,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
+        listen       127.0.0.1:8081 ssl;
         server_name  default;
 
         ssl_session_ticket_key ticket1.key;
@@ -74,7 +74,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  tickets;
 
         ssl_session_ticket_key ticket2.key;
@@ -135,8 +135,8 @@ foreach my $name ('localhost') {
 
 my $ctx = get_ssl_context();
 
-like(get('default', port(0), $ctx), qr!default:\.!, 'default server');
-like(get('default', port(0), $ctx), qr!default:r!, 'default server reused');
+like(get('default', port(8080), $ctx), qr!default:\.!, 'default server');
+like(get('default', port(8080), $ctx), qr!default:r!, 'default server reused');
 
 # check that sessions are still properly saved and restored
 # when using an SNI-based virtual server with different session cache;
@@ -150,16 +150,16 @@ like(get('default', port(0), $ctx), qr!d
 
 $ctx = get_ssl_context();
 
-like(get('nocache', port(0), $ctx), qr!nocache:\.!, 'without cache');
-like(get('nocache', port(0), $ctx), qr!nocache:r!, 'without cache reused');
+like(get('nocache', port(8080), $ctx), qr!nocache:\.!, 'without cache');
+like(get('nocache', port(8080), $ctx), qr!nocache:r!, 'without cache reused');
 
 # make sure tickets can be used if an SNI-based virtual server
 # uses a different set of session ticket keys explicitly set
 
 $ctx = get_ssl_context();
 
-like(get('tickets', port(1), $ctx), qr!tickets:\.!, 'tickets');
-like(get('tickets', port(1), $ctx), qr!tickets:r!, 'tickets reused');
+like(get('tickets', port(8081), $ctx), qr!tickets:\.!, 'tickets');
+like(get('tickets', port(8081), $ctx), qr!tickets:r!, 'tickets reused');
 
 ###############################################################################
 
--- a/ssl_verify_client.t
+++ b/ssl_verify_client.t
@@ -50,7 +50,7 @@ http {
     add_header X-Verify $ssl_client_verify;
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  localhost;
 
         ssl_client_certificate client.crt;
@@ -59,7 +59,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  example.com;
 
         location / { }
@@ -119,7 +119,7 @@ sub get {
 		$s = IO::Socket::SSL->new(
 			Proto => 'tcp',
 			PeerAddr => '127.0.0.1',
-			PeerPort => port(0),
+			PeerPort => port(8080),
 			SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
 			SSL_hostname => $sni,
 			SSL_cert_file => "$d/client.crt",
--- a/stream_access.t
+++ b/stream_access.t
@@ -36,110 +36,110 @@ events {
 
 stream {
     server {
-        listen       127.0.0.1:%%PORT_2%%;
-        proxy_pass   [::1]:%%PORT_0%%;
+        listen       127.0.0.1:8082;
+        proxy_pass   [::1]:%%PORT_8080%%;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_3%%;
+        listen       127.0.0.1:8083;
         proxy_pass   unix:%%TESTDIR%%/unix.sock.0;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_5%%;
-        proxy_pass   [::1]:%%PORT_1%%;
+        listen       127.0.0.1:8085;
+        proxy_pass   [::1]:%%PORT_8081%%;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_6%%;
+        listen       127.0.0.1:8086;
         proxy_pass   unix:%%TESTDIR%%/unix.sock.1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_8%%;
-        proxy_pass   [::1]:%%PORT_2%%;
+        listen       127.0.0.1:8088;
+        proxy_pass   [::1]:%%PORT_8082%%;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_9%%;
+        listen       127.0.0.1:8089;
         proxy_pass   unix:%%TESTDIR%%/unix.sock.2;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_11%%;
-        proxy_pass   [::1]:%%PORT_3%%;
+        listen       127.0.0.1:8091;
+        proxy_pass   [::1]:%%PORT_8083%%;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_12%%;
+        listen       127.0.0.1:8092;
         proxy_pass   unix:%%TESTDIR%%/unix.sock.3;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_14%%;
-        proxy_pass   [::1]:%%PORT_4%%;
+        listen       127.0.0.1:8094;
+        proxy_pass   [::1]:%%PORT_8084%%;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_15%%;
+        listen       127.0.0.1:8095;
         proxy_pass   unix:%%TESTDIR%%/unix.sock.4;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_17%%;
-        proxy_pass   [::1]:%%PORT_5%%;
+        listen       127.0.0.1:8097;
+        proxy_pass   [::1]:%%PORT_8085%%;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_18%%;
+        listen       127.0.0.1:8098;
         proxy_pass   unix:%%TESTDIR%%/unix.sock.5;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
-        listen       [::1]:%%PORT_0%%;
+        listen       127.0.0.1:8081;
+        listen       [::1]:%%PORT_8080%%;
         listen       unix:%%TESTDIR%%/unix.sock.0;
-        proxy_pass   127.0.0.1:%%PORT_0%%;
+        proxy_pass   127.0.0.1:8080;
         allow        all;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_4%%;
-        listen       [::1]:%%PORT_1%%;
+        listen       127.0.0.1:8084;
+        listen       [::1]:%%PORT_8081%%;
         listen       unix:%%TESTDIR%%/unix.sock.1;
-        proxy_pass   127.0.0.1:%%PORT_0%%;
+        proxy_pass   127.0.0.1:8080;
         deny         all;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_7%%;
-        listen       [::1]:%%PORT_2%%;
+        listen       127.0.0.1:8087;
+        listen       [::1]:%%PORT_8082%%;
         listen       unix:%%TESTDIR%%/unix.sock.2;
-        proxy_pass   127.0.0.1:%%PORT_0%%;
+        proxy_pass   127.0.0.1:8080;
         allow        unix:;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_10%%;
-        listen       [::1]:%%PORT_3%%;
+        listen       127.0.0.1:8090;
+        listen       [::1]:%%PORT_8083%%;
         listen       unix:%%TESTDIR%%/unix.sock.3;
-        proxy_pass   127.0.0.1:%%PORT_0%%;
+        proxy_pass   127.0.0.1:8080;
         deny         127.0.0.1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_13%%;
-        listen       [::1]:%%PORT_4%%;
+        listen       127.0.0.1:8093;
+        listen       [::1]:%%PORT_8084%%;
         listen       unix:%%TESTDIR%%/unix.sock.4;
-        proxy_pass   127.0.0.1:%%PORT_0%%;
+        proxy_pass   127.0.0.1:8080;
         deny         ::1;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_16%%;
-        listen       [::1]:%%PORT_5%%;
+        listen       127.0.0.1:8096;
+        listen       [::1]:%%PORT_8085%%;
         listen       unix:%%TESTDIR%%/unix.sock.5;
-        proxy_pass   127.0.0.1:%%PORT_0%%;
+        proxy_pass   127.0.0.1:8080;
         deny         unix:;
     }
 }
@@ -148,7 +148,7 @@ EOF
 
 $t->try_run('no inet6 support')->plan(18);
 $t->run_daemon(\&stream_daemon);
-$t->waitforsocket('127.0.0.1:' . port(0));
+$t->waitforsocket('127.0.0.1:' . port(8080));
 
 ###############################################################################
 
@@ -156,46 +156,46 @@ my $str = 'SEE-THIS';
 
 # allow all
 
-is(stream('127.0.0.1:' . port(1))->io($str), $str, 'inet allow all');
-is(stream('127.0.0.1:' . port(2))->io($str), $str, 'inet6 allow all');
-is(stream('127.0.0.1:' . port(3))->io($str), $str, 'unix allow all');
+is(stream('127.0.0.1:' . port(8081))->io($str), $str, 'inet allow all');
+is(stream('127.0.0.1:' . port(8082))->io($str), $str, 'inet6 allow all');
+is(stream('127.0.0.1:' . port(8083))->io($str), $str, 'unix allow all');
 
 # deny all
 
-is(stream('127.0.0.1:' . port(4))->io($str), '', 'inet deny all');
-is(stream('127.0.0.1:' . port(5))->io($str), '', 'inet6 deny all');
-is(stream('127.0.0.1:' . port(6))->io($str), '', 'unix deny all');
+is(stream('127.0.0.1:' . port(8084))->io($str), '', 'inet deny all');
+is(stream('127.0.0.1:' . port(8085))->io($str), '', 'inet6 deny all');
+is(stream('127.0.0.1:' . port(8086))->io($str), '', 'unix deny all');
 
 # allow unix
 
-is(stream('127.0.0.1:' . port(7))->io($str), $str, 'inet allow unix');
-is(stream('127.0.0.1:' . port(8))->io($str), $str, 'inet6 allow unix');
-is(stream('127.0.0.1:' . port(9))->io($str), $str, 'unix allow unix');
+is(stream('127.0.0.1:' . port(8087))->io($str), $str, 'inet allow unix');
+is(stream('127.0.0.1:' . port(8088))->io($str), $str, 'inet6 allow unix');
+is(stream('127.0.0.1:' . port(8089))->io($str), $str, 'unix allow unix');
 
 # deny inet
 
-is(stream('127.0.0.1:' . port(10))->io($str), '', 'inet deny inet');
-is(stream('127.0.0.1:' . port(11))->io($str), $str, 'inet6 deny inet');
-is(stream('127.0.0.1:' . port(12))->io($str), $str, 'unix deny inet');
+is(stream('127.0.0.1:' . port(8090))->io($str), '', 'inet deny inet');
+is(stream('127.0.0.1:' . port(8091))->io($str), $str, 'inet6 deny inet');
+is(stream('127.0.0.1:' . port(8092))->io($str), $str, 'unix deny inet');
 
 # deny inet6
 
-is(stream('127.0.0.1:' . port(13))->io($str), $str, 'inet deny inet6');
-is(stream('127.0.0.1:' . port(14))->io($str), '', 'inet6 deny inet6');
-is(stream('127.0.0.1:' . port(15))->io($str), $str, 'unix deny inet6');
+is(stream('127.0.0.1:' . port(8093))->io($str), $str, 'inet deny inet6');
+is(stream('127.0.0.1:' . port(8094))->io($str), '', 'inet6 deny inet6');
+is(stream('127.0.0.1:' . port(8095))->io($str), $str, 'unix deny inet6');
 
 # deny unix
 
-is(stream('127.0.0.1:' . port(16))->io($str), $str, 'inet deny unix');
-is(stream('127.0.0.1:' . port(17))->io($str), $str, 'inet6 deny unix');
-is(stream('127.0.0.1:' . port(18))->io($str), '', 'unix deny unix');
+is(stream('127.0.0.1:' . port(8096))->io($str), $str, 'inet deny unix');
+is(stream('127.0.0.1:' . port(8097))->io($str), $str, 'inet6 deny unix');
+is(stream('127.0.0.1:' . port(8098))->io($str), '', 'unix deny unix');
 
 ###############################################################################
 
 sub stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(0),
+		LocalAddr => '127.0.0.1:' . port(8080),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_error_log.t
+++ b/stream_error_log.t
@@ -35,7 +35,7 @@ my $t = Test::Nginx->new()->has(qw/strea
 
 error_log %%TESTDIR%%/e_glob.log info;
 error_log %%TESTDIR%%/e_glob2.log info;
-error_log syslog:server=127.0.0.1:%%PORT_3_UDP%% info;
+error_log syslog:server=127.0.0.1:%%PORT_8083_UDP%% info;
 
 daemon off;
 
@@ -44,11 +44,11 @@ events {
 
 stream {
     upstream u {
-        server 127.0.0.1:%%PORT_3_UDP%% down;
+        server 127.0.0.1:%%PORT_8083_UDP%% down;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8080;
         proxy_pass  u;
 
         error_log %%TESTDIR%%/e_debug.log debug;
@@ -58,12 +58,12 @@ stream {
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%%;
-        proxy_pass  127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8082;
+        proxy_pass  127.0.0.1:8081;
 
         error_log %%TESTDIR%%/e_stream.log info;
-        error_log syslog:server=127.0.0.1:%%PORT_5_UDP%% info;
-        error_log syslog:server=127.0.0.1:%%PORT_4_UDP%% info;
+        error_log syslog:server=127.0.0.1:%%PORT_8085_UDP%% info;
+        error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% info;
     }
 }
 
@@ -75,10 +75,10 @@ open my $stderr, '<', $t->testdir() . '/
 	or die "Can't open stderr file: $!";
 
 $t->run_daemon(\&stream_daemon);
-$t->run_daemon(\&syslog_daemon, port(3), $t, 's_glob.log');
-$t->run_daemon(\&syslog_daemon, port(4), $t, 's_stream.log');
+$t->run_daemon(\&syslog_daemon, port(8083), $t, 's_glob.log');
+$t->run_daemon(\&syslog_daemon, port(8084), $t, 's_stream.log');
 
-$t->waitforsocket('127.0.0.1:' . port(1));
+$t->waitforsocket('127.0.0.1:' . port(8081));
 $t->waitforfile($t->testdir . '/s_glob.log');
 $t->waitforfile($t->testdir . '/s_stream.log');
 
@@ -113,8 +113,8 @@ is_deeply(levels($t, 'e_glob.log'), leve
 
 # syslog
 
-parse_syslog_message('syslog', get_syslog('data2', '127.0.0.1:' . port(2),
-	port(5)));
+parse_syslog_message('syslog', get_syslog('data2', '127.0.0.1:' . port(8082),
+	port(8085)));
 
 is_deeply(levels($t, 's_glob.log'), levels($t, 'e_glob.log'),
 	'global syslog messages');
@@ -127,7 +127,8 @@ SKIP: {
 skip "relies on error log contents", 5 unless $ENV{TEST_NGINX_UNSAFE};
 
 my $msg = 'no live upstreams while connecting to upstream, '
-	. 'client: 127.0.0.1, server: 127.0.0.1:' . port(0) . ', upstream: "u"';
+	. 'client: 127.0.0.1, server: 127.0.0.1:' . port(8080)
+	. ', upstream: "u"';
 
 unlike($t->read_file('e_glob.log'), qr/$msg/ms, 'stream error in global');
 like($t->read_file('e_info.log'), qr/$msg/ms, 'stream error in info');
@@ -275,7 +276,7 @@ sub stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
 		LocalHost => '127.0.0.1',
-		LocalPort => port(1),
+		LocalPort => port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_limit_conn.t
+++ b/stream_limit_conn.t
@@ -37,32 +37,32 @@ stream {
     limit_conn_zone  $binary_remote_addr  zone=zone2:1m;
 
     server {
-        listen           127.0.0.1:%%PORT_0%%;
-        proxy_pass       127.0.0.1:%%PORT_4%%;
+        listen           127.0.0.1:8080;
+        proxy_pass       127.0.0.1:8084;
         limit_conn       zone 1;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_5%%;
-        proxy_pass       127.0.0.1:%%PORT_4%%;
+        listen           127.0.0.1:8085;
+        proxy_pass       127.0.0.1:8084;
         limit_conn       zone 5;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_1%%;
-        proxy_pass       127.0.0.1:%%PORT_4%%;
+        listen           127.0.0.1:8081;
+        proxy_pass       127.0.0.1:8084;
         limit_conn       zone2 1;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_2%%;
-        proxy_pass       127.0.0.1:%%PORT_0%%;
+        listen           127.0.0.1:8082;
+        proxy_pass       127.0.0.1:8080;
         limit_conn       zone2 1;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_3%%;
-        proxy_pass       127.0.0.1:%%PORT_0%%;
+        listen           127.0.0.1:8083;
+        proxy_pass       127.0.0.1:8080;
         limit_conn       zone 1;
     }
 }
@@ -71,7 +71,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_4%%;
+        listen       127.0.0.1:8084;
         server_name  localhost;
 
         location / { }
@@ -96,8 +96,8 @@ EOF
 ok($s, 'long connection');
 
 is(get(), undef, 'rejected same zone');
-like(get('127.0.0.1:' . port(1)), qr/200 OK/, 'passed different zone');
-like(get('127.0.0.1:' . port(5)), qr/200 OK/, 'passed same zone unlimited');
+like(get('127.0.0.1:' . port(8081)), qr/200 OK/, 'passed different zone');
+like(get('127.0.0.1:' . port(8085)), qr/200 OK/, 'passed same zone unlimited');
 
 ok(http(<<EOF, socket => $s), 'long connection closed');
 Host: localhost
@@ -106,8 +106,8 @@ EOF
 
 # zones proxy chain
 
-like(get('127.0.0.1:' . port(2)), qr/200 OK/, 'passed proxy');
-is(get('127.0.0.1:' . port(3)), undef, 'rejected proxy');
+like(get('127.0.0.1:' . port(8082)), qr/200 OK/, 'passed proxy');
+is(get('127.0.0.1:' . port(8083)), undef, 'rejected proxy');
 
 ###############################################################################
 
@@ -126,7 +126,7 @@ sub getconn {
 	my $peer = shift;
 	my $s = IO::Socket::INET->new(
 		Proto => 'tcp',
-		PeerAddr => $peer || '127.0.0.1:' . port(0)
+		PeerAddr => $peer || '127.0.0.1:' . port(8080)
 	)
 		or die "Can't connect to nginx: $!\n";
 
--- a/stream_limit_conn_complex.t
+++ b/stream_limit_conn_complex.t
@@ -36,14 +36,14 @@ stream {
     limit_conn_zone  $binary_remote_addr$server_port  zone=zone:1m;
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
-        proxy_pass  127.0.0.1:%%PORT_4%%;
+        listen      127.0.0.1:8080;
+        proxy_pass  127.0.0.1:8084;
         limit_conn  zone 1;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
-        proxy_pass  127.0.0.1:%%PORT_4%%;
+        listen      127.0.0.1:8081;
+        proxy_pass  127.0.0.1:8084;
         limit_conn  zone 1;
     }
 }
@@ -52,7 +52,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_4%%;
+        listen       127.0.0.1:8084;
         server_name  localhost;
 
         location / { }
@@ -66,7 +66,7 @@ EOF
 
 ###############################################################################
 
-like(get(port(0)), qr/200 OK/, 'passed');
+like(get(port(8080)), qr/200 OK/, 'passed');
 
 my $s = http(<<EOF, start => 1, sleep => 0.2);
 GET / HTTP/1.0
@@ -74,8 +74,8 @@ EOF
 
 ok($s, 'long connection');
 
-is(get(port(0)), undef, 'rejected same key');
-like(get(port(1)), qr/200 OK/, 'passed different key');
+is(get(port(8080)), undef, 'rejected same key');
+like(get(port(8081)), qr/200 OK/, 'passed different key');
 
 ###############################################################################
 
--- a/stream_limit_rate.t
+++ b/stream_limit_rate.t
@@ -46,59 +46,59 @@ stream {
     proxy_upload_rate        1000;
 
     server {
-        listen               127.0.0.1:%%PORT_1%%;
-        proxy_pass           127.0.0.1:%%PORT_0%%;
+        listen               127.0.0.1:8081;
+        proxy_pass           127.0.0.1:8080;
     }
 
     server {
-        listen               127.0.0.1:%%PORT_2%%;
-        proxy_pass           127.0.0.1:%%PORT_0%%;
+        listen               127.0.0.1:8082;
+        proxy_pass           127.0.0.1:8080;
         proxy_download_rate  0;
         proxy_upload_rate    0;
     }
 
     server {
-        listen               127.0.0.1:%%PORT_3%%;
-        proxy_pass           127.0.0.1:%%PORT_0%%;
+        listen               127.0.0.1:8083;
+        proxy_pass           127.0.0.1:8080;
         proxy_download_rate  1;
     }
 
     server {
-        listen               127.0.0.1:%%PORT_4%%;
-        proxy_pass           127.0.0.1:%%PORT_0%%;
+        listen               127.0.0.1:8084;
+        proxy_pass           127.0.0.1:8080;
         proxy_upload_rate    1;
     }
 
     server {
-        listen               127.0.0.1:%%PORT_5%%;
-        proxy_pass           127.0.0.1:%%PORT_0%%;
+        listen               127.0.0.1:8085;
+        proxy_pass           127.0.0.1:8080;
         proxy_download_rate  250;
     }
 
     server {
-        listen               127.0.0.1:%%PORT_6%%;
-        proxy_pass           127.0.0.1:%%PORT_7%%;
+        listen               127.0.0.1:8086;
+        proxy_pass           127.0.0.1:8087;
         proxy_upload_rate    250;
     }
 }
 
 EOF
 
-$t->run_daemon(\&stream_daemon, port(0));
-$t->run_daemon(\&stream_daemon, port(7));
+$t->run_daemon(\&stream_daemon, port(8080));
+$t->run_daemon(\&stream_daemon, port(8087));
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(0));
-$t->waitforsocket('127.0.0.1:' . port(7));
+$t->waitforsocket('127.0.0.1:' . port(8080));
+$t->waitforsocket('127.0.0.1:' . port(8087));
 
 ###############################################################################
 
 my $str = '1234567890' x 100;
 
-my %r = response($str, peer => '127.0.0.1:' . port(1));
+my %r = response($str, peer => '127.0.0.1:' . port(8081));
 is($r{'data'}, $str, 'exact limit');
 
-%r = response($str, peer => '127.0.0.1:' . port(2));
+%r = response($str, peer => '127.0.0.1:' . port(8082));
 is($r{'data'}, $str, 'unlimited');
 
 SKIP: {
@@ -107,10 +107,10 @@ skip 'unsafe on VM', 2 unless $ENV{TEST_
 # if interaction between backend and client is slow then proxy can add extra
 # bytes to upload/download data
 
-%r = response($str, peer => '127.0.0.1:' . port(3), readonce => 1);
+%r = response($str, peer => '127.0.0.1:' . port(8083), readonce => 1);
 is($r{'data'}, '1', 'download - one byte');
 
-%r = response($str, peer =>  '127.0.0.1:' . port(4));
+%r = response($str, peer =>  '127.0.0.1:' . port(8084));
 is($r{'data'}, '1', 'upload - one byte');
 
 }
@@ -119,13 +119,13 @@ is($r{'data'}, '1', 'upload - one byte')
 # the first four chunks are quarters of test string
 # and the fifth one is some extra data from backend.
 
-%r = response($str, peer =>  '127.0.0.1:' . port(5));
+%r = response($str, peer =>  '127.0.0.1:' . port(8085));
 my $diff = time() - $r{'time'};
 cmp_ok($diff, '>=', 4, 'download - time');
 is($r{'data'}, $str, 'download - data');
 
 my $time = time();
-%r = response($str . 'close', peer => '127.0.0.1:' . port(6));
+%r = response($str . 'close', peer => '127.0.0.1:' . port(8086));
 $diff = time() - $time;
 cmp_ok($diff, '>=', 4, 'upload - time');
 is($r{'data'}, $str . 'close', 'upload - data');
@@ -194,13 +194,13 @@ sub stream_handle_client {
 
 	log2i("$client $buffer");
 
-	$buffer .= " " . time() if $client->sockport() eq port(0);
+	$buffer .= " " . time() if $client->sockport() eq port(8080);
 
 	log2o("$client $buffer");
 
 	$client->syswrite($buffer);
 
-	return $client->sockport() eq port(0) ? 1 : $buffer =~ /close/;
+	return $client->sockport() eq port(8080) ? 1 : $buffer =~ /close/;
 }
 
 sub log2i { Test::Nginx::log_core('|| <<', @_); }
--- a/stream_map.t
+++ b/stream_map.t
@@ -37,22 +37,22 @@ events {
 
 stream {
     map $server_port $x {
-        %%PORT_0%%             literal;
-        default                default;
-        ~(%%PORT_2%%)          $1;
-        ~(?P<ncap>%%PORT_3%%)  $ncap;
+        %%PORT_8080%%             literal;
+        default                   default;
+        ~(%%PORT_8082%%)          $1;
+        ~(?P<ncap>%%PORT_8083%%)  $ncap;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_0%%;
-        listen  127.0.0.1:%%PORT_1%%;
-        listen  127.0.0.1:%%PORT_2%%;
-        listen  127.0.0.1:%%PORT_3%%;
+        listen  127.0.0.1:8080;
+        listen  127.0.0.1:8081;
+        listen  127.0.0.1:8082;
+        listen  127.0.0.1:8083;
         return  $x;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_4%%;
+        listen  127.0.0.1:8084;
         return  $x:${x};
     }
 }
@@ -63,10 +63,10 @@ EOF
 
 ###############################################################################
 
-is(stream('127.0.0.1:' . port(0))->read(), 'literal', 'literal');
-is(stream('127.0.0.1:' . port(1))->read(), 'default', 'default');
-is(stream('127.0.0.1:' . port(2))->read(), port(2), 'capture');
-is(stream('127.0.0.1:' . port(3))->read(), port(3), 'named capture');
-is(stream('127.0.0.1:' . port(4))->read(), 'default:default', 'braces');
+is(stream('127.0.0.1:' . port(8080))->read(), 'literal', 'literal');
+is(stream('127.0.0.1:' . port(8081))->read(), 'default', 'default');
+is(stream('127.0.0.1:' . port(8082))->read(), port(8082), 'capture');
+is(stream('127.0.0.1:' . port(8083))->read(), port(8083), 'named capture');
+is(stream('127.0.0.1:' . port(8084))->read(), 'default:default', 'braces');
 
 ###############################################################################
--- a/stream_proxy.t
+++ b/stream_proxy.t
@@ -37,8 +37,8 @@ events {
 
 stream {
     server {
-        listen      127.0.0.1:%%PORT_0%%;
-        proxy_pass  127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8080;
+        proxy_pass  127.0.0.1:8081;
         proxy_connect_timeout 2s;
     }
 }
@@ -46,7 +46,7 @@ stream {
 EOF
 
 $t->run_daemon(\&stream_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(1));
+$t->run()->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
@@ -68,7 +68,7 @@ is($s->io('foo', length => 3), 'bar', 'p
 sub stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_proxy_bind.t
+++ b/stream_proxy_bind.t
@@ -38,9 +38,9 @@ events {
 
 stream {
     server {
-        listen            127.0.0.1:%%PORT_1%%;
+        listen            127.0.0.1:8081;
         proxy_bind        127.0.0.2;
-        proxy_pass        127.0.0.1:%%PORT_2%%;
+        proxy_pass        127.0.0.1:8082;
     }
 }
 
@@ -48,16 +48,16 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen          127.0.0.1:%%PORT_0%%;
+        listen          127.0.0.1:8080;
         server_name     localhost;
 
         location / {
-            proxy_pass  http://127.0.0.1:%%PORT_1%%;
+            proxy_pass  http://127.0.0.1:8081;
         }
     }
 
     server {
-        listen          127.0.0.1:%%PORT_2%%;
+        listen          127.0.0.1:8082;
 
         location / {
             add_header   X-IP $remote_addr;
--- a/stream_proxy_next_upstream.t
+++ b/stream_proxy_next_upstream.t
@@ -36,32 +36,32 @@ events {
 
 stream {
     upstream u {
-        server 127.0.0.1:%%PORT_3%% max_fails=0;
-        server 127.0.0.1:%%PORT_4%% max_fails=0;
-        server 127.0.0.1:%%PORT_5%% backup;
+        server 127.0.0.1:8083 max_fails=0;
+        server 127.0.0.1:8084 max_fails=0;
+        server 127.0.0.1:8085 backup;
     }
 
     upstream u2 {
-        server 127.0.0.1:%%PORT_3%%;
-        server 127.0.0.1:%%PORT_5%% backup;
+        server 127.0.0.1:8083;
+        server 127.0.0.1:8085 backup;
     }
 
     proxy_connect_timeout 1s;
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8080;
         proxy_pass  u;
         proxy_next_upstream off;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8081;
         proxy_pass  u2;
         proxy_next_upstream on;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%%;
+        listen      127.0.0.1:8082;
         proxy_pass  u;
         proxy_next_upstream on;
         proxy_next_upstream_tries 2;
@@ -71,23 +71,23 @@ stream {
 EOF
 
 $t->run_daemon(\&stream_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(5));
+$t->run()->waitforsocket('127.0.0.1:' . port(8085));
 
 ###############################################################################
 
-is(stream('127.0.0.1:' . port(0))->io('.'), '', 'next off');
-is(stream('127.0.0.1:' . port(1))->io('.'), 'SEE-THIS', 'next on');
+is(stream('127.0.0.1:' . port(8080))->io('.'), '', 'next off');
+is(stream('127.0.0.1:' . port(8081))->io('.'), 'SEE-THIS', 'next on');
 
 # make sure backup is not tried
 
-is(stream('127.0.0.1:' . port(2))->io('.'), '', 'next tries');
+is(stream('127.0.0.1:' . port(8082))->io('.'), '', 'next tries');
 
 ###############################################################################
 
 sub stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(5),
+		LocalHost => '127.0.0.1:' . port(8085),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_proxy_protocol.t
+++ b/stream_proxy_protocol.t
@@ -40,13 +40,13 @@ stream {
     proxy_protocol on;
 
     server {
-        listen          127.0.0.1:%%PORT_0%%;
-        proxy_pass      127.0.0.1:%%PORT_1%%;
+        listen          127.0.0.1:8080;
+        proxy_pass      127.0.0.1:8081;
     }
 
     server {
-        listen          127.0.0.1:%%PORT_2%%;
-        proxy_pass      127.0.0.1:%%PORT_1%%;
+        listen          127.0.0.1:8082;
+        proxy_pass      127.0.0.1:8081;
         proxy_protocol  off;
     }
 }
@@ -55,24 +55,24 @@ EOF
 
 $t->run_daemon(\&stream_daemon);
 $t->try_run('no stream proxy_protocol')->plan(2);
-$t->waitforsocket('127.0.0.1:' . port(1));
+$t->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
-my $dp = port(0);
+my $dp = port(8080);
 my $s = stream('127.0.0.1:' . $dp);
 my $data = $s->io('close');
 my $sp = $s->sockport();
 is($data, "PROXY TCP4 127.0.0.1 127.0.0.1 $sp $dp${CRLF}close", 'protocol on');
 
-is(stream('127.0.0.1:' . port(2))->io('close'), 'close', 'protocol off');
+is(stream('127.0.0.1:' . port(8082))->io('close'), 'close', 'protocol off');
 
 ###############################################################################
 
 sub stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_proxy_protocol_ipv6.t
+++ b/stream_proxy_protocol_ipv6.t
@@ -38,24 +38,24 @@ events {
 
 stream {
     server {
-        listen          127.0.0.1:%%PORT_0%%;
-        proxy_pass      [::1]:%%PORT_0%%;
+        listen          127.0.0.1:8080;
+        proxy_pass      [::1]:%%PORT_8080%%;
     }
 
     server {
-        listen          127.0.0.1:%%PORT_1%%;
-        proxy_pass      [::1]:%%PORT_1%%;
+        listen          127.0.0.1:8081;
+        proxy_pass      [::1]:%%PORT_8081%%;
     }
 
     server {
-        listen          [::1]:%%PORT_0%%;
-        proxy_pass      127.0.0.1:%%PORT_2%%;
+        listen          [::1]:%%PORT_8080%%;
+        proxy_pass      127.0.0.1:8082;
         proxy_protocol  on;
     }
 
     server {
-        listen          [::1]:%%PORT_1%%;
-        proxy_pass      127.0.0.1:%%PORT_2%%;
+        listen          [::1]:%%PORT_8081%%;
+        proxy_pass      127.0.0.1:8082;
     }
 }
 
@@ -63,15 +63,15 @@ EOF
 
 $t->run_daemon(\&stream_daemon);
 $t->try_run('no inet6 support or stream proxy_protocol')->plan(2);
-$t->waitforsocket('127.0.0.1:' . port(2));
+$t->waitforsocket('127.0.0.1:' . port(8082));
 
 ###############################################################################
 
-my $dp = port(0);
+my $dp = port(8080);
 
 like(stream('127.0.0.1:' . $dp)->io('close'),
 	qr/PROXY TCP6 ::1 ::1 \d+ $dp$CRLF/, 'protocol on');
-unlike(stream('127.0.0.1:' . port(1))->io('close'), qr/PROXY/,
+unlike(stream('127.0.0.1:' . port(8081))->io('close'), qr/PROXY/,
 	'protocol off');
 
 ###############################################################################
@@ -79,7 +79,7 @@ unlike(stream('127.0.0.1:' . port(1))->i
 sub stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(2),
+		LocalHost => '127.0.0.1:' . port(8082),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_proxy_protocol_ssl.t
+++ b/stream_proxy_protocol_ssl.t
@@ -43,13 +43,13 @@ stream {
     proxy_protocol  on;
 
     server {
-        listen          127.0.0.1:%%PORT_0%%;
-        proxy_pass      127.0.0.1:%%PORT_1%%;
+        listen          127.0.0.1:8080;
+        proxy_pass      127.0.0.1:8081;
     }
 
     server {
-        listen          127.0.0.1:%%PORT_2%%;
-        proxy_pass      127.0.0.1:%%PORT_3%%;
+        listen          127.0.0.1:8082;
+        proxy_pass      127.0.0.1:8083;
         proxy_protocol  off;
     }
 }
@@ -74,22 +74,22 @@ foreach my $name ('localhost') {
 		or die "Can't create certificate for $name: $!\n";
 }
 
-$t->run_daemon(\&stream_daemon_ssl, port(1), path => $d, pp => 1);
-$t->run_daemon(\&stream_daemon_ssl, port(3), path => $d, pp => 0);
+$t->run_daemon(\&stream_daemon_ssl, port(8081), path => $d, pp => 1);
+$t->run_daemon(\&stream_daemon_ssl, port(8083), path => $d, pp => 0);
 $t->try_run('no stream proxy_protocol')->plan(2);
 
-$t->waitforsocket('127.0.0.1:' . port(1));
-$t->waitforsocket('127.0.0.1:' . port(3));
+$t->waitforsocket('127.0.0.1:' . port(8081));
+$t->waitforsocket('127.0.0.1:' . port(8083));
 
 ###############################################################################
 
-my $dp = port(0);
+my $dp = port(8080);
 
 my %r = pp_get('test', '127.0.0.1:' . $dp);
 is($r{'data'}, "PROXY TCP4 127.0.0.1 127.0.0.1 $r{'sp'} $dp" . CRLF . 'test',
 	'protocol on');
 
-%r = pp_get('test', '127.0.0.1:' . port(2));
+%r = pp_get('test', '127.0.0.1:' . port(8082));
 is($r{'data'}, 'test', 'protocol off');
 
 ###############################################################################
--- a/stream_proxy_ssl.t
+++ b/stream_proxy_ssl.t
@@ -40,14 +40,14 @@ stream {
     proxy_connect_timeout 2s;
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
-        proxy_pass  127.0.0.1:%%PORT_2%%;
+        listen      127.0.0.1:8080;
+        proxy_pass  127.0.0.1:8082;
         proxy_ssl_session_reuse off;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
-        proxy_pass  127.0.0.1:%%PORT_2%%;
+        listen      127.0.0.1:8081;
+        proxy_pass  127.0.0.1:8082;
     }
 }
 
@@ -55,7 +55,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_2%% ssl;
+        listen       127.0.0.1:8082 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
@@ -95,11 +95,11 @@ foreach my $name ('localhost') {
 ###############################################################################
 
 like(http_get('/'), qr/200 OK.*X-Session: \./s, 'ssl');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(1))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8081))),
 	qr/200 OK.*X-Session: \./s, 'ssl 2');
 
 like(http_get('/'), qr/200 OK.*X-Session: \./s, 'ssl reuse session');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(1))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8081))),
 	qr/200 OK.*X-Session: r/s, 'ssl reuse session 2');
 
 my $s = http('', start => 1);
--- a/stream_proxy_ssl_certificate.t
+++ b/stream_proxy_ssl_certificate.t
@@ -40,24 +40,24 @@ stream {
     proxy_ssl_session_reuse off;
 
     server {
-        listen      127.0.0.1:%%PORT_2%%;
-        proxy_pass  127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8082;
+        proxy_pass  127.0.0.1:8080;
 
         proxy_ssl_certificate 1.example.com.crt;
         proxy_ssl_certificate_key 1.example.com.key;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3%%;
-        proxy_pass  127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8083;
+        proxy_pass  127.0.0.1:8080;
 
         proxy_ssl_certificate 2.example.com.crt;
         proxy_ssl_certificate_key 2.example.com.key;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_4%%;
-        proxy_pass  127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8084;
+        proxy_pass  127.0.0.1:8081;
 
         proxy_ssl_certificate 3.example.com.crt;
         proxy_ssl_certificate_key 3.example.com.key;
@@ -69,7 +69,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%% ssl;
+        listen       127.0.0.1:8080 ssl;
         server_name  localhost;
 
         ssl_certificate 2.example.com.crt;
@@ -85,7 +85,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%% ssl;
+        listen       127.0.0.1:8081 ssl;
         server_name  localhost;
 
         ssl_certificate 1.example.com.crt;
@@ -139,16 +139,16 @@ foreach my $name ('3.example.com') {
 
 ###############################################################################
 
-like(http_get('/', socket => getconn('127.0.0.1:' . port(2))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8082))),
 	qr/X-Verify: SUCCESS/ms, 'verify certificate');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(3))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8083))),
 	qr/X-Verify: FAILED/ms, 'fail certificate');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(4))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8084))),
 	qr/X-Verify: SUCCESS/ms, 'with encrypted key');
 
-like(http_get('/', socket => getconn('127.0.0.1:' . port(2))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8082))),
 	qr!X-Name: /CN=1.example!, 'valid certificate');
-unlike(http_get('/', socket => getconn('127.0.0.1:' . port(3))),
+unlike(http_get('/', socket => getconn('127.0.0.1:' . port(8083))),
 	qr!X-Name: /CN=1.example!, 'invalid certificate');
 
 ###############################################################################
--- a/stream_proxy_ssl_name.t
+++ b/stream_proxy_ssl_name.t
@@ -40,41 +40,41 @@ stream {
     proxy_ssl_session_reuse off;
 
     upstream u {
-        server 127.0.0.1:%%PORT_5%%;
+        server 127.0.0.1:8085;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8080;
         proxy_pass  u;
 
         proxy_ssl_server_name off;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8081;
         proxy_pass  u;
 
         proxy_ssl_server_name on;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%%;
-        proxy_pass  127.0.0.1:%%PORT_5%%;
+        listen      127.0.0.1:8082;
+        proxy_pass  127.0.0.1:8085;
 
         proxy_ssl_server_name on;
         proxy_ssl_name example.com;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3%%;
-        proxy_pass  127.0.0.1:%%PORT_5%%;
+        listen      127.0.0.1:8083;
+        proxy_pass  127.0.0.1:8085;
 
         proxy_ssl_server_name on;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_4%%;
-        proxy_pass  127.0.0.1:%%PORT_5%%;
+        listen      127.0.0.1:8084;
+        proxy_pass  127.0.0.1:8085;
 
         proxy_ssl_server_name on;
         proxy_ssl_name example.com:123;
@@ -85,7 +85,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_5%% ssl;
+        listen       127.0.0.1:8085 ssl;
         server_name  localhost;
 
         ssl_certificate_key localhost.key;
@@ -124,13 +124,13 @@ foreach my $name ('localhost') {
 ###############################################################################
 
 like(http_get('/'), qr/200 OK.*X-Name: ,/s, 'no name');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(1))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8081))),
 	qr/200 OK.*X-Name: u,/s, 'name default');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(2))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8082))),
 	qr/200 OK.*X-Name: example.com,/s, 'name override');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(3))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8083))),
 	qr/200 OK.*X-Name: ,/s, 'no ip');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(4))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8084))),
 	qr/200 OK.*X-Name: example.com,/s, 'no port in name');
 
 ###############################################################################
--- a/stream_proxy_ssl_verify.t
+++ b/stream_proxy_ssl_verify.t
@@ -38,56 +38,56 @@ stream {
     proxy_ssl_verify on;
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
-        proxy_pass  127.0.0.1:%%PORT_6%%;
+        listen      127.0.0.1:8080;
+        proxy_pass  127.0.0.1:8086;
 
         proxy_ssl_name example.com;
         proxy_ssl_trusted_certificate 1.example.com.crt;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
-        proxy_pass  127.0.0.1:%%PORT_6%%;
+        listen      127.0.0.1:8081;
+        proxy_pass  127.0.0.1:8086;
 
         proxy_ssl_name foo.example.com;
         proxy_ssl_trusted_certificate 1.example.com.crt;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%%;
-        proxy_pass  127.0.0.1:%%PORT_6%%;
+        listen      127.0.0.1:8082;
+        proxy_pass  127.0.0.1:8086;
 
         proxy_ssl_name no.match.example.com;
         proxy_ssl_trusted_certificate 1.example.com.crt;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3%%;
-        proxy_pass  127.0.0.1:%%PORT_7%%;
+        listen      127.0.0.1:8083;
+        proxy_pass  127.0.0.1:8087;
 
         proxy_ssl_name 2.example.com;
         proxy_ssl_trusted_certificate 2.example.com.crt;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_4%%;
-        proxy_pass  127.0.0.1:%%PORT_7%%;
+        listen      127.0.0.1:8084;
+        proxy_pass  127.0.0.1:8087;
 
         proxy_ssl_name bad.example.com;
         proxy_ssl_trusted_certificate 2.example.com.crt;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_5%%;
-        proxy_pass  127.0.0.1:%%PORT_7%%;
+        listen      127.0.0.1:8085;
+        proxy_pass  127.0.0.1:8087;
 
         proxy_ssl_trusted_certificate 1.example.com.crt;
         proxy_ssl_session_reuse off;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_6%% ssl;
-        proxy_pass  127.0.0.1:%%PORT_8%%;
+        listen      127.0.0.1:8086 ssl;
+        proxy_pass  127.0.0.1:8088;
         proxy_ssl   off;
 
         ssl_certificate 1.example.com.crt;
@@ -95,8 +95,8 @@ stream {
     }
 
     server {
-        listen      127.0.0.1:%%PORT_7%% ssl;
-        proxy_pass  127.0.0.1:%%PORT_8%%;
+        listen      127.0.0.1:8087 ssl;
+        proxy_pass  127.0.0.1:8088;
         proxy_ssl   off;
 
         ssl_certificate 2.example.com.crt;
@@ -147,24 +147,24 @@ foreach my $name ('1.example.com', '2.ex
 $t->run_daemon(\&http_daemon);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(8));
+$t->waitforsocket('127.0.0.1:' . port(8088));
 
 ###############################################################################
 
 # subjectAltName
 
-like(get('/', '127.0.0.1:' . port(0)), qr/200 OK/, 'verify');
-like(get('/', '127.0.0.1:' . port(1)), qr/200 OK/, 'verify wildcard');
-unlike(get('/', '127.0.0.1:' . port(2)), qr/200 OK/, 'verify fail');
+like(get('/', '127.0.0.1:' . port(8080)), qr/200 OK/, 'verify');
+like(get('/', '127.0.0.1:' . port(8081)), qr/200 OK/, 'verify wildcard');
+unlike(get('/', '127.0.0.1:' . port(8082)), qr/200 OK/, 'verify fail');
 
 # commonName
 
-like(get('/', '127.0.0.1:' . port(3)), qr/200 OK/, 'verify cn');
-unlike(get('/', '127.0.0.1:' . port(4)), qr/200 OK/, 'verify cn fail');
+like(get('/', '127.0.0.1:' . port(8083)), qr/200 OK/, 'verify cn');
+unlike(get('/', '127.0.0.1:' . port(8084)), qr/200 OK/, 'verify cn fail');
 
 # untrusted
 
-unlike(get('/', '127.0.0.1:' . port(5)), qr/200 OK/, 'untrusted');
+unlike(get('/', '127.0.0.1:' . port(8085)), qr/200 OK/, 'untrusted');
 
 ###############################################################################
 
@@ -186,7 +186,7 @@ sub get {
 sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(8),
+		LocalHost => '127.0.0.1:' . port(8088),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_ssl.t
+++ b/stream_ssl.t
@@ -53,32 +53,32 @@ stream {
     ssl_password_file password_http;
 
     server {
-        listen      127.0.0.1:%%PORT_0%% ssl;
-        proxy_pass  127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8080 ssl;
+        proxy_pass  127.0.0.1:8081;
 
         ssl_session_cache builtin;
         ssl_password_file password;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%% ssl;
-        proxy_pass  127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8082 ssl;
+        proxy_pass  127.0.0.1:8081;
 
         ssl_session_cache off;
         ssl_password_file password_many;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3%% ssl;
-        proxy_pass  127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8083 ssl;
+        proxy_pass  127.0.0.1:8081;
 
         ssl_session_cache builtin:1000;
         ssl_password_file password_fifo;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_4%% ssl;
-        proxy_pass  127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8084 ssl;
+        proxy_pass  127.0.0.1:8081;
 
         ssl_session_cache shared:SSL:1m;
         ssl_certificate_key inherits.key;
@@ -123,48 +123,48 @@ fork() || exec("echo localhost > $d/pass
 $t->run_daemon(\&http_daemon);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
+$t->waitforsocket('127.0.0.1:' . port(8081));
 
 ###############################################################################
 
 my ($s, $ssl, $ses);
 
-($s, $ssl) = get_ssl_socket(port(0));
+($s, $ssl) = get_ssl_socket(port(8080));
 Net::SSLeay::write($ssl, "GET / HTTP/1.0$CRLF$CRLF");
 like(Net::SSLeay::read($ssl), qr/200 OK/, 'ssl');
 
 # ssl_session_cache
 
-($s, $ssl) = get_ssl_socket(port(0));
+($s, $ssl) = get_ssl_socket(port(8080));
 $ses = Net::SSLeay::get_session($ssl);
 
-($s, $ssl) = get_ssl_socket(port(0), $ses);
+($s, $ssl) = get_ssl_socket(port(8080), $ses);
 is(Net::SSLeay::session_reused($ssl), 1, 'builtin session reused');
 
-($s, $ssl) = get_ssl_socket(port(2));
+($s, $ssl) = get_ssl_socket(port(8082));
 $ses = Net::SSLeay::get_session($ssl);
 
-($s, $ssl) = get_ssl_socket(port(2), $ses);
+($s, $ssl) = get_ssl_socket(port(8082), $ses);
 isnt(Net::SSLeay::session_reused($ssl), 1, 'session not reused');
 
-($s, $ssl) = get_ssl_socket(port(3));
+($s, $ssl) = get_ssl_socket(port(8083));
 $ses = Net::SSLeay::get_session($ssl);
 
-($s, $ssl) = get_ssl_socket(port(3), $ses);
+($s, $ssl) = get_ssl_socket(port(8083), $ses);
 is(Net::SSLeay::session_reused($ssl), 1, 'builtin size session reused');
 
-($s, $ssl) = get_ssl_socket(port(4));
+($s, $ssl) = get_ssl_socket(port(8084));
 $ses = Net::SSLeay::get_session($ssl);
 
-($s, $ssl) = get_ssl_socket(port(4), $ses);
+($s, $ssl) = get_ssl_socket(port(8084), $ses);
 is(Net::SSLeay::session_reused($ssl), 1, 'shared session reused');
 
 # ssl_certificate inheritance
 
-($s, $ssl) = get_ssl_socket(port(0));
+($s, $ssl) = get_ssl_socket(port(8080));
 like(Net::SSLeay::dump_peer_certificate($ssl), qr/CN=localhost/, 'CN');
 
-($s, $ssl) = get_ssl_socket(port(4));
+($s, $ssl) = get_ssl_socket(port(8084));
 like(Net::SSLeay::dump_peer_certificate($ssl), qr/CN=inherits/, 'CN inner');
 
 ###############################################################################
@@ -191,7 +191,7 @@ sub get_ssl_socket {
 sub http_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalHost => '127.0.0.1:' . port(1),
+		LocalHost => '127.0.0.1:' . port(8081),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_ssl_variables.t
+++ b/stream_ssl_variables.t
@@ -57,15 +57,15 @@ stream {
     ssl_certificate localhost.crt;
 
     server {
-        listen  127.0.0.1:%%PORT_0%%;
-        listen  127.0.0.1:%%PORT_1%% ssl;
+        listen  127.0.0.1:8080;
+        listen  127.0.0.1:8081 ssl;
         return  $ssl_session_reused:$ssl_session_id:$ssl_cipher:$ssl_protocol;
 
         ssl_session_cache builtin;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_2%% ssl;
+        listen  127.0.0.1:8082 ssl;
         return  $ssl_server_name;
     }
 }
@@ -98,19 +98,19 @@ my ($s, $ssl);
 
 is(stream()->read(), ':::', 'no ssl');
 
-($s, $ssl) = get_ssl_socket(port(1));
+($s, $ssl) = get_ssl_socket(port(8081));
 like(Net::SSLeay::read($ssl), qr/^\.:(\w{64})?:[\w-]+:(TLS|SSL)v(\d|\.)+$/,
 	'ssl variables');
 
 my $ses = Net::SSLeay::get_session($ssl);
-($s, $ssl) = get_ssl_socket(port(1), $ses);
+($s, $ssl) = get_ssl_socket(port(8081), $ses);
 like(Net::SSLeay::read($ssl), qr/^r:\w{64}:[\w-]+:(TLS|SSL)v(\d|\.)+$/,
 	'ssl variables - session reused');
 
-($s, $ssl) = get_ssl_socket(port(2), undef, 'example.com');
+($s, $ssl) = get_ssl_socket(port(8082), undef, 'example.com');
 is(Net::SSLeay::ssl_read_all($ssl), 'example.com', 'ssl server name');
 
-($s, $ssl) = get_ssl_socket(port(2));
+($s, $ssl) = get_ssl_socket(port(8082));
 is(Net::SSLeay::ssl_read_all($ssl), '', 'ssl server name empty');
 
 ###############################################################################
--- a/stream_tcp_nodelay.t
+++ b/stream_tcp_nodelay.t
@@ -44,30 +44,30 @@ stream {
     tcp_nodelay off;
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
-        proxy_pass  127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8081;
+        proxy_pass  127.0.0.1:8080;
     }
 
     server {
         tcp_nodelay on;
-        listen      127.0.0.1:%%PORT_2%%;
-        proxy_pass  127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8082;
+        proxy_pass  127.0.0.1:8080;
     }
 }
 
 EOF
 
 $t->run_daemon(\&stream_daemon);
-$t->run()->waitforsocket('127.0.0.1:' . port(0));
+$t->run()->waitforsocket('127.0.0.1:' . port(8080));
 
 ###############################################################################
 
 my $str = '1234567890' x 10 . 'F';
 my $length = length($str);
 
-is(stream('127.0.0.1:' . port(1))->io($str, length => $length), $str,
+is(stream('127.0.0.1:' . port(8081))->io($str, length => $length), $str,
 	'tcp_nodelay off');
-is(stream('127.0.0.1:' . port(2))->io($str, length => $length), $str,
+is(stream('127.0.0.1:' . port(8082))->io($str, length => $length), $str,
 	'tcp_nodelay on');
 
 ###############################################################################
@@ -75,7 +75,7 @@ is(stream('127.0.0.1:' . port(2))->io($s
 sub stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:' . port(0),
+		LocalAddr => '127.0.0.1:' . port(8080),
 		Listen => 5,
 		Reuse => 1
 	)
--- a/stream_udp_limit_conn.t
+++ b/stream_udp_limit_conn.t
@@ -41,34 +41,34 @@ stream {
     proxy_timeout    1s;
 
     server {
-        listen           127.0.0.1:%%PORT_1_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_0_UDP%%;
+        listen           127.0.0.1:%%PORT_8081_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8080_UDP%%;
 
         limit_conn       zone 1;
         proxy_responses  2;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_2_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_0_UDP%%;
+        listen           127.0.0.1:%%PORT_8082_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8080_UDP%%;
         limit_conn       zone2 1;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_3_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_0_UDP%%;
+        listen           127.0.0.1:%%PORT_8083_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8080_UDP%%;
         limit_conn       zone 5;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_4_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_1_UDP%%;
+        listen           127.0.0.1:%%PORT_8084_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8081_UDP%%;
         limit_conn       zone2 1;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_5_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_1_UDP%%;
+        listen           127.0.0.1:%%PORT_8085_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8081_UDP%%;
         limit_conn       zone 1;
     }
 }
@@ -77,13 +77,13 @@ EOF
 
 $t->try_run('no stream udp')->plan(9);
 $t->run_daemon(\&udp_daemon, $t);
-$t->waitforfile($t->testdir . '/' . port(0));
+$t->waitforfile($t->testdir . '/' . port(8080));
 
 ###############################################################################
 
 # same and other zones
 
-my $s = dgram('127.0.0.1:' . port(1));
+my $s = dgram('127.0.0.1:' . port(8081));
 
 is($s->io('1'), '1', 'passed');
 
@@ -91,21 +91,21 @@ is($s->io('1'), '1', 'passed');
 # in same socket will be treated as new connection
 
 is($s->io('1', read_timeout => 0.1), '', 'rejected new connection');
-is(dgram('127.0.0.1:' . port(1))->io('1', read_timeout => 0.1), '',
+is(dgram('127.0.0.1:' . port(8081))->io('1', read_timeout => 0.1), '',
 	'rejected same zone');
-is(dgram('127.0.0.1:' . port(2))->io('1'), '1', 'passed different zone');
-is(dgram('127.0.0.1:' . port(3))->io('1'), '1', 'passed same zone unlimited');
+is(dgram('127.0.0.1:' . port(8082))->io('1'), '1', 'passed different zone');
+is(dgram('127.0.0.1:' . port(8083))->io('1'), '1', 'passed same zone unlimited');
 
 sleep 1;	# waiting for proxy_timeout to expire
 
 is($s->io('2', read => 2), '12', 'new connection after proxy_timeout');
 
-is(dgram('127.0.0.1:' . port(1))->io('2', read => 2), '12', 'passed 2');
+is(dgram('127.0.0.1:' . port(8081))->io('2', read => 2), '12', 'passed 2');
 
 # zones proxy chain
 
-is(dgram('127.0.0.1:' . port(4))->io('1'), '1', 'passed proxy');
-is(dgram('127.0.0.1:' . port(5))->io('1', read_timeout => 0.1), '',
+is(dgram('127.0.0.1:' . port(8084))->io('1'), '1', 'passed proxy');
+is(dgram('127.0.0.1:' . port(8085))->io('1', read_timeout => 0.1), '',
 	'rejected proxy');
 
 ###############################################################################
@@ -115,14 +115,14 @@ sub udp_daemon {
 
 	my $server = IO::Socket::INET->new(
 		Proto => 'udp',
-		LocalAddr => '127.0.0.1:' . port(0),
+		LocalAddr => '127.0.0.1:' . port(8080),
 		Reuse => 1,
 	)
 		or die "Can't create listening socket: $!\n";
 
 	# signal we are ready
 
-	open my $fh, '>', $t->testdir() . '/' . port(0);
+	open my $fh, '>', $t->testdir() . '/' . port(8080);
 	close $fh;
 
 	while (1) {
--- a/stream_udp_proxy.t
+++ b/stream_udp_proxy.t
@@ -36,43 +36,43 @@ stream {
     proxy_timeout        1s;
 
     server {
-        listen           127.0.0.1:%%PORT_0_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_1_UDP%%;
+        listen           127.0.0.1:%%PORT_8080_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8081_UDP%%;
 
         proxy_responses  0;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_2_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_1_UDP%%;
+        listen           127.0.0.1:%%PORT_8082_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8081_UDP%%;
 
         proxy_responses  2;
     }
 
     server {
-        listen           127.0.0.1:%%PORT_3_UDP%% udp;
-        proxy_pass       127.0.0.1:%%PORT_1_UDP%%;
+        listen           127.0.0.1:%%PORT_8083_UDP%% udp;
+        proxy_pass       127.0.0.1:%%PORT_8081_UDP%%;
     }
 }
 
 EOF
 
 
-$t->run_daemon(\&udp_daemon, port(1), $t);
+$t->run_daemon(\&udp_daemon, port(8081), $t);
 $t->try_run('no stream udp')->plan(5);
-$t->waitforfile($t->testdir . '/' . port(1));
+$t->waitforfile($t->testdir . '/' . port(8081));
 
 ###############################################################################
 
-my $s = dgram('127.0.0.1:' . port(0));
+my $s = dgram('127.0.0.1:' . port(8080));
 is($s->io('1', read => 1, read_timeout => 0.5), '', 'proxy responses 0');
 
-$s = dgram('127.0.0.1:' . port(2));
+$s = dgram('127.0.0.1:' . port(8082));
 is($s->io('1'), '1', 'proxy responses 1');
 is($s->io('2', read => 2), '12', 'proxy responses 2');
 is($s->io('3', read => 3, read_timeout => 0.5), '12', 'proxy responses 3');
 
-$s = dgram('127.0.0.1:' . port(3));
+$s = dgram('127.0.0.1:' . port(8083));
 is($s->io('3', read => 3), '123', 'proxy responses default');
 
 ###############################################################################
@@ -82,14 +82,14 @@ sub udp_daemon {
 
 	my $server = IO::Socket::INET->new(
 		Proto => 'udp',
-		LocalAddr => '127.0.0.1:' . port(1),
+		LocalAddr => '127.0.0.1:' . port(8081),
 		Reuse => 1,
 	)
 		or die "Can't create listening socket: $!\n";
 
 	# signal we are ready
 
-	open my $fh, '>', $t->testdir() . '/' . port(1);
+	open my $fh, '>', $t->testdir() . '/' . port(8081);
 	close $fh;
 
 	while (1) {
--- a/stream_udp_upstream.t
+++ b/stream_udp_upstream.t
@@ -38,65 +38,65 @@ stream {
     proxy_timeout        1s;
 
     upstream u {
-        server 127.0.0.1:%%PORT_4_UDP%%;
-        server 127.0.0.1:%%PORT_5_UDP%%;
+        server 127.0.0.1:%%PORT_8084_UDP%%;
+        server 127.0.0.1:%%PORT_8085_UDP%%;
     }
 
     upstream u2 {
-        server 127.0.0.1:%%PORT_6_UDP%% down;
-        server 127.0.0.1:%%PORT_6_UDP%%;
-        server 127.0.0.1:%%PORT_4_UDP%%;
-        server 127.0.0.1:%%PORT_5_UDP%%;
+        server 127.0.0.1:%%PORT_8086_UDP%% down;
+        server 127.0.0.1:%%PORT_8086_UDP%%;
+        server 127.0.0.1:%%PORT_8084_UDP%%;
+        server 127.0.0.1:%%PORT_8085_UDP%%;
     }
 
     upstream u3 {
-        server 127.0.0.1:%%PORT_4_UDP%%;
-        server 127.0.0.1:%%PORT_5_UDP%% weight=2;
+        server 127.0.0.1:%%PORT_8084_UDP%%;
+        server 127.0.0.1:%%PORT_8085_UDP%% weight=2;
     }
 
     upstream u4 {
-        server 127.0.0.1:%%PORT_6_UDP%%;
-        server 127.0.0.1:%%PORT_4_UDP%% backup;
+        server 127.0.0.1:%%PORT_8086_UDP%%;
+        server 127.0.0.1:%%PORT_8084_UDP%% backup;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0_UDP%% udp;
+        listen      127.0.0.1:%%PORT_8080_UDP%% udp;
         proxy_pass  u;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1_UDP%% udp;
+        listen      127.0.0.1:%%PORT_8081_UDP%% udp;
         proxy_pass  u2;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2_UDP%% udp;
+        listen      127.0.0.1:%%PORT_8082_UDP%% udp;
         proxy_pass  u3;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3_UDP%% udp;
+        listen      127.0.0.1:%%PORT_8083_UDP%% udp;
         proxy_pass  u4;
     }
 }
 
 EOF
 
-$t->run_daemon(\&udp_daemon, port(4), $t);
-$t->run_daemon(\&udp_daemon, port(5), $t);
+$t->run_daemon(\&udp_daemon, port(8084), $t);
+$t->run_daemon(\&udp_daemon, port(8085), $t);
 $t->try_run('no stream udp')->plan(4);
 
-$t->waitforfile($t->testdir . '/' . port(4));
-$t->waitforfile($t->testdir . '/' . port(5));
+$t->waitforfile($t->testdir . '/' . port(8084));
+$t->waitforfile($t->testdir . '/' . port(8085));
 
 ###############################################################################
 
-my @ports = my ($port4, $port5) = (port(4), port(5));
+my @ports = my ($port4, $port5) = (port(8084), port(8085));
 
-is(many(30, port(0)), "$port4: 15, $port5: 15", 'balanced');
-is(many(30, port(1)), "$port4: 15, $port5: 15", 'failures');
-is(many(30, port(2)), "$port4: 10, $port5: 20", 'weight');
-is(many(30, port(3)), "$port4: 30", 'backup');
+is(many(30, port(8080)), "$port4: 15, $port5: 15", 'balanced');
+is(many(30, port(8081)), "$port4: 15, $port5: 15", 'failures');
+is(many(30, port(8082)), "$port4: 10, $port5: 20", 'weight');
+is(many(30, port(8083)), "$port4: 30", 'backup');
 
 ###############################################################################
 
--- a/stream_udp_upstream_hash.t
+++ b/stream_udp_upstream_hash.t
@@ -40,42 +40,42 @@ stream {
 
     upstream hash {
         hash $remote_addr;
-        server 127.0.0.1:%%PORT_2_UDP%%;
-        server 127.0.0.1:%%PORT_3_UDP%%;
+        server 127.0.0.1:%%PORT_8082_UDP%%;
+        server 127.0.0.1:%%PORT_8083_UDP%%;
     }
 
     upstream cons {
         hash $remote_addr consistent;
-        server 127.0.0.1:%%PORT_2_UDP%%;
-        server 127.0.0.1:%%PORT_3_UDP%%;
+        server 127.0.0.1:%%PORT_8082_UDP%%;
+        server 127.0.0.1:%%PORT_8083_UDP%%;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0_UDP%% udp;
+        listen      127.0.0.1:%%PORT_8080_UDP%% udp;
         proxy_pass  hash;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1_UDP%% udp;
+        listen      127.0.0.1:%%PORT_8081_UDP%% udp;
         proxy_pass  cons;
     }
 }
 
 EOF
 
-$t->run_daemon(\&udp_daemon, port(2), $t);
-$t->run_daemon(\&udp_daemon, port(3), $t);
+$t->run_daemon(\&udp_daemon, port(8082), $t);
+$t->run_daemon(\&udp_daemon, port(8083), $t);
 $t->try_run('no stream udp')->plan(2);
 
-$t->waitforfile($t->testdir . '/' . port(2));
-$t->waitforfile($t->testdir . '/' . port(3));
+$t->waitforfile($t->testdir . '/' . port(8082));
+$t->waitforfile($t->testdir . '/' . port(8083));
 
 ###############################################################################
 
-my @ports = my ($port2, $port3) = (port(2), port(3));
+my @ports = my ($port2, $port3) = (port(8082), port(8083));
 
-is(many(10, port(0)), "$port3: 10", 'hash');
-like(many(10, port(1)), qr/($port2|$port3): 10/, 'hash consistent');
+is(many(10, port(8080)), "$port3: 10", 'hash');
+like(many(10, port(8081)), qr/($port2|$port3): 10/, 'hash consistent');
 
 ###############################################################################
 
--- a/stream_udp_upstream_least_conn.t
+++ b/stream_udp_upstream_least_conn.t
@@ -39,28 +39,28 @@ stream {
 
     upstream u {
         least_conn;
-        server 127.0.0.1:%%PORT_1_UDP%%;
-        server 127.0.0.1:%%PORT_2_UDP%%;
+        server 127.0.0.1:%%PORT_8081_UDP%%;
+        server 127.0.0.1:%%PORT_8082_UDP%%;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0_UDP%% udp;
+        listen      127.0.0.1:%%PORT_8080_UDP%% udp;
         proxy_pass  u;
     }
 }
 
 EOF
 
-$t->run_daemon(\&udp_daemon, port(1), $t);
-$t->run_daemon(\&udp_daemon, port(2), $t);
+$t->run_daemon(\&udp_daemon, port(8081), $t);
+$t->run_daemon(\&udp_daemon, port(8082), $t);
 $t->try_run('no stream udp')->plan(2);
 
-$t->waitforfile($t->testdir . '/' . port(1));
-$t->waitforfile($t->testdir . '/' . port(2));
+$t->waitforfile($t->testdir . '/' . port(8081));
+$t->waitforfile($t->testdir . '/' . port(8082));
 
 ###############################################################################
 
-my @ports = my ($port1, $port2) = (port(1), port(2));
+my @ports = my ($port1, $port2) = (port(8081), port(8082));
 
 is(many(10), "$port1: 5, $port2: 5", 'balanced');
 
@@ -114,7 +114,7 @@ sub udp_daemon {
 
 		my $port = $server->sockport();
 
-		if ($buffer =~ /w/ && $port == port(1)) {
+		if ($buffer =~ /w/ && $port == port(8081)) {
 			select undef, undef, undef, 2.5;
 		}
 
--- a/stream_unix.t
+++ b/stream_unix.t
@@ -43,12 +43,12 @@ stream {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         proxy_pass   unix:%%TESTDIR%%/unix.sock;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         proxy_pass   u;
     }
 }
@@ -71,8 +71,8 @@ for (1 .. 50) {
 
 my $str = 'SEE-THIS';
 
-is(stream('127.0.0.1:' . port(0))->io($str), $str, 'proxy');
-is(stream('127.0.0.1:' . port(1))->io($str), $str, 'upstream');
+is(stream('127.0.0.1:' . port(8080))->io($str), $str, 'proxy');
+is(stream('127.0.0.1:' . port(8081))->io($str), $str, 'upstream');
 
 ###############################################################################
 
--- a/stream_upstream.t
+++ b/stream_upstream.t
@@ -37,67 +37,67 @@ events {
 
 stream {
     upstream u {
-        server 127.0.0.1:%%PORT_4%%;
-        server 127.0.0.1:%%PORT_5%%;
+        server 127.0.0.1:8084;
+        server 127.0.0.1:8085;
     }
 
     upstream u2 {
-        server 127.0.0.1:%%PORT_6%% down;
-        server 127.0.0.1:%%PORT_6%%;
-        server 127.0.0.1:%%PORT_4%%;
-        server 127.0.0.1:%%PORT_5%%;
+        server 127.0.0.1:8086 down;
+        server 127.0.0.1:8086;
+        server 127.0.0.1:8084;
+        server 127.0.0.1:8085;
     }
 
     upstream u3 {
-        server 127.0.0.1:%%PORT_4%%;
-        server 127.0.0.1:%%PORT_5%% weight=2;
+        server 127.0.0.1:8084;
+        server 127.0.0.1:8085 weight=2;
     }
 
     upstream u4 {
-        server 127.0.0.1:%%PORT_6%%;
-        server 127.0.0.1:%%PORT_4%% backup;
+        server 127.0.0.1:8086;
+        server 127.0.0.1:8084 backup;
     }
 
     proxy_connect_timeout 1s;
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8080;
         proxy_pass  u;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8081;
         proxy_pass  u2;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%%;
+        listen      127.0.0.1:8082;
         proxy_pass  u3;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3%%;
+        listen      127.0.0.1:8083;
         proxy_pass  u4;
     }
 }
 
 EOF
 
-$t->run_daemon(\&stream_daemon, port(4));
-$t->run_daemon(\&stream_daemon, port(5));
+$t->run_daemon(\&stream_daemon, port(8084));
+$t->run_daemon(\&stream_daemon, port(8085));
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(4));
-$t->waitforsocket('127.0.0.1:' . port(5));
+$t->waitforsocket('127.0.0.1:' . port(8084));
+$t->waitforsocket('127.0.0.1:' . port(8085));
 
 ###############################################################################
 
-my @ports = my ($port4, $port5) = (port(4), port(5));
+my @ports = my ($port4, $port5) = (port(8084), port(8085));
 
-is(many(30, port(0)), "$port4: 15, $port5: 15", 'balanced');
-is(many(30, port(1)), "$port4: 15, $port5: 15", 'failures');
-is(many(30, port(2)), "$port4: 10, $port5: 20", 'weight');
-is(many(30, port(3)), "$port4: 30", 'backup');
+is(many(30, port(8080)), "$port4: 15, $port5: 15", 'balanced');
+is(many(30, port(8081)), "$port4: 15, $port5: 15", 'failures');
+is(many(30, port(8082)), "$port4: 10, $port5: 20", 'weight');
+is(many(30, port(8083)), "$port4: 30", 'backup');
 
 ###############################################################################
 
--- a/stream_upstream_hash.t
+++ b/stream_upstream_hash.t
@@ -39,42 +39,42 @@ events {
 stream {
     upstream hash {
         hash $remote_addr;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083;
     }
 
     upstream cons {
         hash $remote_addr consistent;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8080;
         proxy_pass  hash;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8081;
         proxy_pass  cons;
     }
 }
 
 EOF
 
-$t->run_daemon(\&stream_daemon, port(2));
-$t->run_daemon(\&stream_daemon, port(3));
+$t->run_daemon(\&stream_daemon, port(8082));
+$t->run_daemon(\&stream_daemon, port(8083));
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(2));
-$t->waitforsocket('127.0.0.1:' . port(3));
+$t->waitforsocket('127.0.0.1:' . port(8082));
+$t->waitforsocket('127.0.0.1:' . port(8083));
 
 ###############################################################################
 
-my @ports = my ($port2, $port3) = (port(2), port(3));
+my @ports = my ($port2, $port3) = (port(8082), port(8083));
 
-is(many(10, port(0)), "$port3: 10", 'hash');
-like(many(10, port(1)), qr/($port2|$port3): 10/, 'hash consistent');
+is(many(10, port(8080)), "$port3: 10", 'hash');
+like(many(10, port(8081)), qr/($port2|$port3): 10/, 'hash consistent');
 
 ###############################################################################
 
--- a/stream_upstream_least_conn.t
+++ b/stream_upstream_least_conn.t
@@ -38,28 +38,28 @@ events {
 stream {
     upstream u {
         least_conn;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8080;
         proxy_pass  u;
     }
 }
 
 EOF
 
-$t->run_daemon(\&stream_daemon, port(1));
-$t->run_daemon(\&stream_daemon, port(2));
+$t->run_daemon(\&stream_daemon, port(8081));
+$t->run_daemon(\&stream_daemon, port(8082));
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
-$t->waitforsocket('127.0.0.1:' . port(2));
+$t->waitforsocket('127.0.0.1:' . port(8081));
+$t->waitforsocket('127.0.0.1:' . port(8082));
 
 ###############################################################################
 
-my @ports = my ($port1, $port2) = (port(1), port(2));
+my @ports = my ($port1, $port2) = (port(8081), port(8082));
 
 is(many(10), "$port1: 5, $port2: 5", 'balanced');
 
@@ -135,7 +135,7 @@ sub stream_handle_client {
 
 	my $port = $client->sockport();
 
-	if ($buffer =~ /w/ && $port == port(1)) {
+	if ($buffer =~ /w/ && $port == port(8081)) {
 		Test::Nginx::log_core('||', "$port: sleep(2.5)");
 		select undef, undef, undef, 2.5;
 	}
--- a/stream_upstream_zone_ssl.t
+++ b/stream_upstream_zone_ssl.t
@@ -40,34 +40,34 @@ stream {
 
     upstream u {
         zone u 32k;
-        server 127.0.0.1:%%PORT_4%%;
+        server 127.0.0.1:8084;
     }
 
     upstream u2 {
         zone u2 32k;
-        server 127.0.0.1:%%PORT_4%% backup;
-        server 127.0.0.1:%%PORT_5%% down;
+        server 127.0.0.1:8084 backup;
+        server 127.0.0.1:8085 down;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_0%%;
+        listen      127.0.0.1:8080;
         proxy_pass  u;
         proxy_ssl_session_reuse off;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_1%%;
+        listen      127.0.0.1:8081;
         proxy_pass  u;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_2%%;
+        listen      127.0.0.1:8082;
         proxy_pass  u2;
         proxy_ssl_session_reuse off;
     }
 
     server {
-        listen      127.0.0.1:%%PORT_3%%;
+        listen      127.0.0.1:8083;
         proxy_pass  u2;
     }
 }
@@ -76,7 +76,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen 127.0.0.1:%%PORT_4%% ssl;
+        listen 127.0.0.1:8084 ssl;
 
         ssl_certificate_key localhost.key;
         ssl_certificate localhost.crt;
@@ -115,21 +115,21 @@ foreach my $name ('localhost') {
 ###############################################################################
 
 like(http_get('/'), qr/200 OK.*X-Session: \./s, 'ssl');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(1))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8081))),
 	qr/200 OK.*X-Session: \./s, 'ssl 2');
 
 like(http_get('/'), qr/200 OK.*X-Session: \./s, 'ssl reuse session');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(1))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8081))),
 	qr/200 OK.*X-Session: r/s, 'ssl reuse session 2');
 
-like(http_get('/', socket => getconn('127.0.0.1:' . port(2))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8082))),
 	qr/200 OK.*X-Session: \./s, 'ssl backup');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(3))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8083))),
 	qr/200 OK.*X-Session: \./s, 'ssl backup 2');
 
-like(http_get('/', socket => getconn('127.0.0.1:' . port(2))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8082))),
 	qr/200 OK.*X-Session: \./s, 'ssl reuse session backup');
-like(http_get('/', socket => getconn('127.0.0.1:' . port(3))),
+like(http_get('/', socket => getconn('127.0.0.1:' . port(8083))),
 	qr/200 OK.*X-Session: r/s, 'ssl reuse session backup 2');
 
 ###############################################################################
--- a/stream_variables.t
+++ b/stream_variables.t
@@ -36,34 +36,34 @@ events {
 
 stream {
     server {
-        listen  127.0.0.1:%%PORT_0%%;
+        listen  127.0.0.1:8080;
         return  $connection:$nginx_version:$hostname:$pid:$bytes_sent;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_1%%;
-        listen  [::1]:%%PORT_1%%;
+        listen  127.0.0.1:8081;
+        listen  [::1]:%%PORT_8081%%;
         return  $remote_addr:$remote_port:$server_addr:$server_port;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_2%%;
-        proxy_pass  [::1]:%%PORT_1%%;
+        listen  127.0.0.1:8082;
+        proxy_pass  [::1]:%%PORT_8081%%;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_3%%;
-        listen  [::1]:%%PORT_3%%;
+        listen  127.0.0.1:8083;
+        listen  [::1]:%%PORT_8083%%;
         return  $binary_remote_addr;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_4%%;
-        proxy_pass  [::1]:%%PORT_3%%;
+        listen  127.0.0.1:8084;
+        proxy_pass  [::1]:%%PORT_8083%%;
     }
 
     server {
-        listen  127.0.0.1:%%PORT_5%%;
+        listen  127.0.0.1:8085;
         return  $msec!$time_local!$time_iso8601;
     }
 }
@@ -77,21 +77,21 @@ EOF
 chomp(my $hostname = lc `hostname`);
 like(stream()->read(), qr/^\d+:[\d.]+:$hostname:\d+:0$/, 'vars');
 
-my $dport = port(1);
+my $dport = port(8081);
 my $s = stream("127.0.0.1:$dport");
 my $lport = $s->sockport();
 is($s->read(), "127.0.0.1:$lport:127.0.0.1:$dport", 'addr');
 
-my $data = stream('127.0.0.1:' . port(2))->read();
+my $data = stream('127.0.0.1:' . port(8082))->read();
 like($data, qr/^::1:\d+:::1:\d+$/, 'addr ipv6');
 
-$data = stream('127.0.0.1:' . port(3))->read();
+$data = stream('127.0.0.1:' . port(8083))->read();
 is(unpack("H*", $data), '7f000001', 'binary addr');
 
-$data = stream('127.0.0.1:' . port(4))->read();
+$data = stream('127.0.0.1:' . port(8084))->read();
 is(unpack("H*", $data), '0' x 31 . '1', 'binary addr ipv6');
 
-$data = stream('127.0.0.1:' . port(5))->read();
+$data = stream('127.0.0.1:' . port(8085))->read();
 like($data, qr#^\d+.\d+![-+\w/: ]+![-+\dT:]+$#, 'time');
 
 ###############################################################################
--- a/stub_status.t
+++ b/stub_status.t
@@ -37,7 +37,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header X-Active $connections_active;
--- a/sub_filter.t
+++ b/sub_filter.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         sub_filter_types *;
@@ -91,12 +91,12 @@ http {
 
         location /lm {
             sub_filter_last_modified on;
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
         server_name  localhost;
     }
 }
--- a/sub_filter_merge.t
+++ b/sub_filter_merge.t
@@ -42,7 +42,7 @@ http {
     sub_filter foo bar;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / { }
--- a/sub_filter_multi.t
+++ b/sub_filter_multi.t
@@ -39,7 +39,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         sub_filter_types *;
@@ -198,7 +198,7 @@ http {
             sub_filter_once off;
             sub_filter abpatternyz +;
 
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_buffering off;
         }
 
@@ -207,7 +207,7 @@ http {
             sub_filter abpatternyz +;
             sub_filter abpaernyz -;
 
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_buffering off;
         }
 
@@ -217,7 +217,7 @@ http {
             sub_filter abpaernyz -;
             sub_filter _ *;
 
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_buffering off;
         }
 
@@ -225,7 +225,7 @@ http {
             sub_filter_once off;
             sub_filter patt +;
 
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_buffering off;
         }
 
@@ -235,13 +235,13 @@ http {
             sub_filter abpa -;
             sub_filter tter *;
 
-            proxy_pass http://127.0.0.1:%%PORT_1%%/;
+            proxy_pass http://127.0.0.1:8081/;
             proxy_buffering off;
         }
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
+        listen       127.0.0.1:8081;
 
         limit_rate 4;
         limit_rate_after 160;
--- a/sub_filter_multi2.t
+++ b/sub_filter_multi2.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         sub_filter_types *;
--- a/sub_filter_perl.t
+++ b/sub_filter_perl.t
@@ -35,7 +35,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         sub_filter_types *;
--- a/sub_filter_ssi.t
+++ b/sub_filter_ssi.t
@@ -40,7 +40,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
--- a/syslog.t
+++ b/syslog.t
@@ -30,7 +30,7 @@ my $t = Test::Nginx->new()->has(qw/http 
 
 %%TEST_GLOBALS%%
 
-error_log syslog:server=127.0.0.1:%%PORT_1_UDP%% info;
+error_log syslog:server=127.0.0.1:%%PORT_8081_UDP%% info;
 error_log %%TESTDIR%%/f_glob.log info;
 
 daemon off;
@@ -46,102 +46,102 @@ http {
     log_format empty "";
     log_format logf "$uri:$status";
 
-    error_log syslog:server=127.0.0.1:%%PORT_2_UDP%% info;
+    error_log syslog:server=127.0.0.1:%%PORT_8082_UDP%% info;
     error_log %%TESTDIR%%/f_http.log info;
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /e {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /a {
-            access_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /ef {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%,facility=user;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,facility=user;
         }
         location /es {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%,severity=alert;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,severity=alert;
         }
         location /et {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%,tag=SEETHIS;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,tag=SEETHIS;
         }
         location /af {
-            access_log syslog:server=127.0.0.1:%%PORT_4_UDP%%,facility=user;
+            access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,facility=user;
         }
         location /as {
             # put severity inside to catch possible parsing programming errors
-            access_log syslog:severity=alert,server=127.0.0.1:%%PORT_4_UDP%%;
+            access_log syslog:severity=alert,server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /at {
-            access_log syslog:server=127.0.0.1:%%PORT_4_UDP%%,tag=SEETHIS;
+            access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,tag=SEETHIS;
         }
         location /e2 {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /a2 {
-            access_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
-            access_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
+            access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /a_logf {
-            access_log syslog:server=127.0.0.1:%%PORT_4_UDP%% logf;
+            access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% logf;
         }
         location /if {
-            access_log syslog:server=127.0.0.1:%%PORT_3_UDP%% logf
+            access_log syslog:server=127.0.0.1:%%PORT_8083_UDP%% logf
                 if=$arg_logme;
         }
 
         location /nohostname {
-            access_log syslog:server=127.0.0.1:%%PORT_4_UDP%%,nohostname;
+            access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,nohostname;
         }
 
         location /debug {
             limit_req zone=one;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%% debug;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% debug;
         }
         location /info {
             limit_req zone=one;
             limit_req_log_level info;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%% info;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% info;
         }
         location /notice {
             limit_req zone=one;
             limit_req_log_level notice;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%% notice;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% notice;
         }
         location /warn {
             limit_req zone=one;
             limit_req_log_level warn;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%% warn;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% warn;
         }
         location /error {
             limit_req zone=one;
             limit_req_log_level error;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /low {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%% warn;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% warn;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /dup {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
         location /high {
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%% emerg;
-            error_log syslog:server=127.0.0.1:%%PORT_4_UDP%%;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% emerg;
+            error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%;
         }
     }
 }
 
 EOF
 
-$t->run_daemon(\&syslog_daemon, port(1), $t, 's_glob.log');
-$t->run_daemon(\&syslog_daemon, port(2), $t, 's_http.log');
-$t->run_daemon(\&syslog_daemon, port(3), $t, 's_if.log');
+$t->run_daemon(\&syslog_daemon, port(8081), $t, 's_glob.log');
+$t->run_daemon(\&syslog_daemon, port(8082), $t, 's_http.log');
+$t->run_daemon(\&syslog_daemon, port(8083), $t, 's_if.log');
 
 $t->waitforfile($t->testdir . '/s_glob.log');
 $t->waitforfile($t->testdir . '/s_http.log');
@@ -251,7 +251,7 @@ sub get_syslog {
 		alarm(1);
 		$s = IO::Socket::INET->new(
 			Proto => 'udp',
-			LocalAddr => '127.0.0.1:' . port(4)
+			LocalAddr => '127.0.0.1:' . port(8084)
 		);
 		alarm(0);
 	};
--- a/upstream.t
+++ b/upstream.t
@@ -36,17 +36,17 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%% max_fails=3 fail_timeout=10s;
-        server 127.0.0.1:%%PORT_2%% max_fails=3 fail_timeout=10s;
+        server 127.0.0.1:8081 max_fails=3 fail_timeout=10s;
+        server 127.0.0.1:8082 max_fails=3 fail_timeout=10s;
     }
 
     upstream u2 {
-        server 127.0.0.1:%%PORT_1%% max_fails=3 fail_timeout=10s;
-        server 127.0.0.1:%%PORT_2%% max_fails=3 fail_timeout=10s;
+        server 127.0.0.1:8081 max_fails=3 fail_timeout=10s;
+        server 127.0.0.1:8082 max_fails=3 fail_timeout=10s;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -60,16 +60,16 @@ http {
 
 EOF
 
-$t->run_daemon(\&http_daemon, port(1));
-$t->run_daemon(\&http_daemon, port(2));
+$t->run_daemon(\&http_daemon, port(8081));
+$t->run_daemon(\&http_daemon, port(8082));
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
-$t->waitforsocket('127.0.0.1:' . port(2));
+$t->waitforsocket('127.0.0.1:' . port(8081));
+$t->waitforsocket('127.0.0.1:' . port(8082));
 
 ###############################################################################
 
-my @ports = my ($p1, $p2) = (port(1), port(2));
+my @ports = my ($p1, $p2) = (port(8081), port(8082));
 
 is(many('/', 30), "$p1: 15, $p2: 15", 'balanced');
 
@@ -140,7 +140,8 @@ sub http_daemon {
 
 		$uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
 
-		if ($uri =~ 'close' && $port == port(1) && $count++ % 3 == 0) {
+		if ($uri =~ 'close' && $port == port(8081) && $count++ % 3 == 0)
+		{
 			next;
 		}
 
--- a/upstream_hash.t
+++ b/upstream_hash.t
@@ -38,57 +38,57 @@ http {
 
     upstream u {
         hash $arg_a;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083;
     }
 
     upstream u2 {
         hash $arg_a;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8083;
     }
 
     upstream cw {
         hash $arg_a consistent;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%% weight=10;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083 weight=10;
     }
 
     upstream cw2 {
         hash $arg_a consistent;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_3%% weight=10;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8083 weight=10;
     }
 
     upstream c {
         hash $arg_a consistent;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083;
     }
 
     upstream c2 {
         hash $arg_a consistent;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8083;
     }
 
     upstream bad {
         hash $arg_a;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_4%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8084;
     }
 
     upstream cbad {
         hash $arg_a consistent;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_4%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8084;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -122,9 +122,9 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
-        listen       127.0.0.1:%%PORT_2%%;
-        listen       127.0.0.1:%%PORT_3%%;
+        listen       127.0.0.1:8081;
+        listen       127.0.0.1:8082;
+        listen       127.0.0.1:8083;
         server_name  localhost;
 
         add_header X-Port $server_port;
@@ -134,7 +134,7 @@ http {
         }
 
         location /502 {
-            if ($server_port = %%PORT_3%%) {
+            if ($server_port = %%PORT_8083%%) {
                 return 502;
             }
             return 204;
@@ -142,7 +142,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_4%%;
+        listen       127.0.0.1:8084;
         server_name  localhost;
         return 444;
     }
@@ -154,7 +154,7 @@ EOF
 
 ###############################################################################
 
-my ($p1, $p2, $p3) = (port(1), port(2), port(3));
+my ($p1, $p2, $p3) = (port(8081), port(8082), port(8083));
 
 # Only requests for absent peer are moved to other peers if hash is consistent.
 # Check this by comparing two upstreams with different number of peers.
--- a/upstream_hash_memcached.t
+++ b/upstream_hash_memcached.t
@@ -47,34 +47,34 @@ http {
 
     upstream memd {
         hash $arg_a;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083;
     }
 
     upstream memd_c {
         hash $arg_a consistent;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083;
     }
 
     upstream memd_w {
         hash $arg_a;
-        server 127.0.0.1:%%PORT_1%% weight=2;
-        server 127.0.0.1:%%PORT_2%% weight=3;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081 weight=2;
+        server 127.0.0.1:8082 weight=3;
+        server 127.0.0.1:8083;
     }
 
     upstream memd_cw {
         hash $arg_a consistent;
-        server 127.0.0.1:%%PORT_1%% weight=2;
-        server 127.0.0.1:%%PORT_2%% weight=3;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081 weight=2;
+        server 127.0.0.1:8082 weight=3;
+        server 127.0.0.1:8083;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         set $memcached_key $arg_a;
@@ -108,41 +108,41 @@ if ($memhelp =~ /-U/) {
 	push @memopts, '-U', '0';
 }
 
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(1), @memopts);
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(2), @memopts);
-$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(3), @memopts);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8081), @memopts);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8082), @memopts);
+$t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8083), @memopts);
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1)) or die "Can't start memcached";
-$t->waitforsocket('127.0.0.1:' . port(2)) or die "Can't start memcached";
-$t->waitforsocket('127.0.0.1:' . port(3)) or die "Can't start memcached";
+$t->waitforsocket('127.0.0.1:' . port(8081)) or die "Can't start memcached";
+$t->waitforsocket('127.0.0.1:' . port(8082)) or die "Can't start memcached";
+$t->waitforsocket('127.0.0.1:' . port(8083)) or die "Can't start memcached";
 
 ###############################################################################
 
-my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(1) ],
+my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8081) ],
 	connect_timeout => 1.0);
-my $memd2 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(2) ],
+my $memd2 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8082) ],
 	connect_timeout => 1.0);
-my $memd3 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(3) ],
+my $memd3 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8083) ],
 	connect_timeout => 1.0);
 
 for my $i (1 .. 20) {
-	$memd1->set($i, port(1)) or die "can't put value into memcached: $!";
-	$memd2->set($i, port(2)) or die "can't put value into memcached: $!";
-	$memd3->set($i, port(3)) or die "can't put value into memcached: $!";
+	$memd1->set($i, port(8081)) or die "can't put value into memcached: $!";
+	$memd2->set($i, port(8082)) or die "can't put value into memcached: $!";
+	$memd3->set($i, port(8083)) or die "can't put value into memcached: $!";
 }
 
 my $memd = new Cache::Memcached(servers => [
-	'127.0.0.1:' . port(1),
-	'127.0.0.1:' . port(2),
-	'127.0.0.1:' . port(3) ]);
+	'127.0.0.1:' . port(8081),
+	'127.0.0.1:' . port(8082),
+	'127.0.0.1:' . port(8083) ]);
 
 is_deeply(ngx('/'), mem($memd), 'cache::memcached');
 
 $memd = new Cache::Memcached::Fast({ ketama_points => 160, servers => [
-	'127.0.0.1:' . port(1),
-	'127.0.0.1:' . port(2),
-	'127.0.0.1:' . port(3)] });
+	'127.0.0.1:' . port(8081),
+	'127.0.0.1:' . port(8082),
+	'127.0.0.1:' . port(8083)] });
 
 TODO: {
 local $TODO = 'not yet' unless $Config{byteorder} =~ '1234'
@@ -153,16 +153,16 @@ is_deeply(ngx('/c'), mem($memd), 'cache:
 }
 
 $memd = new Cache::Memcached(servers => [
-	[ '127.0.0.1:' . port(1), 2 ],
-	[ '127.0.0.1:' . port(2), 3 ],
-	[ '127.0.0.1:' . port(3), 1 ]]);
+	[ '127.0.0.1:' . port(8081), 2 ],
+	[ '127.0.0.1:' . port(8082), 3 ],
+	[ '127.0.0.1:' . port(8083), 1 ]]);
 
 is_deeply(ngx('/w'), mem($memd), 'cache::memcached weight');
 
 $memd = new Cache::Memcached::Fast({ ketama_points => 160, servers => [
-	{ address => '127.0.0.1:' . port(1), weight => 2 },
-	{ address => '127.0.0.1:' . port(2), weight => 3 },
-	{ address => '127.0.0.1:' . port(3), weight => 1 }] });
+	{ address => '127.0.0.1:' . port(8081), weight => 2 },
+	{ address => '127.0.0.1:' . port(8082), weight => 3 },
+	{ address => '127.0.0.1:' . port(8083), weight => 1 }] });
 
 TODO: {
 local $TODO = 'not yet' unless $Config{byteorder} =~ '1234'
--- a/upstream_ip_hash.t
+++ b/upstream_ip_hash.t
@@ -38,19 +38,19 @@ http {
 
     upstream u {
         ip_hash;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
     }
 
     upstream u2 {
         ip_hash;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
-        server 127.0.0.1:%%PORT_3%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8083;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         set_real_ip_from 127.0.0.0/8;
@@ -65,9 +65,9 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_1%%;
-        listen       127.0.0.1:%%PORT_2%%;
-        listen       127.0.0.1:%%PORT_3%%;
+        listen       127.0.0.1:8081;
+        listen       127.0.0.1:8082;
+        listen       127.0.0.1:8083;
         server_name  localhost;
 
         location / {
@@ -86,7 +86,7 @@ plan(skip_all => 'no 127.0.0.1 on host')
 
 ###############################################################################
 
-my @ports = my ($port1, $port2, $port3) = (port(1), port(2), port(3));
+my @ports = my ($port1, $port2, $port3) = (port(8081), port(8082), port(8083));
 
 is(many('/', 30), "$port1: 15, $port2: 15", 'ip_hash');
 is(many('/u2', 30), "$port1: 10, $port2: 10, $port3: 10", 'ip_hash 3 peers');
--- a/upstream_least_conn.t
+++ b/upstream_least_conn.t
@@ -37,12 +37,12 @@ http {
 
     upstream u {
         least_conn;
-        server 127.0.0.1:%%PORT_1%%;
-        server 127.0.0.1:%%PORT_2%%;
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
@@ -53,16 +53,16 @@ http {
 
 EOF
 
-$t->run_daemon(\&http_daemon, port(1));
-$t->run_daemon(\&http_daemon, port(2));
+$t->run_daemon(\&http_daemon, port(8081));
+$t->run_daemon(\&http_daemon, port(8082));
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1));
-$t->waitforsocket('127.0.0.1:' . port(2));
+$t->waitforsocket('127.0.0.1:' . port(8081));
+$t->waitforsocket('127.0.0.1:' . port(8082));
 
 ###############################################################################
 
-my @ports = my ($port1, $port2) = (port(1), port(2));
+my @ports = my ($port1, $port2) = (port(8081), port(8082));
 
 is(many('/', 10), "$port1: 5, $port2: 5", 'balanced');
 
@@ -120,7 +120,7 @@ sub http_daemon {
 
 		$uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
 
-		if ($uri eq '/w' && $port == port(1)) {
+		if ($uri eq '/w' && $port == port(8081)) {
 			Test::Nginx::log_core('||', "$port: sleep(2.5)");
 			select undef, undef, undef, 2.5;
 		}
--- a/upstream_zone_ssl.t
+++ b/upstream_zone_ssl.t
@@ -37,17 +37,17 @@ http {
 
     upstream u {
         zone u 32k;
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     upstream u2 {
         zone u;
-        server 127.0.0.1:%%PORT_1%% backup;
-        server 127.0.0.1:%%PORT_2%% down;
+        server 127.0.0.1:8081 backup;
+        server 127.0.0.1:8082 down;
     }
 
     server {
-        listen 127.0.0.1:%%PORT_1%% ssl;
+        listen 127.0.0.1:8081 ssl;
 
         ssl_certificate_key localhost.key;
         ssl_certificate localhost.crt;
@@ -59,7 +59,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         proxy_ssl_session_reuse off;
--- a/userid.t
+++ b/userid.t
@@ -47,7 +47,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         add_header X-Got $uid_got;
--- a/uwsgi.t
+++ b/uwsgi.t
@@ -35,15 +35,15 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     upstream u {
-        server 127.0.0.1:%%PORT_1%%;
+        server 127.0.0.1:8081;
     }
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         location / {
-            uwsgi_pass 127.0.0.1:%%PORT_1%%;
+            uwsgi_pass 127.0.0.1:8081;
             uwsgi_param SERVER_PROTOCOL $server_protocol;
             uwsgi_param HTTP_X_BLAH "blah";
         }
@@ -73,13 +73,13 @@ if ($uwsgihelp !~ /--wsgi-file/) {
 	push @uwsgiopts, '--plugin', 'python';
 }
 
-$t->run_daemon('uwsgi', '--socket', '127.0.0.1:' . port(1), @uwsgiopts,
+$t->run_daemon('uwsgi', '--socket', '127.0.0.1:' . port(8081), @uwsgiopts,
 	'--wsgi-file', $t->testdir() . '/uwsgi_test_app.py',
 	'--logto', $t->testdir() . '/uwsgi_log');
 
 $t->run();
 
-$t->waitforsocket('127.0.0.1:' . port(1))
+$t->waitforsocket('127.0.0.1:' . port(8081))
 	or die "Can't start uwsgi";
 
 ###############################################################################
@@ -90,7 +90,7 @@ unlike(http_head('/head'), qr/SEE-THIS/,
 like(http_get_headers('/headers'), qr/SEE-THIS/,
 	'uwsgi request with many ignored headers');
 
-like(http_get('/var?b=127.0.0.1:' . port(1)), qr/SEE-THIS/,
+like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/,
 	'uwsgi with variables');
 like(http_get('/var?b=u'), qr/SEE-THIS/, 'uwsgi with variables to upstream');
 
--- a/xslt.t
+++ b/xslt.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         default_type text/xml;
--- a/xslt_params.t
+++ b/xslt_params.t
@@ -36,7 +36,7 @@ http {
     %%TEST_GLOBALS_HTTP%%
 
     server {
-        listen       127.0.0.1:%%PORT_0%%;
+        listen       127.0.0.1:8080;
         server_name  localhost;
 
         default_type text/xml;