1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
From bf6cd93f2098b59260de8d494f0f4b1f11a84627 Mon Sep 17 00:00:00 2001
From: Weibin Yao <yaoweibin@gmail.com>
Date: Fri, 27 Feb 2015 23:13:30 +0800
Subject: [PATCH] fixed the compatible problem with nginx-1.7.9+
---
ngx_http_ajp.h | 1 +
ngx_http_ajp_module.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
diff --git a/ngx_http_ajp.h b/ngx_http_ajp.h
index 72502ad..b3c7051 100644
--- a/ngx_http_ajp.h
+++ b/ngx_http_ajp.h
@@ -5,6 +5,7 @@
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
+#include <nginx.h>
#include "ngx_http_ajp_module.h"
#define AJP13_DEF_HOST "127.0.0.1"
diff --git a/ngx_http_ajp_module.c b/ngx_http_ajp_module.c
index e4d5b00..be32459 100644
--- a/ngx_http_ajp_module.c
+++ b/ngx_http_ajp_module.c
@@ -464,8 +464,12 @@ ngx_http_ajp_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
#if (NGX_HTTP_CACHE)
+#if (nginx_version >= 1007009)
+ if (alcf->upstream.cache > 0)
+#else
if (alcf->upstream.cache != NGX_CONF_UNSET_PTR
&& alcf->upstream.cache != NULL)
+#endif
{
return "is incompatible with \"ajp_cache\"";
}
@@ -534,15 +538,27 @@ ngx_http_ajp_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_http_ajp_loc_conf_t *alcf = conf;
ngx_str_t *value;
+#if (nginx_version >= 1007009)
+ ngx_http_complex_value_t cv;
+ ngx_http_compile_complex_value_t ccv;
+#endif
value = cf->args->elts;
+#if (nginx_version >= 1007009)
+ if (alcf->upstream.cache != NGX_CONF_UNSET) {
+#else
if (alcf->upstream.cache != NGX_CONF_UNSET_PTR) {
+#endif
return "is duplicate";
}
if (ngx_strcmp(value[1].data, "off") == 0) {
+#if (nginx_version >= 1007009)
+ alcf->upstream.cache = 0;
+#else
alcf->upstream.cache = NULL;
+#endif
return NGX_CONF_OK;
}
@@ -550,11 +566,44 @@ ngx_http_ajp_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "is incompatible with \"ajp_store\"";
}
+#if (nginx_version >= 1007009)
+ alcf->upstream.cache = 1;
+
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
+
+ ccv.cf = cf;
+ ccv.value = &value[1];
+ ccv.complex_value = &cv;
+
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+
+ if (cv.lengths != NULL) {
+
+ alcf->upstream.cache_value = ngx_palloc(cf->pool,
+ sizeof(ngx_http_complex_value_t));
+ if (alcf->upstream.cache_value == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ *alcf->upstream.cache_value = cv;
+
+ return NGX_CONF_OK;
+ }
+
+ alcf->upstream.cache_zone = ngx_shared_memory_add(cf, &value[1], 0,
+ &ngx_http_ajp_module);
+ if (alcf->upstream.cache_zone == NULL) {
+ return NGX_CONF_ERROR;
+ }
+#else
alcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0,
&ngx_http_ajp_module);
if (alcf->upstream.cache == NULL) {
return NGX_CONF_ERROR;
}
+#endif
return NGX_CONF_OK;
}
@@ -666,7 +715,11 @@ ngx_http_ajp_create_loc_conf(ngx_conf_t *cf)
conf->upstream.pass_request_body = NGX_CONF_UNSET;
#if (NGX_HTTP_CACHE)
+#if (nginx_version >= 1007009)
+ conf->upstream.cache = NGX_CONF_UNSET;
+#else
conf->upstream.cache = NGX_CONF_UNSET_PTR;
+#endif
conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT;
conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
conf->upstream.cache_lock = NGX_CONF_UNSET;
@@ -699,6 +752,18 @@ ngx_http_ajp_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_str_t *h;
ngx_hash_init_t hash;
+#if (NGX_HTTP_CACHE) && (nginx_version >= 1007009)
+
+ if (conf->upstream.store > 0) {
+ conf->upstream.cache = 0;
+ }
+
+ if (conf->upstream.cache > 0) {
+ conf->upstream.store = 0;
+ }
+
+#endif
+
if (conf->upstream.store != 0) {
ngx_conf_merge_value(conf->upstream.store,
prev->upstream.store, 0);
@@ -864,6 +929,20 @@ ngx_http_ajp_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
#if (NGX_HTTP_CACHE)
+#if (nginx_version >= 1007009)
+ if (conf->upstream.cache == NGX_CONF_UNSET) {
+ ngx_conf_merge_value(conf->upstream.cache,
+ prev->upstream.cache, 0);
+
+ conf->upstream.cache_zone = prev->upstream.cache_zone;
+ conf->upstream.cache_value = prev->upstream.cache_value;
+ }
+
+ if (conf->upstream.cache_zone && conf->upstream.cache_zone->data == NULL) {
+ ngx_shm_zone_t *shm_zone;
+
+ shm_zone = conf->upstream.cache_zone;
+#else
ngx_conf_merge_ptr_value(conf->upstream.cache,
prev->upstream.cache, NULL);
@@ -871,6 +950,7 @@ ngx_http_ajp_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_shm_zone_t *shm_zone;
shm_zone = conf->upstream.cache;
+#endif
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"ajp_cache\" zone \"%V\" is unknown, "
@@ -910,6 +990,11 @@ ngx_http_ajp_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
conf->cache_key = prev->cache_key;
}
+ if (conf->upstream.cache && conf->cache_key.value.data == NULL) {
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
+ "no \"fastcgi_cache_key\" for \"fastcgi_cache\"");
+ }
+
ngx_conf_merge_value(conf->upstream.cache_lock,
prev->upstream.cache_lock, 0);
|