Skip to content

Commit 41535e5

Browse files
authored
Merge pull request #23 from arvancloud/resty-master-1.19.4
Resty master 1.19.4
2 parents 66c7eed + fff2e44 commit 41535e5

File tree

117 files changed

+10478
-1910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+10478
-1910
lines changed

.travis.yml

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,53 @@ addons:
1717
- cpanminus
1818
- libgd-dev
1919

20+
linux-s390x: &linux-s390x
21+
os: linux
22+
arch: s390x
23+
dist: xenial
24+
compiler: gcc
25+
addons:
26+
apt:
27+
update: true
28+
packages:
29+
- axel
30+
- dos2unix
31+
- cpanminus
32+
- libgd-dev
33+
- libpcre3
34+
- libpcre3-dev
35+
- mercurial
36+
- libpq-dev
37+
install:
38+
- sudo cpanm --notest Test::Nginx IPC::Run3 > build.log 2>&1 || (cat build.log && exit 1)
39+
- if [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz || wget -P download-cache https://www.openssl.org/source/old/${OPENSSL_VER//[a-z]/}/openssl-$OPENSSL_VER.tar.gz; fi
40+
- tar zxf download-cache/openssl-$OPENSSL_VER.tar.gz
41+
- cd openssl-$OPENSSL_VER/
42+
- patch -p1 < ../patches/openssl-$OPENSSL_PATCH_VER-sess_set_get_cb_yield.patch
43+
- ./config no-threads shared enable-ssl3 enable-ssl3-method -g --prefix=$OPENSSL_PREFIX -DPURIFY > build.log 2>&1 || (cat build.log && exit 1)
44+
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
45+
- sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1)
46+
- cd ..
47+
- sudo ln -s /usr/bin/make /usr/bin/gmake
48+
script:
49+
- util/mirror-tarballs > build.log 2>&1 || (cat build.log && exit 1)
50+
- cd openresty-*
51+
- ./configure --prefix=$OPENRESTY_PREFIX --with-cc-opt="-I$PCRE_INC -I$OPENSSL_INC" --with-ld-opt="-L$PCRE_LIB -L$OPENSSL_LIB -Wl,-rpath,$PCRE_LIB:$OPENSSL_LIB" --with-pcre-jit --with-http_ssl_module --with-debug -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
52+
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
53+
- sudo make install > build.log 2>&1 || (cat build.log && exit 1)
54+
- cd ..
55+
- export PATH=$OPENRESTY_PREFIX/bin:$OPENRESTY_PREFIX/nginx/sbin:$PATH
56+
- nginx -V
57+
- ldd `which nginx`|grep -E 'luajit|ssl|pcre'
58+
2059
cache:
2160
directories:
2261
- download-cache
2362

