Compare commits

...

17 Commits

Author SHA1 Message Date
163432a678 updated tests to reflect recent changes. 2013-12-14 16:06:31 -08:00
c338e4d0e2 bumped version to 1.4.3.7. 2013-12-14 16:05:18 -08:00
374f575dfa upgraded ngx_memc to 0.14. 2013-12-14 15:32:54 -08:00
b53c539f7e upgraded ngx_set_misc to 0.23. 2013-12-14 14:36:42 -08:00
a16a33d417 upgraded ngx_rds_json to 0.13. 2013-12-14 14:27:38 -08:00
e3e60a3a68 upgraded ngx_headers_more to 0.24. 2013-12-14 14:23:45 -08:00
71a675f4fb upgraded ngx_echo to 0.50. 2013-12-14 14:19:51 -08:00
adb00e91e7 upgraded LuaJIT to v2.1-20131211. 2013-12-14 14:14:26 -08:00
c6aad4deba upgraded ngx_lua to 0.9.3. 2013-12-14 13:30:18 -08:00
b8bf7bbb4c feature: bundle the lua-resty-core library, which reimplements ngx_lua's Lua API with LuaJIT FFI. 2013-12-14 13:21:41 -08:00
0528788543 feature: added new configure option --with-pcre-conf-opt=OPTIONS to the nginx core to allow custom PCRE ./configure build options. thanks Lance Li for the original patch in #39. 2013-12-10 10:19:00 -08:00
378f94fb58 updated the tests to reflect recent upgrades. 2013-12-10 10:16:13 -08:00
5be3b51678 upgraded ngx_array_var to 0.03. 2013-12-09 21:10:29 -08:00
2fb9ed5c1d updated the larger_max_error_str patch to allow NGX_MAX_ERROR_STR to be redefined from the outside. 2013-12-05 20:36:53 -08:00
1728ca8c66 feature: applied the larger_max_error_str patch to the nginx core to allow error log messages up to 4096 bytes. 2013-12-05 20:33:30 -08:00
157febe350 upgraded ngx_http_redis module to 0.3.7. 2013-12-03 12:07:10 -08:00
633abb71bf upgraded the patch "variables_in_redis_pass" to ngx_http_redis 0.3.7. 2013-12-03 12:06:31 -08:00
7 changed files with 680 additions and 385 deletions

View File

@ -0,0 +1,13 @@
--- nginx-1.4.3/src/core/ngx_log.h 2013-10-08 05:07:14.000000000 -0700
+++ nginx-1.4.3-patched/src/core/ngx_log.h 2013-12-05 20:35:35.996236720 -0800
@@ -64,7 +64,9 @@ struct ngx_log_s {
};
-#define NGX_MAX_ERROR_STR 2048
+#ifndef NGX_MAX_ERROR_STR
+#define NGX_MAX_ERROR_STR 4096
+#endif
/*********************************/

View File

@ -0,0 +1,26 @@
# HG changeset patch
# User Yichun Zhang <agentzh@gmail.com>
# Date 1386694955 28800
# Node ID 9ba6b149669f1f02eeb4cdc0ebd364a949b5c469
# Parent 30e806b8636af5fd3f03ec17df24801f390f7511
Configure: added new option --with-pcre-conf-opt=OPTIONS.
diff -r 30e806b8636a -r 9ba6b149669f auto/options
--- a/auto/options Mon Dec 09 10:16:44 2013 +0400
+++ b/auto/options Tue Dec 10 09:02:35 2013 -0800
@@ -286,6 +286,7 @@
--with-pcre) USE_PCRE=YES ;;
--with-pcre=*) PCRE="$value" ;;
--with-pcre-opt=*) PCRE_OPT="$value" ;;
+ --with-pcre-conf-opt=*) PCRE_CONF_OPT="$value" ;;
--with-pcre-jit) PCRE_JIT=YES ;;
--with-openssl=*) OPENSSL="$value" ;;
@@ -441,6 +442,7 @@
--with-pcre force PCRE library usage
--with-pcre=DIR set path to PCRE library sources
--with-pcre-opt=OPTIONS set additional build options for PCRE
+ --with-pcre-conf-opt=OPTIONS set additional configure options for PCRE
--with-pcre-jit build PCRE with JIT compilation support
--with-md5=DIR set path to md5 library sources

