如何在 Oracle Linux 中使用 mod_jk 将 Apache Httpd 连接到多个 Tomcat 实例?

How to connect Apache Httpd to multiple Tomcat instances using mod_jk in Oracle Linux?

提问人:Dominique Morales 提问时间:9/6/2023 最后编辑:Dominique Morales 更新时间:9/6/2023 访问量:55

问:

我正在尝试使用 Oracle Linux R7U9 中的 mod_jk 模块设置 Apache httpd + 多个 Tomcat 实例配置。目的是让 Apache httpd 通过单个外部 IP 地址 (192.168.157.130) 和单个域 (artemis.com) 接收请求,然后将请求处理委托给不同的 Tomcat 实例。 Tomcat 实例包括:

  1. 演示 - 使用上下文路径 /bar 部署应用的位置
  2. expo - 使用上下文路径 /foo 部署应用的位置

在类似的情况下,我试图将此处提供的一些解决方案合并到 SO 中。但是,当我尝试访问应用程序 /bar/foo 时,我不断收到以下错误消息。

我的配置中可能缺少什么?我需要安装任何 Apache 组件吗? 任何帮助将不胜感激。提前致谢。

浏览器错误消息

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Mod JK 错误日志

 95 [info] init_jk::mod_jk.c (3591): mod_jk/1.2.48 initialized
 96 [debug] uri_worker_map_dump::jk_uri_worker_map.c (177): uri map dump after extension stripping: id=1, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
 97 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 0: size=0 nosize=0 capacity=0
 98 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 1: size=0 nosize=0 capacity=0
 99 [debug] uri_worker_map_switch::jk_uri_worker_map.c (601): Switching uri worker map from index 0 to index 1
