我有一个简单的服务器设置:
- Apache 2.4.6
- JK Worker 用于与 REST 服务所在的 Tomcat 进行通信
- 雄猫 10
虚拟主机
在我的虚拟主机文件中我有这个配置(节选<VirtualHost *:443>
):
<Directory "/var/www/frontends">
Require all granted
RewriteEngine On
# [...]
RewriteRule co2avatar-app/sdp-api$ sdp-api/test/ [PT]
RewriteRule co2avatar-app/sdp-api/(.*)$ sdp-api/$1 [PT]
# anything else to index.html
RewriteRule co2avatar-app/(.+) co2avatar-app/index.html [L]
</Directory>
# worker definition
JkMount /sdp-api/* ajp13_worker_prod
JkMount /sdp-api ajp13_worker_prod
工人
# workers.properties -
# workers.tomcat_home=/opt/tomcat/latest/
#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/lib/jvm/
ps=/
worker.list=ajp13_worker_prod,ajp13_worker_test,ajp13_worker_tomcat10_test,ajp_worker_tomcat10_prod
#
#------ ajp13_worker WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#
worker.ajp13_worker_prod.port=8009
worker.ajp13_worker_prod.host=localhost
worker.ajp13_worker_prod.type=ajp13
worker.ajp13_worker_test.port=8010
worker.ajp13_worker_test.host=localhost
worker.ajp13_worker_test.type=ajp13
worker.ajp13_worker_tomcat10_test.port=8020
worker.ajp13_worker_tomcat10_test.host=localhost
worker.ajp13_worker_tomcat10_test.type=ajp13
worker.ajp13_worker_tomcat10_prod.port=8019
worker.ajp13_worker_tomcat10_prod.host=localhost
worker.ajp13_worker_tomcat10_prod.type=ajp13
# we do not use load balancing at all.
我应该补充的是ajp13_worker_prodworker 指向 Tomcat 9 实例中的一个服务,ajp13_worker_tomcat10_prod工作器到 Tomcat 10 实例。但是这对于不同的虚拟主机(实际上是测试系统)来说非常有效。
一切都很好,直到我改变线路
JkMount /sdp-api/* ajp13_worker_prod
JkMount /sdp-api ajp13_worker_prod
到
JkMount /sdp-api/* ajp13_worker_tomcat10_prod
JkMount /sdp-api ajp13_worker_tomcat10_prod
Tomcat 中的服务运行良好,我可以通过 访问它们curl http://localhost:6085/[...]
。因此端口已开放,可供本地主机使用。
但我无法联系到他们从外面,通过 Apache。我在这里得到一个500和The server encountered an internal error or misconfiguration and was unable to complete your request.
我扫描了所有可能的错误日志文件,但找不到问题,尤其是在 Apache 日志中。
有没有什么办法可以测试 JK 工人?
有没有什么办法可以测试 Tomcat 连接器?
它看起来像这样服务器.xml:
<Connector port="8019" proxyName="co2avatar.org" proxyPort="80" protocol="AJP/1.3" redirectPort="8443" secretRequired="false" />
。HTTP 连接器可以工作,但这个可能不行?Apache(ajp 工作程序)和 Tomcat 之间存在问题,但仅向 Apache 发出请求还无济于事。
(初学者问题:)是否可以仅重新启动 JK 模块?
以下是 Apache 的摘录错误日志(mod_jk.log 中没有任何内容):
[jk:warn] [pid 1286] No JkShmFile defined in httpd.conf. Using default /etc/httpd/logs/jk-runtime-status
[slotmem_shm:debug] [pid 1286] mod_slotmem_shm.c(448): AH02301: attach looking for /run/httpd/slotmem-shm-mod_heartmonitor.shm
[lbmethod_heartbeat:notice] [pid 1286] AH02282: No slotmem from mod_heartmonitor
[ssl:debug] [pid 1286] ssl_engine_pphrase.c(181): AH02199: SSL not enabled on vhost h2862201.stratoserver.net:80, skipping SSL setup
[ssl:debug] [pid 1286] ssl_engine_pphrase.c(239): AH02202: Init: Read server certificate from '/etc/letsencrypt/live/co2-avatar.com/cert.pem'
[ssl:debug] [pid 1286] ssl_engine_pphrase.c(239): AH02202: Init: Read server certificate from '/etc/letsencrypt/live/co2-avatar.com/cert.pem'
[ssl:debug] [pid 1286] ssl_engine_pphrase.c(239): AH02202: Init: Read server certificate from '/etc/letsencrypt/live/co2-avatar.com/fullchain.pem'
[ssl:debug] [pid 1286] ssl_engine_pphrase.c(239): AH02202: Init: Read server certificate from '/etc/letsencrypt/live/co2-avatar.com/cert.pem'
[ssl:debug] [pid 1286] ssl_engine_pphrase.c(239): AH02202: Init: Read server certificate from '/etc/letsencrypt/live/co2-avatar.com/cert.pem'
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(391): AH00821: shmcb_init allocated 512000 bytes of shared memory
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(407): AH00822: for 511912 bytes (512000 including header), recommending 32 subcaches, 88 indexes each
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(440): AH00824: shmcb_init_memory choices follow
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(442): AH00825: subcache_num = 32
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(444): AH00826: subcache_size = 15992
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(446): AH00827: subcache_data_offset = 2128
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(448): AH00828: subcache_data_size = 13864
[socache_shmcb:debug] [pid 1286] mod_socache_shmcb.c(450): AH00829: index_num = 88
[socache_shmcb:info] [pid 1286] AH00830: Shared memory socache initialised
[ssl:info] [pid 1286] AH01887: Init: Initializing (virtual) servers for SSL
[ssl:debug] [pid 1286] ssl_engine_init.c(1502): Init: SSL server IP/port overlap: h2862201.stratoserver.net:443 (/etc/httpd/conf.d/ssl.conf:57) vs. co2-avatar.com:443 (/etc/httpd/conf.d/vhost-le-ssl.conf:4)
[ssl:debug] [pid 1286] ssl_engine_init.c(1502): Init: SSL server IP/port overlap: gitlab.sustainable-data-platform.org:443 (/etc/httpd/conf.d/gitlab-le-ssl.conf:2) vs. co2-avatar.com:443 (/etc/httpd/conf.d/vhost-le-ssl.conf:4)
[ssl:debug] [pid 1286] ssl_engine_init.c(1502): Init: SSL server IP/port overlap: co2avatar.org:443 (/etc/httpd/conf.d/co2avatar.conf:66) vs. co2-avatar.com:443 (/etc/httpd/conf.d/vhost-le-ssl.conf:4)
[ssl:warn] [pid 1286] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[ssl:info] [pid 1286] AH01876: mod_ssl/2.4.6 compiled against Server: Apache/2.4.6, Library: OpenSSL/1.0.2k
[proxy:debug] [pid 1292] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1292] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1292] proxy_util.c(1939): AH00931: initialized single connection worker in child 1292 for (*)
[proxy:debug] [pid 1293] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1293] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1293] proxy_util.c(1939): AH00931: initialized single connection worker in child 1293 for (*)
[proxy:debug] [pid 1295] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1295] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1295] proxy_util.c(1939): AH00931: initialized single connection worker in child 1295 for (*)
[mpm_prefork:notice] [pid 1286] AH00163: Apache/2.4.6 (CentOS) mod_jk/1.2.48 OpenSSL/1.0.2k-fips PHP/7.2.29 configured -- resuming normal operations
[mpm_prefork:info] [pid 1286] AH00164: Server built: Nov 16 2020 16:18:20
[core:notice] [pid 1286] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[mpm_prefork:debug] [pid 1286] prefork.c(1005): AH00165: Accept mutex: sysvsem (default: sysvsem)
[proxy:debug] [pid 1294] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1294] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1294] proxy_util.c(1939): AH00931: initialized single connection worker in child 1294 for (*)
[proxy:debug] [pid 1296] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1296] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1296] proxy_util.c(1939): AH00931: initialized single connection worker in child 1296 for (*)
[proxy:debug] [pid 1378] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1378] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1378] proxy_util.c(1939): AH00931: initialized single connection worker in child 1378 for (*)
[proxy:debug] [pid 1408] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1408] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1408] proxy_util.c(1939): AH00931: initialized single connection worker in child 1408 for (*)
[proxy:debug] [pid 1859] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 1859] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 1859] proxy_util.c(1939): AH00931: initialized single connection worker in child 1859 for (*)
[proxy:debug] [pid 15109] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 15109] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 15109] proxy_util.c(1939): AH00931: initialized single connection worker in child 15109 for (*)
[proxy:debug] [pid 17029] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[proxy:debug] [pid 17029] proxy_util.c(1888): AH00927: initializing worker proxy:reverse local
[proxy:debug] [pid 17029] proxy_util.c(1939): AH00931: initialized single connection worker in child 17029 for (*)
答案1
嗯,这很尴尬,但是我在工人名单中使用了错误的名字。
ajp_worker_tomcat10_prod
代替ajp13_worker_tomcat10_prod
。
有趣的是,没有出现类似这样的错误信息找不到工人或者worker 没有配置。只有来自 Apache 的奇怪消息,没有任何内容mod_jk.log或 Apache 的错误日志。
这也可能是一个配置问题。