View File

@ -0,0 +1,190 @@
--- ngx_http_redis-0.3.7/ngx_http_redis_module.c 2013-03-21 17:51:09.224660165 -0700
+++ ngx_http_redis-0.3.7-patched/ngx_http_redis_module.c 2013-03-21 17:50:51.928599875 -0700
@@ -18,6 +18,8 @@ typedef struct {
ngx_int_t index;
ngx_int_t db;
ngx_uint_t gzip_flag;
+
+ ngx_http_complex_value_t *complex_target; /* for redis_pass */
} ngx_http_redis_loc_conf_t;
@@ -44,6 +46,9 @@ static char *ngx_http_redis_merge_loc_co
static char *ngx_http_redis_pass(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
+static ngx_http_upstream_srv_conf_t *
+ ngx_http_redis_upstream_add(ngx_http_request_t *r, ngx_url_t *url);
+
static ngx_conf_bitmask_t ngx_http_redis_next_upstream_masks[] = {
{ ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
@@ -185,11 +190,43 @@ ngx_http_redis_handler(ngx_http_request_
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
+ rlcf = ngx_http_get_module_loc_conf(r, ngx_http_redis_module);
+ if (rlcf->complex_target) {
+ ngx_str_t target;
+ ngx_url_t url;
+
+ /* variables used in the redis_pass directive */
+
+ if (ngx_http_complex_value(r, rlcf->complex_target, &target)
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
+ if (target.len == 0) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "handler: empty \"redis_pass\" target");
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ url.host = target;
+ url.port = 0;
+ url.default_port = 6379;
+ url.no_resolve = 1;
+
+ rlcf->upstream.upstream = ngx_http_redis_upstream_add(r, &url);
+
+ if (rlcf->upstream.upstream == NULL) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "redis: upstream \"%V\" not found", &target);
+
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+ }
+
#if defined nginx_version && nginx_version >= 8011
if (ngx_http_upstream_create(r) != NGX_OK) {
#else
- rlcf = ngx_http_get_module_loc_conf(r, ngx_http_redis_module);
-
u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));
if (u == NULL) {
#endif
@@ -214,9 +251,7 @@ ngx_http_redis_handler(ngx_http_request_
u->peer.log_error = NGX_ERROR_ERR;
#endif
-#if defined nginx_version && nginx_version >= 8011
- rlcf = ngx_http_get_module_loc_conf(r, ngx_http_redis_module);
-#else
+#if !defined(nginx_version) || nginx_version < 8011
u->output.tag = (ngx_buf_tag_t) &ngx_http_redis_module;
#endif
@@ -835,24 +870,15 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
ngx_str_t *value;
ngx_url_t u;
+ ngx_uint_t n;
ngx_http_core_loc_conf_t *clcf;
+ ngx_http_compile_complex_value_t ccv;
+
if (rlcf->upstream.upstream) {
return "is duplicate";
}
- value = cf->args->elts;
-
- ngx_memzero(&u, sizeof(ngx_url_t));
-
- u.url = value[1];
- u.no_resolve = 1;
-
- rlcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
- if (rlcf->upstream.upstream == NULL) {
- return NGX_CONF_ERROR;
- }
-
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
clcf->handler = ngx_http_redis_handler;
@@ -869,6 +895,41 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
rlcf->db = ngx_http_get_variable_index(cf, &ngx_http_redis_db);
+ value = cf->args->elts;
+
+ n = ngx_http_script_variables_count(&value[1]);
+ if (n) {
+ rlcf->complex_target = ngx_palloc(cf->pool,
+ sizeof(ngx_http_complex_value_t));
+
+ if (rlcf->complex_target == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
+ ccv.cf = cf;
+ ccv.value = &value[1];
+ ccv.complex_value = rlcf->complex_target;
+
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+
+ return NGX_CONF_OK;
+ }
+
+ rlcf->complex_target = NULL;
+
+ ngx_memzero(&u, sizeof(ngx_url_t));
+
+ u.url = value[1];
+ u.no_resolve = 1;
+
+ rlcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
+ if (rlcf->upstream.upstream == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
return NGX_CONF_OK;
}
@@ -906,3 +967,41 @@ ngx_http_redis_add_variables(ngx_conf_t
return NGX_OK;
}
+
+
+static ngx_http_upstream_srv_conf_t *
+ngx_http_redis_upstream_add(ngx_http_request_t *r, ngx_url_t *url)
+{
+ ngx_http_upstream_main_conf_t *umcf;
+ ngx_http_upstream_srv_conf_t **uscfp;
+ ngx_uint_t i;
+
+ umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
+
+ uscfp = umcf->upstreams.elts;
+
+ for (i = 0; i < umcf->upstreams.nelts; i++) {
+
+ if (uscfp[i]->host.len != url->host.len
+ || ngx_strncasecmp(uscfp[i]->host.data, url->host.data,
+ url->host.len) != 0)
+ {
+ continue;
+ }
+
+ if (uscfp[i]->port != url->port) {
+ continue;
+ }
+
+ if (uscfp[i]->default_port
+ && url->default_port
+ && uscfp[i]->default_port != url->default_port)
+ {
+ continue;
+ }
+
+ return uscfp[i];
+ }
+
+ return NULL;
+}

File diff suppressed because it is too large Load Diff

9
util/configure vendored
View File

@ -182,6 +182,9 @@ for my $opt (@ARGV) {
} elsif ($opt eq '--without-lua_resty_lock') {
$resty_opts{no_lua_resty_lock} = 1;
} elsif ($opt eq '--without-lua_resty_core') {
$resty_opts{no_lua_resty_core} = 1;
} elsif ($opt eq '--without-lua_rds_parser') {
$resty_opts{no_lua_rds_parser} = 1;
@ -787,7 +790,7 @@ _EOC_
}
for my $key (qw(dns memcached redis mysql string upload websocket
lock))
lock core))
{
unless ($opts->{"no_lua_resty_$key"}) {
my $name = "lua-resty-$key";
@ -911,6 +914,7 @@ _EOC_
--without-lua_resty_string disable the lua-resty-string library
--without-lua_resty_websocket disable the lua-resty-websocket library
--without-lua_resty_lock disable the lua-resty-lock library
--without-lua_resty_core disable the lua-resty-core library
--without-lua51 disable the bundled Lua 5.1 interpreter
--with-lua51=PATH specify the external installation of Lua 5.1 by PATH
@ -1025,7 +1029,8 @@ Options directly inherited from nginx
--without-pcre disable PCRE library usage
--with-pcre force PCRE library usage
--with-pcre=DIR set path to PCRE library sources
--with-pcre-opt=OPTIONS set additional options for PCRE building
--with-pcre-opt=OPTIONS set additional make options for PCRE
--with-pcre-conf-opt=OPTIONS set additional configure options for PCRE
--with-pcre-jit build PCRE with JIT compilation support
--with-md5=DIR set path to md5 library sources

View File

@ -210,6 +210,14 @@ if [ "$answer" = "N" ]; then
echo
fi
echo "$info_txt applying the larger_max_error_str patch for nginx $ver"
patch -p1 < $root/patches/nginx-$ver-larger_max_error_str.patch || exit 1
echo
echo "$info_txt applying the pcre_conf_opt patch for nginx $ver"
patch -p1 < $root/patches/nginx-$ver-pcre_conf_opt.patch || exit 1
echo
rm -f *.patch || exit 1
cd .. || exit 1
@ -223,7 +231,7 @@ rm -rf no-pool-nginx-$ver
#################################
ver=0.49
ver=0.50
$root/util/get-tarball "https://github.com/agentzh/echo-nginx-module/tarball/v$ver" -O echo-nginx-module-$ver.tar.gz || exit 1
tar -xzf echo-nginx-module-$ver.tar.gz || exit 1
mv agentzh-echo-nginx-module-* echo-nginx-module-$ver || exit 1
@ -244,14 +252,14 @@ mv simpl-ngx_devel_kit-* ngx_devel_kit-$ver || exit 1
#################################
ver=0.22
ver=0.23
$root/util/get-tarball "https://github.com/agentzh/set-misc-nginx-module/tarball/v$ver" -O set-misc-nginx-module-$ver.tar.gz || exit 1
tar -xzf set-misc-nginx-module-$ver.tar.gz || exit 1
mv agentzh-set-misc-nginx-module-* set-misc-nginx-module-$ver || exit 1
#################################
ver=0.12
ver=0.13
$root/util/get-tarball "https://github.com/agentzh/rds-json-nginx-module/tarball/v$ver" -O rds-json-nginx-module-$ver.tar.gz || exit 1
tar -xzf rds-json-nginx-module-$ver.tar.gz || exit 1
mv agentzh-rds-json-nginx-module-* rds-json-nginx-module-$ver || exit 1
@ -265,7 +273,7 @@ mv agentzh-rds-csv-nginx-module-* rds-csv-nginx-module-$ver || exit 1
#################################
ver=0.23
ver=0.24
$root/util/get-tarball "https://github.com/agentzh/headers-more-nginx-module/tarball/v$ver" -O headers-more-nginx-module-$ver.tar.gz || exit 1
tar -xzf headers-more-nginx-module-$ver.tar.gz || exit 1
mv agentzh-headers-more-nginx-module-* headers-more-nginx-module-$ver || exit 1
@ -279,21 +287,21 @@ mv chaoslawful-drizzle-nginx-module-* drizzle-nginx-module-$ver || exit 1
#################################
ver=0.9.2
ver=0.9.3
$root/util/get-tarball "https://github.com/chaoslawful/lua-nginx-module/tarball/v$ver" -O lua-nginx-module-$ver.tar.gz || exit 1
tar -xzf lua-nginx-module-$ver.tar.gz || exit 1
mv chaoslawful-lua-nginx-module-* ngx_lua-$ver || exit 1
#################################
ver=0.03rc1
ver=0.03
$root/util/get-tarball "https://github.com/agentzh/array-var-nginx-module/tarball/v$ver" -O array-var-nginx-module-$ver.tar.gz || exit 1
tar -xzf array-var-nginx-module-$ver.tar.gz || exit 1
mv agentzh-array-var-nginx-module-* array-var-nginx-module-$ver || exit 1
#################################
ver=0.13
ver=0.14
$root/util/get-tarball "https://github.com/agentzh/memc-nginx-module/tarball/v$ver" -O memc-nginx-module-$ver.tar.gz || exit 1
tar -xzf memc-nginx-module-$ver.tar.gz || exit 1
mv agentzh-memc-nginx-module-* memc-nginx-module-$ver || exit 1
@ -343,7 +351,7 @@ mv ngx_http_auth_request_module-* auth-request-nginx-module-$ver || exit 1
#################################
ver=0.3.6
ver=0.3.7
$root/util/get-tarball "http://people.freebsd.org/~osa/ngx_http_redis-$ver.tar.gz" -O redis-nginx-module-$ver.tar.gz || exit 1
tar -xzf redis-nginx-module-$ver.tar.gz || exit 1
mv ngx_http_redis-* redis-nginx-module-$ver || exit 1
@ -402,9 +410,10 @@ echo
#################################
ver=2.0.2
$root/util/get-tarball "http://luajit.org/download/LuaJIT-$ver.tar.gz" -O "LuaJIT-$ver.tar.gz" || exit 1
ver=2.1-20131211
$root/util/get-tarball "https://github.com/agentzh/luajit2/archive/v$ver.tar.gz" -O "LuaJIT-$ver.tar.gz" || exit 1
tar -xzf LuaJIT-$ver.tar.gz || exit 1
mv luajit2-* LuaJIT-$ver || exit 1
#echo "$info_txt applying luajit-$ver hotfix #1 patch for luajit $ver"
#$root/util/get-tarball http://luajit.org/download/v2.0.1_hotfix1.patch -O hotfix.patch
@ -501,6 +510,13 @@ mv agentzh-lua-resty-lock-* lua-resty-lock-$ver || exit 1
#################################
ver=0.0.2
$root/util/get-tarball "https://github.com/agentzh/lua-resty-core/tarball/v$ver" -O "lua-resty-core-$ver.tar.gz" || exit 1
tar -xzf lua-resty-core-$ver.tar.gz || exit 1
mv agentzh-lua-resty-core-* lua-resty-core-$ver || exit 1
#################################
rm *.tar.gz
cd ..

View File

@ -2,7 +2,7 @@
#main_ver=1.5.4
main_ver=1.4.3
minor_ver=6
minor_ver=7
version=$main_ver.$minor_ver
echo $version