100 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker bar
101 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
102 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker bar of type ajp13 (2)
103 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker foo
104 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
105 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker foo of type ajp13 (2)
106 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker bar
107 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
108 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker bar of type ajp13 (2)
109 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker foo
110 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
111 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker foo of type ajp13 (2)
112 [debug] uri_worker_map_dump::jk_uri_worker_map.c (177): uri map dump after extension stripping: id=2, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
113 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 0: size=0 nosize=0 capacity=0
114 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 1: size=4 nosize=0 capacity=4
115 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #0: uri=/bar/* worker=bar context=/bar/* source=JkMount type=Wildchar len=6
116 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #1: uri=/foo/* worker=foo context=/foo/* source=JkMount type=Wildchar len=6
117 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #2: uri=/bar worker=bar context=/bar source=JkMount type=Exact len=4
118 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #3: uri=/foo worker=foo context=/foo source=JkMount type=Exact len=4
119 [debug] uri_worker_map_switch::jk_uri_worker_map.c (601): Switching uri worker map from index 0 to index 1
120 [debug] jk_shm_close::jk_shm.c (744): Closed shared memory /var/cache/httpd/mod_jk/jk.shm.7403 childs=1
121 [debug] jk_set_time_fmt::jk_util.c (486): Pre-processed log time stamp format is '[%a %b %d %H:%M:%S %Y] '
122 [debug] dump_options::mod_jk.c (665): JkOption 'ForwardURICompat' set in server 'artemis.com:80'
123 [debug] dump_options::mod_jk.c (673): JkOption 'ForwardURIEscaped' set in server 'artemis.com:80'
124 [debug] dump_options::mod_jk.c (697): JkOption 'ForwardKeySize' set in server 'artemis.com:80' (default)
125 [debug] uri_worker_map_open::jk_uri_worker_map.c (897): rule map size is 0
126 [debug] uri_worker_map_dump::jk_uri_worker_map.c (177): uri map dump after map open: id=0, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
127 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 0: size=0 nosize=0 capacity=0
128 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 1: size=0 nosize=0 capacity=0
129 [debug] jk_set_time_fmt::jk_util.c (486): Pre-processed log time stamp format is '[%a %b %d %H:%M:%S %Y] '
130 [debug] dump_options::mod_jk.c (665): JkOption 'ForwardURICompat' set in server 'artemis.com [_default_:8443]'
131 [debug] dump_options::mod_jk.c (673): JkOption 'ForwardURIEscaped' set in server 'artemis.com [_default_:8443]'
132 [debug] dump_options::mod_jk.c (697): JkOption 'ForwardKeySize' set in server 'artemis.com [_default_:8443]' (default)
133 [debug] jk_set_time_fmt::jk_util.c (486): Pre-processed log time stamp format is '[%a %b %d %H:%M:%S %Y] '
134 [debug] dump_options::mod_jk.c (665): JkOption 'ForwardURICompat' set in server 'artemis.com [*:80]'
135 [debug] dump_options::mod_jk.c (673): JkOption 'ForwardURIEscaped' set in server 'artemis.com [*:80]'
136 [debug] dump_options::mod_jk.c (697): JkOption 'ForwardKeySize' set in server 'artemis.com [*:80]' (default)
137 [debug] uri_worker_map_open::jk_uri_worker_map.c (897): rule map size is 4
138 [debug] uri_worker_map_add::jk_uri_worker_map.c (856): exact rule '/bar=bar' source 'JkMount' was added
139 [debug] uri_worker_map_add::jk_uri_worker_map.c (847): wildchar rule '/bar/*=bar' source 'JkMount' was added
140 [debug] uri_worker_map_add::jk_uri_worker_map.c (856): exact rule '/foo=foo' source 'JkMount' was added
141 [debug] uri_worker_map_add::jk_uri_worker_map.c (847): wildchar rule '/foo/*=foo' source 'JkMount' was added
142 [debug] uri_worker_map_dump::jk_uri_worker_map.c (177): uri map dump after map open: id=0, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
143 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 0: size=0 nosize=0 capacity=0
144 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 1: size=4 nosize=0 capacity=4
145 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #0: uri=/bar/* worker=bar context=/bar/* source=JkMount type=Wildchar len=6
146 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #1: uri=/foo/* worker=foo context=/foo/* source=JkMount type=Wildchar len=6
147 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #2: uri=/bar worker=bar context=/bar source=JkMount type=Exact len=4
148 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #3: uri=/foo worker=foo context=/foo source=JkMount type=Exact len=4
149 [debug] init_jk::mod_jk.c (3529): Setting default connection pool max size to 1
150 [debug] jk_map_read_property::jk_map.c (500): Adding property 'worker.list' with value 'bar,foo' to map.
151 [debug] jk_map_read_property::jk_map.c (500): Adding property 'worker.bar.port' with value '8209' to map.
152 [debug] jk_map_read_property::jk_map.c (500): Adding property 'worker.bar.host' with value '192.168.157.130' to map.
153 [debug] jk_map_read_property::jk_map.c (500): Adding property 'worker.bar.type' with value 'ajp13' to map.
154 [debug] jk_map_read_property::jk_map.c (500): Adding property 'worker.foo.port' with value '8309' to map.
155 [debug] jk_map_read_property::jk_map.c (500): Adding property 'worker.foo.host' with value '192.168.157.130' to map.
156 [debug] jk_map_read_property::jk_map.c (500): Adding property 'worker.foo.type' with value 'ajp13' to map.
157 [debug] jk_map_resolve_references::jk_map.c (782): Checking for references with prefix worker. with wildcard (recursion 1)
158 [debug] jk_shm_calculate_size::jk_shm.c (142): JK_SHM_SLOT_SIZE defined as 384, need at least 384
159 [debug] jk_shm_calculate_size::jk_shm.c (176): shared memory will contain 2 ajp workers and 0 lb workers with 0 members
160 [debug] do_shm_open::jk_shm.c (621): Truncated shared memory to 1152
161 [debug] do_shm_open::jk_shm.c (668): Initialized shared memory /var/cache/httpd/mod_jk/jk.shm.7403 size=1152 free=768 addr=0x7f88473a0000
162 [debug] do_shm_open_lock::jk_shm.c (531): Opened shared memory lock /var/cache/httpd/mod_jk/jk.shm.7403.lock
163 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'ServerRoot' -> '/etc/httpd'
164 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'worker.list' -> 'bar,foo'
165 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'worker.bar.port' -> '8209'
166 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'worker.bar.host' -> '192.168.157.130'
167 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'worker.bar.type' -> 'ajp13'
168 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'worker.foo.port' -> '8309'
169 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'worker.foo.host' -> '192.168.157.130'
170 [debug] jk_map_dump::jk_map.c (598): Dump of map 3: 'worker.foo.type' -> 'ajp13'
171 [debug] build_worker_map::jk_worker.c (249): creating worker bar
172 [debug] wc_create_worker::jk_worker.c (153): about to create instance bar of ajp13
173 [debug] ajp_worker_factory::jk_ajp_common.c (3218): ajp worker 'bar' type=2 created
174 [debug] wc_create_worker::jk_worker.c (166): about to validate and init bar
175 [debug] ajp_validate::jk_ajp_common.c (2862): worker bar target is '192.168.157.130:8209'
176 [debug] jk_ajp_push::jk_ajp_common.c (1190): syncing shm for ajp worker 'bar' from mem (0->0) [0->0]
177 [debug] ajp_init::jk_ajp_common.c (3076): (bar) setting endpoint options:
178 [debug] ajp_init::jk_ajp_common.c (3080): keepalive:              0
179 [debug] ajp_init::jk_ajp_common.c (3084): socket timeout:         0
180 [debug] ajp_init::jk_ajp_common.c (3088): socket connect timeout: 0
181 [debug] ajp_init::jk_ajp_common.c (3092): buffer size:            0
182 [debug] ajp_init::jk_ajp_common.c (3096): pool timeout:           0
183 [debug] ajp_init::jk_ajp_common.c (3100): ping timeout:           10000
184 [debug] ajp_init::jk_ajp_common.c (3104): connect timeout:        0
185 [debug] ajp_init::jk_ajp_common.c (3108): reply timeout:          0
186 [debug] ajp_init::jk_ajp_common.c (3112): prepost timeout:        0
187 [debug] ajp_init::jk_ajp_common.c (3116): recovery options:       0
188 [debug] ajp_init::jk_ajp_common.c (3120): retries:                2
189 [debug] ajp_init::jk_ajp_common.c (3124): max packet size:        8192
190 [debug] ajp_init::jk_ajp_common.c (3128): retry interval:         100
191 [debug] ajp_init::jk_ajp_common.c (3132): busy limit:         0
192 [debug] ajp_create_endpoint_cache::jk_ajp_common.c (2932): (bar) setting connection pool size to 1 with min 1 and acquire timeout 200
193 [debug] build_worker_map::jk_worker.c (249): creating worker foo
194 [debug] wc_create_worker::jk_worker.c (153): about to create instance foo of ajp13
195 [debug] ajp_worker_factory::jk_ajp_common.c (3218): ajp worker 'foo' type=2 created
196 [debug] wc_create_worker::jk_worker.c (166): about to validate and init foo
197 [debug] ajp_validate::jk_ajp_common.c (2862): worker foo target is '192.168.157.130:8309'
198 [debug] jk_ajp_push::jk_ajp_common.c (1190): syncing shm for ajp worker 'foo' from mem (0->0) [0->0]
199 [debug] ajp_init::jk_ajp_common.c (3076): (foo) setting endpoint options:
200 [debug] ajp_init::jk_ajp_common.c (3080): keepalive:              0
201 [debug] ajp_init::jk_ajp_common.c (3084): socket timeout:         0
202 [debug] ajp_init::jk_ajp_common.c (3088): socket connect timeout: 0
203 [debug] ajp_init::jk_ajp_common.c (3092): buffer size:            0
204 [debug] ajp_init::jk_ajp_common.c (3096): pool timeout:           0
205 [debug] ajp_init::jk_ajp_common.c (3100): ping timeout:           10000
206 [debug] ajp_init::jk_ajp_common.c (3104): connect timeout:        0
207 [debug] ajp_init::jk_ajp_common.c (3108): reply timeout:          0
208 [debug] ajp_init::jk_ajp_common.c (3112): prepost timeout:        0
209 [debug] ajp_init::jk_ajp_common.c (3116): recovery options:       0
210 [debug] ajp_init::jk_ajp_common.c (3120): retries:                2
211 [debug] ajp_init::jk_ajp_common.c (3124): max packet size:        8192
212 [debug] ajp_init::jk_ajp_common.c (3128): retry interval:         100
213 [debug] ajp_init::jk_ajp_common.c (3132): busy limit:         0
214 [debug] ajp_create_endpoint_cache::jk_ajp_common.c (2932): (foo) setting connection pool size to 1 with min 1 and acquire timeout 200
215 [info] init_jk::mod_jk.c (3591): mod_jk/1.2.48 initialized
216 [debug] uri_worker_map_dump::jk_uri_worker_map.c (177): uri map dump after extension stripping: id=1, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
217 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 0: size=0 nosize=0 capacity=0
218 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 1: size=0 nosize=0 capacity=0
219 [debug] uri_worker_map_switch::jk_uri_worker_map.c (601): Switching uri worker map from index 0 to index 1
220 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker bar
221 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
222 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker bar of type ajp13 (2)
223 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker foo
224 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
225 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker foo of type ajp13 (2)
226 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker bar
227 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
228 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker bar of type ajp13 (2)
229 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker foo
230 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
231 [debug] extension_fix_activation::jk_uri_worker_map.c (486): Checking extension for worker foo of type ajp13 (2)
232 [debug] uri_worker_map_dump::jk_uri_worker_map.c (177): uri map dump after extension stripping: id=2, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
233 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 0: size=0 nosize=0 capacity=0
234 [debug] uri_worker_map_dump::jk_uri_worker_map.c (183): generation 1: size=4 nosize=0 capacity=4
235 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #0: uri=/bar/* worker=bar context=/bar/* source=JkMount type=Wildchar len=6
236 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #1: uri=/foo/* worker=foo context=/foo/* source=JkMount type=Wildchar len=6
237 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #2: uri=/bar worker=bar context=/bar source=JkMount type=Exact len=4
238 [debug] uri_worker_map_dump::jk_uri_worker_map.c (196): NEXT (1) map #3: uri=/foo worker=foo context=/foo source=JkMount type=Exact len=4
239 [debug] uri_worker_map_switch::jk_uri_worker_map.c (601): Switching uri worker map from index 0 to index 1
240 [debug] do_shm_open::jk_shm.c (678): Attached shared memory /var/cache/httpd/mod_jk/jk.shm.7403 [2] size=1152 workers=1 free=0 addr=0x7f88473a0000
241 [debug] do_shm_open_lock::jk_shm.c (472): Duplicated shared memory lock /var/cache/httpd/mod_jk/jk.shm.7403.lock
242 [debug] jk_child_init::mod_jk.c (3474): Initialized mod_jk/1.2.48
243 [debug] do_shm_open::jk_shm.c (678): Attached shared memory /var/cache/httpd/mod_jk/jk.shm.7403 [3] size=1152 workers=1 free=0 addr=0x7f88473a0000
244 [debug] do_shm_open_lock::jk_shm.c (472): Duplicated shared memory lock /var/cache/httpd/mod_jk/jk.shm.7403.lock
245 [debug] jk_child_init::mod_jk.c (3474): Initialized mod_jk/1.2.48
246 [debug] do_shm_open::jk_shm.c (678): Attached shared memory /var/cache/httpd/mod_jk/jk.shm.7403 [4] size=1152 workers=1 free=0 addr=0x7f88473a0000
247 [debug] do_shm_open_lock::jk_shm.c (472): Duplicated shared memory lock /var/cache/httpd/mod_jk/jk.shm.7403.lock
248 [debug] jk_child_init::mod_jk.c (3474): Initialized mod_jk/1.2.48
249 [debug] do_shm_open::jk_shm.c (678): Attached shared memory /var/cache/httpd/mod_jk/jk.shm.7403 [5] size=1152 workers=1 free=0 addr=0x7f88473a0000
250 [debug] do_shm_open_lock::jk_shm.c (472): Duplicated shared memory lock /var/cache/httpd/mod_jk/jk.shm.7403.lock
251 [debug] jk_child_init::mod_jk.c (3474): Initialized mod_jk/1.2.48
252 [debug] do_shm_open::jk_shm.c (678): Attached shared memory /var/cache/httpd/mod_jk/jk.shm.7403 [6] size=1152 workers=1 free=0 addr=0x7f88473a0000
253 [debug] do_shm_open_lock::jk_shm.c (472): Duplicated shared memory lock /var/cache/httpd/mod_jk/jk.shm.7403.lock
254 [debug] jk_child_init::mod_jk.c (3474): Initialized mod_jk/1.2.48
255 [debug] jk_servlet_normalize::jk_util.c (2184): URI on entering jk_servlet_normalize: [/bar/]
256 [debug] jk_servlet_normalize::jk_util.c (2278): URI on exiting jk_servlet_normalize: [/bar/]
257 [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1167): Attempting to map URI '/bar/' from 4 maps
258 [debug] find_match::jk_uri_worker_map.c (977): Attempting to map context URI '/bar/*=bar' source 'JkMount'
259 [debug] find_match::jk_uri_worker_map.c (990): Found a wildchar match '/bar/*=bar'
260 [debug] jk_handler::mod_jk.c (2821): Into handler jakarta-servlet worker=bar r->proxyreq=0
261 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker bar
262 [debug] wc_maintain::jk_worker.c (352): Maintaining worker bar
263 [debug] wc_maintain::jk_worker.c (352): Maintaining worker foo
264 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
265 [debug] init_ws_service::mod_jk.c (1178): Service protocol=HTTP/1.1 method=GET ssl=false host=(null) addr=192.168.157.1 name=192.168.157.130 port=80 auth=(null) user=(null) laddr=192.168.157.130 raddr=192.168.157.1 uaddr=192.168.157.1 uri=/ba        r/
266 [debug] ajp_get_endpoint::jk_ajp_common.c (3356): (bar) acquired connection pool slot=0 after 0 retries
267 [debug] ajp_marshal_into_msgb::jk_ajp_common.c (680): (bar) ajp marshaling done
268 [debug] ajp_service::jk_ajp_common.c (2587): processing bar with 2 retries
269 [debug] ajp_send_request::jk_ajp_common.c (1718): (bar) no usable connection found, will create a new one.
270 [debug] jk_open_socket::jk_connect.c (673): socket TCP_NODELAY set to On
271 [debug] jk_open_socket::jk_connect.c (797): trying to connect socket 45 to 192.168.157.130:8209
272 [info] jk_open_socket::jk_connect.c (815): connect to 192.168.157.130:8209 failed (errno=13)
273 [info] ajp_connect_to_endpoint::jk_ajp_common.c (1064): (bar) Failed opening socket to (192.168.157.130:8209) (errno=13)
274 [error] ajp_send_request::jk_ajp_common.c (1724): (bar) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=13)
275 [info] ajp_service::jk_ajp_common.c (2774): (bar) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
276 [debug] ajp_service::jk_ajp_common.c (2623): (bar) retry 1, sleeping for 100 ms before retrying
277 [debug] ajp_send_request::jk_ajp_common.c (1718): (bar) no usable connection found, will create a new one.
278 [debug] jk_open_socket::jk_connect.c (673): socket TCP_NODELAY set to On
279 [debug] jk_open_socket::jk_connect.c (797): trying to connect socket 45 to 192.168.157.130:8209
280 [info] jk_open_socket::jk_connect.c (815): connect to 192.168.157.130:8209 failed (errno=13)
281 [info] ajp_connect_to_endpoint::jk_ajp_common.c (1064): (bar) Failed opening socket to (192.168.157.130:8209) (errno=13)
282 [error] ajp_send_request::jk_ajp_common.c (1724): (bar) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=13)
283 [info] ajp_service::jk_ajp_common.c (2774): (bar) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
284 [error] ajp_service::jk_ajp_common.c (2795): (bar) connecting to tomcat failed (rc=-3, errors=1, client_errors=0).
285 [debug] ajp_reset_endpoint::jk_ajp_common.c (847): (bar) resetting endpoint with socket -1 (socket shutdown)
286 [debug] ajp_abort_endpoint::jk_ajp_common.c (817): (bar) aborting endpoint with socket -1
287 [debug] ajp_done::jk_ajp_common.c (3287): recycling connection pool for worker bar and socket -1
288 [info] jk_handler::mod_jk.c (2991): Service error=-3 for worker=bar
289 [Wed Sep 06 04:32:49 2023] bar 192.168.157.130 0.101021
290 [debug] jk_servlet_normalize::jk_util.c (2184): URI on entering jk_servlet_normalize: [/foo]
291 [debug] jk_servlet_normalize::jk_util.c (2278): URI on exiting jk_servlet_normalize: [/foo]
292 [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1167): Attempting to map URI '/foo' from 4 maps
293 [debug] find_match::jk_uri_worker_map.c (977): Attempting to map context URI '/bar/*=bar' source 'JkMount'
294 [debug] find_match::jk_uri_worker_map.c (977): Attempting to map context URI '/foo/*=foo' source 'JkMount'
295 [debug] find_match::jk_uri_worker_map.c (977): Attempting to map context URI '/bar=bar' source 'JkMount'
296 [debug] find_match::jk_uri_worker_map.c (977): Attempting to map context URI '/foo=foo' source 'JkMount'
297 [debug] find_match::jk_uri_worker_map.c (1000): Found an exact match '/foo=foo'
298 [debug] jk_handler::mod_jk.c (2821): Into handler jakarta-servlet worker=foo r->proxyreq=0
299 [debug] wc_get_worker_for_name::jk_worker.c (119): found a worker foo
300 [debug] wc_maintain::jk_worker.c (352): Maintaining worker bar
301 [debug] wc_maintain::jk_worker.c (352): Maintaining worker foo
302 [debug] wc_get_name_for_type::jk_worker.c (303): Found worker type 'ajp13'
303 [debug] init_ws_service::mod_jk.c (1178): Service protocol=HTTP/1.1 method=GET ssl=false host=(null) addr=192.168.157.1 name=192.168.157.130 port=80 auth=(null) user=(null) laddr=192.168.157.130 raddr=192.168.157.1 uaddr=192.168.157.1 uri=/fo        o
304 [debug] ajp_get_endpoint::jk_ajp_common.c (3356): (foo) acquired connection pool slot=0 after 0 retries
305 [debug] ajp_marshal_into_msgb::jk_ajp_common.c (680): (foo) ajp marshaling done
306 [debug] ajp_service::jk_ajp_common.c (2587): processing foo with 2 retries
307 [debug] ajp_send_request::jk_ajp_common.c (1718): (foo) no usable connection found, will create a new one.
308 [debug] jk_open_socket::jk_connect.c (673): socket TCP_NODELAY set to On
309 [debug] jk_open_socket::jk_connect.c (797): trying to connect socket 45 to 192.168.157.130:8309
310 [info] jk_open_socket::jk_connect.c (815): connect to 192.168.157.130:8309 failed (errno=13)
311 [info] ajp_connect_to_endpoint::jk_ajp_common.c (1064): (foo) Failed opening socket to (192.168.157.130:8309) (errno=13)
312 [error] ajp_send_request::jk_ajp_common.c (1724): (foo) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=13)
313 [info] ajp_service::jk_ajp_common.c (2774): (foo) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
314 [debug] ajp_service::jk_ajp_common.c (2623): (foo) retry 1, sleeping for 100 ms before retrying
315 [debug] ajp_send_request::jk_ajp_common.c (1718): (foo) no usable connection found, will create a new one.
316 [debug] jk_open_socket::jk_connect.c (673): socket TCP_NODELAY set to On
317 [debug] jk_open_socket::jk_connect.c (797): trying to connect socket 45 to 192.168.157.130:8309
318 [info] jk_open_socket::jk_connect.c (815): connect to 192.168.157.130:8309 failed (errno=13)
319 [info] ajp_connect_to_endpoint::jk_ajp_common.c (1064): (foo) Failed opening socket to (192.168.157.130:8309) (errno=13)
320 [error] ajp_send_request::jk_ajp_common.c (1724): (foo) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=13)
321 [info] ajp_service::jk_ajp_common.c (2774): (foo) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
322 [error] ajp_service::jk_ajp_common.c (2795): (foo) connecting to tomcat failed (rc=-3, errors=1, client_errors=0).
323 [debug] ajp_reset_endpoint::jk_ajp_common.c (847): (foo) resetting endpoint with socket -1 (socket shutdown)
324 [debug] ajp_abort_endpoint::jk_ajp_common.c (817): (foo) aborting endpoint with socket -1
325 [debug] ajp_done::jk_ajp_common.c (3287): recycling connection pool for worker foo and socket -1
326 [info] jk_handler::mod_jk.c (2991): Service error=-3 for worker=foo
327 [Wed Sep 06 04:32:59 2023] foo 192.168.157.130 0.100528