2463
env:
2564
global:
26-
- VERSION=1.17.0.rc1
2765
- JOBS=3
28-
- PCRE_VER=8.41
66+
- PCRE_VER=8.44
2967
- PCRE_PREFIX=/opt/pcre
3068
- PCRE_LIB=$PCRE_PREFIX/lib
3169
- PCRE_INC=$PCRE_PREFIX/include
@@ -34,16 +72,23 @@ env:
3472
- OPENSSL_INC=$OPENSSL_PREFIX/include
3573
- OPENRESTY_PREFIX=/opt/openresty
3674
matrix:
37-
- OPENSSL_VER=1.0.2q OPENSSL_PATCH_VER=1.0.2h
38-
- OPENSSL_VER=1.1.0j OPENSSL_PATCH_VER=1.1.0d
39-
- OPENSSL_VER=1.1.1c OPENSSL_PATCH_VER=1.1.1c
40-
before_install:
41-
- sudo apt-get update
42-
- sudo apt-get install dos2unix curl perl
75+
- OPENSSL_VER=1.0.2u OPENSSL_PATCH_VER=1.0.2h
76+
- OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
77+
- OPENSSL_VER=1.1.1f OPENSSL_PATCH_VER=1.1.1f
78+
79+
jobs:
80+
include:
81+
- <<: *linux-s390x
82+
env: OPENSSL_VER=1.0.2u OPENSSL_PATCH_VER=1.0.2h
83+
- <<: *linux-s390x
84+
env: OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
85+
- <<: *linux-s390x
86+
env: OPENSSL_VER=1.1.1f OPENSSL_PATCH_VER=1.1.1f
87+
4388
install:
4489
- sudo cpanm --notest Test::Nginx IPC::Run3 > build.log 2>&1 || (cat build.log && exit 1)
45-
- if [ ! -f download-cache/pcre-$PCRE_VER.tar.gz ]; then wget -P download-cache http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-$PCRE_VER.tar.gz; fi
46-
- if [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz; fi
90+
- if [ ! -f download-cache/pcre-$PCRE_VER.tar.gz ]; then wget -P download-cache https://ftp.pcre.org/pub/pcre/pcre-$PCRE_VER.tar.gz; fi
91+
- if [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz || wget -P download-cache https://www.openssl.org/source/old/${OPENSSL_VER//[a-z]/}/openssl-$OPENSSL_VER.tar.gz; fi
4792
- tar zxf download-cache/pcre-$PCRE_VER.tar.gz
4893
- cd pcre-$PCRE_VER/
4994
- ./configure --prefix=$PCRE_PREFIX --enable-jit --enable-utf --enable-unicode-properties > build.log 2>&1 || (cat build.log && exit 1)
@@ -69,52 +114,4 @@ script:
69114
- export PATH=$OPENRESTY_PREFIX/bin:$OPENRESTY_PREFIX/nginx/sbin:$PATH
70115
- nginx -V
71116
- ldd `which nginx`|grep -E 'luajit|ssl|pcre'
72-
<<<<<<< HEAD
73-
- prove -I. -r t/
74-
- ROOT=$(pwd)
75-
- mkdir -p /tmp
76-
- mkdir -p /opt
77-
- mkdir -p /opt/openssl
78-
- curl -fsSL https://www.openssl.org/source/openssl-1.1.1b.tar.gz -o /tmp/openssl.tar.gz
79-
- tar -C /opt/openssl -xzf /tmp/openssl.tar.gz --strip-components 1
80-
- cd /opt/openssl
81-
- ls
82-
- ./config
83-
- sudo make 1> /dev/null
84-
- sudo make install_sw 1> /dev/null
85-
- sudo ldconfig
86-
- cd $ROOT
87-
- make
88-
- cd $ROOT/openresty-$VERSION
89-
- sudo ./configure
90-
- sudo make
91-
- sudo make install
92-
- export PATH=/usr/local/openresty/nginx/sbin:$PATH
93-
- cd $ROOT
94-
- git clone https://github.com/openresty/test-nginx
95-
- cd test-nginx
96-
- yes | sudo cpan .
97-
- cd $ROOT/openresty-$VERSION/bundle/
98-
- ls -l
99-
- cd $ROOT/openresty-$VERSION/bundle/array-var-nginx-module-0.05
100-
- prove t/.
101-
- cd $ROOT/openresty-$VERSION/bundle/echo-nginx-module-0.61
102-
- prove t/abort-parent.t
103-
- prove t/echo-duplicate.t
104-
- prove t/echo-timer.t
105-
- prove t/filter-used.t
106-
- prove t/gzip.t
107-
- prove t/incr.t
108-
- prove t/request-body.t
109-
- prove t/status.t
110-
- prove t/exec.t
111-
- prove t/if.t
112-
- prove t/mixed.t
113-
- prove t/request-info.t
114-
- prove t/sleep.t
115-
116-
- cd $ROOT/openresty-$VERSION/bundle/form-input-nginx-module-0.12
117-
- prove t/.
118-
=======
119117
- prove -r t/
120-
>>>>>>> 7508c1852265bd04fdb2dfd64989d4c490440f1a

html/50x.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
5+
<meta content="utf-8" http-equiv="encoding">
46
<title>Error</title>
57
<style>
68
body {
@@ -16,6 +18,8 @@ <h1>An error occurred.</h1>
1618
Please try again later.</p>
1719
<p>If you are the system administrator of this resource then you should check
1820
the <a href="http://nginx.org/r/error_log">error log</a> for details.</p>
19-
<p><em>Faithfully yours, OpenResty.</em></p>
21+
<p>We have articles on troubleshooting issues like <a href="https://blog.openresty.com/en/lua-cpu-flame-graph/?src=wb">high CPU usage</a> and
22+
<a href="https://blog.openresty.com/en/how-or-alloc-mem/">large memory usage</a> on <a href="https://blog.openresty.com/">our official blog site</a>.
23+
<p><em>Faithfully yours, <a href="https://openresty.org/">OpenResty</a>.</em></p>
2024
</body>
2125
</html>

html/index.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
5+
<meta content="utf-8" http-equiv="encoding">
46
<title>Welcome to OpenResty!</title>
57
<style>
68
body {
@@ -15,11 +17,12 @@ <h1>Welcome to OpenResty!</h1>
1517
<p>If you see this page, the OpenResty web platform is successfully installed and
1618
working. Further configuration is required.</p>
1719

18-
<p>For online documentation and support please refer to
19-
<a href="https://openresty.org/">openresty.org</a>.<br/>
20+
<p>For online documentation and support please refer to our
21+
<a href="https://openresty.org/">openresty.org</a> site<br/>
2022
Commercial support is available at
2123
<a href="https://openresty.com/">openresty.com</a>.</p>
22-
23-
<p><em>Thank you for flying OpenResty.</em></p>
24+
<p>We have articles on troubleshooting issues like <a href="https://blog.openresty.com/en/lua-cpu-flame-graph/?src=wb">high CPU usage</a> and
25+
<a href="https://blog.openresty.com/en/how-or-alloc-mem/">large memory usage</a> on <a href="https://blog.openresty.com/">our official blog site</a>.
26+
<p><em>Thank you for flying <a href="https://openresty.org/">OpenResty</a>.</em></p>
2427
</body>
2528
</html>

patches/nginx-1.17.8-single_process_graceful_exit.patch

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1+
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
2+
index 15680237..12a8c687 100644
3+
--- a/src/os/unix/ngx_process.c
4+
+++ b/src/os/unix/ngx_process.c
5+
@@ -362,8 +362,15 @@ ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext)
6+
break;
7+
8+
case ngx_signal_value(NGX_RECONFIGURE_SIGNAL):
9+
- ngx_reconfigure = 1;
10+
- action = ", reconfiguring";
11+
+ if (ngx_process == NGX_PROCESS_SINGLE) {
12+
+ ngx_terminate = 1;
13+
+ action = ", exiting";
14+
+
15+
+ } else {
16+
+ ngx_reconfigure = 1;
17+
+ action = ", reconfiguring";
18+
+ }
19+
+
20+
break;
21+
22+
case ngx_signal_value(NGX_REOPEN_SIGNAL):
123
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
2-
index 1710ea81..b379da9c 100644
24+
index 5817a2c2..f3d58e97 100644
325
--- a/src/os/unix/ngx_process_cycle.c
426
+++ b/src/os/unix/ngx_process_cycle.c
5-
@@ -304,11 +304,26 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
27+
@@ -305,11 +305,26 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
628
}
729

830
for ( ;; ) {
@@ -30,7 +52,7 @@ index 1710ea81..b379da9c 100644
3052

3153
for (i = 0; cycle->modules[i]; i++) {
3254
if (cycle->modules[i]->exit_process) {
33-
@@ -319,6 +334,20 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
55+
@@ -320,6 +335,20 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
3456
ngx_master_process_exit(cycle);
3557
}
3658

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
2+
index 282d6ee..899e11e 100644
3+
--- a/src/http/modules/ngx_http_static_module.c
4+
+++ b/src/http/modules/ngx_http_static_module.c
5+
@@ -58,6 +58,8 @@ ngx_http_static_handler(ngx_http_request_t *r)
6+
ngx_chain_t out;
7+
ngx_open_file_info_t of;
8+
ngx_http_core_loc_conf_t *clcf;
9+
+ u_char *uri;
10+
+ uintptr_t escape;
11+
12+
if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {
13+
return NGX_HTTP_NOT_ALLOWED;
14+
@@ -162,9 +164,21 @@ ngx_http_static_handler(ngx_http_request_t *r)
15+
16+
*last = '/';
17+
18+
+ escape = 2 * ngx_escape_uri(NULL, location, len, NGX_ESCAPE_URI);
19+
+ if (escape > 0) {
20+
+ uri = ngx_pnalloc(r->pool, len + escape);
21+
+ if (uri == NULL) {
22+
+ return NGX_ERROR;
23+
+ }
24+
+ ngx_escape_uri(uri, location, len, NGX_ESCAPE_URI);
25+
+ location = uri;
26+
+ len += escape;
27+
+ }
28+
+
29+
} else {
30+
+ escape = 2 * ngx_escape_uri(NULL, r->uri.data, r->uri.len, NGX_ESCAPE_URI);
31+
if (r->args.len) {
32+
- len += r->args.len + 1;
33+
+ len += r->args.len + 1 + escape;
34+
}
35+
36+
location = ngx_pnalloc(r->pool, len);
37+
@@ -173,7 +187,12 @@ ngx_http_static_handler(ngx_http_request_t *r)
38+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
39+
}
40+
41+
- last = ngx_copy(location, r->uri.data, r->uri.len);
42+
+ if (escape > 0) {
43+
+ last = (u_char *) ngx_escape_uri(location, r->uri.data, r->uri.len, NGX_ESCAPE_URI);
44+
+
45+
+ } else {
46+
+ last = ngx_copy(location, r->uri.data, r->uri.len);
47+
+ }
48+
49+
*last = '/';
50+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- nginx-1.19.2/auto/cc/conf 2015-10-30 22:47:50.000000000 +0800
2+
+++ nginx-1.19.2-patched/auto/cc/conf 2015-11-02 12:23:05.385156987 +0800
3+
@@ -136,7 +136,7 @@ fi
4+
CFLAGS="$CFLAGS $NGX_CC_OPT"
5+
NGX_TEST_LD_OPT="$NGX_LD_OPT"
6+
7+
-if [ "$NGX_PLATFORM" != win32 ]; then
8+
+if [ 1 ]; then
9+
10+
if test -n "$NGX_LD_OPT"; then
11+
ngx_feature=--with-ld-opt=\"$NGX_LD_OPT\"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
2+
index f8d5707d..6efe0047 100644
3+
--- a/src/http/ngx_http_upstream.c
4+
+++ b/src/http/ngx_http_upstream.c
5+
@@ -1515,6 +1515,11 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
6+
return;
7+
}
8+
9+
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
10+
+ ngx_http_upstream_finalize_request(r, u, rc);
11+
+ return;
12+
+ }
13+
+
14+
u->state->peer = u->peer.name;
15+
16+
if (rc == NGX_BUSY) {
17+
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
18+
index 3e714e5b..dfbb25e0 100644
19+
--- a/src/http/ngx_http_upstream.h
20+
+++ b/src/http/ngx_http_upstream.h
21+
@@ -427,4 +427,9 @@ extern ngx_conf_bitmask_t ngx_http_upstream_cache_method_mask[];
22+
extern ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[];
23+
24+
25+
+#ifndef HAVE_BALANCER_STATUS_CODE_PATCH
26+
+#define HAVE_BALANCER_STATUS_CODE_PATCH
27+
+#endif
28+
+
29+
+
30+
#endif /* _NGX_HTTP_UPSTREAM_H_INCLUDED_ */
31+
diff --git a/src/stream/ngx_stream.h b/src/stream/ngx_stream.h
32+
index 09d24593..d8b4b584 100644
33+
--- a/src/stream/ngx_stream.h
34+
+++ b/src/stream/ngx_stream.h
35+
@@ -27,6 +27,7 @@ typedef struct ngx_stream_session_s ngx_stream_session_t;
36+
37+
38+
#define NGX_STREAM_OK 200
39+
+#define NGX_STREAM_SPECIAL_RESPONSE 300
40+
#define NGX_STREAM_BAD_REQUEST 400
41+
#define NGX_STREAM_FORBIDDEN 403
42+
#define NGX_STREAM_INTERNAL_SERVER_ERROR 500
43+
diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c
44+
index 818d7329..329dcdc6 100644
45+
--- a/src/stream/ngx_stream_proxy_module.c
46+
+++ b/src/stream/ngx_stream_proxy_module.c
47+
@@ -691,6 +691,11 @@ ngx_stream_proxy_connect(ngx_stream_session_t *s)
48+
return;
49+
}
50+
51+
+ if (rc >= NGX_STREAM_SPECIAL_RESPONSE) {
52+
+ ngx_stream_proxy_finalize(s, rc);
53+
+ return;
54+
+ }
55+
+
56+
u->state->peer = u->peer.name;
57+
58+
if (rc == NGX_BUSY) {
59+
diff --git a/src/stream/ngx_stream_upstream.h b/src/stream/ngx_stream_upstream.h
60+
index 73947f46..21bc0ad7 100644
61+
--- a/src/stream/ngx_stream_upstream.h
62+
+++ b/src/stream/ngx_stream_upstream.h
63+
@@ -151,4 +151,9 @@ ngx_stream_upstream_srv_conf_t *ngx_stream_upstream_add(ngx_conf_t *cf,
64+
extern ngx_module_t ngx_stream_upstream_module;
65+
66+
67+
+#ifndef HAVE_BALANCER_STATUS_CODE_PATCH
68+
+#define HAVE_BALANCER_STATUS_CODE_PATCH
69+
+#endif
70+
+
71+
+
72+
#endif /* _NGX_STREAM_UPSTREAM_H_INCLUDED_ */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
2+
index 64e5acd..f5374f6 100644
3+
--- a/src/http/ngx_http_special_response.c
4+
+++ b/src/http/ngx_http_special_response.c
5+
@@ -26,7 +26,7 @@ static u_char ngx_http_error_full_tail[] =
6+
7+
8+
static u_char ngx_http_error_tail[] =
9+
-"<hr><center>nginx</center>" CRLF
10+
+"<hr><center>openresty</center>" CRLF
11+
"</body>" CRLF
12+
"</html>" CRLF
13+
;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# HG changeset patch
2+
# User Yichun Zhang <agentzh@gmail.com>
3+
# Date 1383598130 28800
4+
# Node ID f64218e1ac963337d84092536f588b8e0d99bbaa
5+
# Parent dea321e5c0216efccbb23e84bbce7cf3e28f130c
6+
Cache: gracefully exit the cache manager process.
7+
8+
diff -r dea321e5c021 -r f64218e1ac96 src/os/unix/ngx_process_cycle.c
9+
--- a/src/os/unix/ngx_process_cycle.c Thu Oct 31 18:23:49 2013 +0400
10+
+++ b/src/os/unix/ngx_process_cycle.c Mon Nov 04 12:48:50 2013 -0800
11+
@@ -1335,7 +1335,7 @@
12+
13+
if (ngx_terminate || ngx_quit) {
14+
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
15+
- exit(0);
16+
+ ngx_worker_process_exit(cycle);
17+
}
18+
19+
if (ngx_reopen) {

0 commit comments

Comments
 (0)