当我像这样在 Mac 桌面 Safari(以及 Chrome)上测试我的应用程序时,

  1. http://192.168.157.130/bar
  2. http://192.168.157.130/foo

这两种情况都会引发上述错误。 但是,当我通过包含端口号来测试站点时:

  1. http://192.168.157.130:8280/bar
  2. http://192.168.157.130:8380/foo

两者都成功显示测试站点。

配置文件

Apache Httpd (/etc/httpd/conf/httpd.conf)

<VirtualHost *:80>
   ServerName artemis.com

   JkMount /bar bar
   JkMount /bar/* bar

   JkMount /foo foo
   JkMount /foo/* foo
</VirtualHost>

模组 JK

LoadModule jk_module modules/mod_jk.so

#-- Path to workers.properties
JkWorkersFile conf/workers.properties

#-- Path to jk logs
JkLogFile logs/mod_jk.log

#-- Jk log level [debug/error/info]
JkLogLevel debug

#-- Jk log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

#-- JkOptions for forwarding
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

#-- JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile /var/cache/httpd/mod_jk/jk.shm

Workers 文件

worker.list=bar,foo

#-- @instance demo /bar (port 8280)
worker.bar.port=8209
worker.bar.host=192.168.157.130
worker.bar.type=ajp13

#-- @instance expo /foo (port 8380)
worker.foo.port=8309
worker.foo.host=192.168.157.130
worker.foo.type=ajp13

Tomcat 安装在 /usr/local/apache-tomcat-9.0.80 中 Tomcat 实例安装在 /var/lib/tomcats 中

Tomcat 实例“demo”(/var/lib/tomcats/demo)

<Server port="8205" shutdown="SHUTDOWN">  

<Connector port="8280" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443"
    maxParameterCount="1000"
/>                                                                    

<Connector protocol="AJP/1.3"
    address="192.168.157.130"
    port="8209"
    redirectPort="8443"
    maxParameterCount="1000"
    secretRequired=”false”
/>

Tomcat 实例“expo”(/var/lib/tomcats/expo)

<Server port="8305" shutdown="SHUTDOWN">

<Connector port="8380" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443"
    maxParameterCount="1000"
/>                                                                    

<Connector protocol="AJP/1.3"
    address="192.168.157.130"
    port="8309"
    redirectPort="8443"
    maxParameterCount="1000"
    secretRequired=”false”
/>

其他条件

$ uname -a
Linux artemis 5.4.17-2136.322.6.2.el7uek.x86_64 x86_64 GNU/Linux

$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
  inet 192.168.157.130  netmask 255.255.255.0  broadcast 192.168.157.255

$ vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.157.130 artemis.com

$ java -version
openjdk version "11.0.20" 2023-07-18 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.20.0.8-1.0.1.el7_9) (build 11.0.20+8-LTS)

显影机

Apple Mac mini (2018), macOS Catalina, Intel Core i5
Hypervisor: VMWare Fusion v11.5.3
VM: Oracle Linux R7 U9
阿帕奇 雄猫

评论


答: 暂无答案