简体   繁体   English

我无法让 tomcat 连接器与 apache 一起使用,“找不到 /jk-status 的匹配项”

[英]I'm unable to get tomcat connectors to work with apache "no match for /jk-status found"

I deployed a springboot application to tomcat, I managed to connect it to the db and now I can access it throw the browser.我将一个 springboot 应用程序部署到 tomcat,我设法将它连接到数据库,现在我可以通过浏览器访问它。 eg: "www.mydomain.com:8080/spring_app/api/myendpoint" will return a value from SQL.例如:“www.mydomain.com:8080/spring_app/api/myendpoint”将返回 SQL 的值。

Of course now I want my angular app located in apache to reach this backend.当然,现在我希望位于 apache 中的 angular 应用程序到达此后端。 Since just accessing (localhost:8080/localhost/127.0.0.1) didn't work I found out I needed a connector to map certain requests from apache to tomcat. Tomcat connectors are meant for that.由于只是访问 (localhost:8080/localhost/127.0.0.1) 不起作用,我发现我需要一个连接器到 map 从 apache 到 tomcat 的某些请求。Tomcat 连接器就是为此而设计的。 Since I couldn't get my endpoint to work I started to try to get "jk-status" which is a default one to work.由于我无法让我的端点工作,我开始尝试让“jk-status”工作,这是默认的工作方式。 I still haven't managed because of the error "no match for /jk-status found".由于错误“找不到 /jk-status 的匹配项”,我仍然没有成功。

Apache is clearly trying because whatever I define as a connector in apache's config file will appear in the error shown above". Apache 显然是在尝试,因为我在 apache 的配置文件中定义为连接器的任何内容都会出现在上面显示的错误中”。

I'll attach my config and hopefully someone can help me because I've never spent this long trying to solve an issue and not fix it.我会附上我的配置,希望有人能帮助我,因为我从来没有花这么长时间试图解决问题而不是修复它。

-> FIRST FILE (apache config file): "Include httpd-jk.conf". -> 第一个文件(apache 配置文件):“包含 httpd-jk.conf”。

-> SECOND FILE (apache2/sites-available/api.mydomain.com.conf): -> 第二个文件(apache2/sites-available/api.mydomain.com.conf):

        Require all granted
</Directory>
<VirtualHost *:80>
        ServerName api.mydomain.com
        ServerAlias www.api.mydomain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/api.mydomain.com/html
        JkMount /jk-status/* jk-status

this last line mounts the jk-status connector which should display info about all the connectors最后一行安装了 jk-status 连接器,它应该显示所有连接器的信息

-> THIRD FILE (html for jk-status): In the document root specified above I have a file called jk-status which contains the connector configuration. -> 第三个文件(jk-status 的 html):在上面指定的文档根目录中,我有一个名为 jk-status 的文件,其中包含连接器配置。 (I don't really understand this file but I saw it somewhere). (我不太了解这个文件,但我在某处看到过)。

worker.list=jk-status
worker.jk-status.type=status

-> FOURTH FILE (connector config previously Included in the apache config httpd-jk.conf): -> 第四个文件(连接器配置先前包含在 apache 配置 httpd-jk.conf 中):

JkWorkersFile /opt/tomcat-connectors-1.2.48-src/conf/workers.properties

Shows the correct path to the workers.properties file显示 workers.properties 文件的正确路径

-> FIFTH FILE (workers.properties file): -> 第五个文件(workers.properties 文件):

worker.list=jk-status
worker.jk-status.type=status
worker.jk-status.read_only=true

This is the default config for jk-status connector.这是 jk-status 连接器的默认配置。

MOD_JK.LOG MOD_JK.LOG

[Mon Jan 09 14:15:58.963 2023] [31374:139970214833088] [debug] jk_servlet_normalize::jk_util.c (2184): URI on entering jk_servlet_normalize: [/jk-status]
[Mon Jan 09 14:15:58.963 2023] [31374:139970214833088] [debug] jk_servlet_normalize::jk_util.c (2278): URI on exiting jk_servlet_normalize: [/jk-status]
[Mon Jan 09 14:15:58.963 2023] [31374:139970214833088] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1167): Attempting to map URI '/jk-status' from 1 maps
[Mon Jan 09 14:15:58.963 2023] [31374:139970214833088] [debug] find_match::jk_uri_worker_map.c (977): Attempting to map context URI '/jk-status/*=jk-status' source 'JkMount'
[Mon Jan 09 14:15:58.963 2023] [31374:139970214833088] [debug] jk_map_to_storage::mod_jk.c (4074): no match for /jk-status found

all apache files, workers.properties, httpd-jk.conf have chown set to www:data (apache's user).所有 apache 文件、workers.properties、httpd-jk.conf 都将 chown 设置为 www:data(apache 的用户)。

I've reached a point in which I can access any file in the document root except the one named "jk-status".我已经达到了可以访问文档根目录中除名为“jk-status”的文件之外的任何文件的程度。 I want to think it's because the connector is trying something which looks like progress at least.我想这是因为连接器正在尝试至少看起来像进步的东西。

What am I missing, is my understanding of connectors correct?我错过了什么,我对连接器的理解是否正确? is this what I need in my case.这是我需要的吗?

Thank you.谢谢你。

I try to configure jk connector to redirect some apache requests' to tomcat我尝试配置 jk 连接器以将一些 apache 请求重定向到 tomcat

I understood your webapp is accessible under http://www.example.com:8080/spring_app/api/myendpoint and now you would like it to be accessible under http://www.example.com/spring_app/api/myendpoint also.我知道您的 webapp 可以在http://www.example.com:8080/spring_app/api/myendpoint下访问,现在您希望它也可以在http://www.example.com/spring_app/api/myendpoint下访问.

Here is what you need to do, based on what you already have.根据您已有的,这是您需要做的。

First, configure your VirtualHost to let mod_jk take care of all requests intended for your webapp.首先,配置您的 VirtualHost 以让 mod_jk 处理针对您的 webapp 的所有请求。

<VirtualHost *:80>
  ...
  # Let the worker named 'ajp13_worker' handle all requests
  # with a path beginning with '/spring_app/' 
  JkMount /spring_app/* ajp13_worker
  ...
</VirtualHost>

Second, define the worker with that name in your workers.properties.其次,在您的 workers.properties 中定义具有该名称的 worker。

worker.list=ajp13_worker
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13

Note the difference to your version, the type in particular.请注意您的版本的差异,特别是类型。 What you want is ajp13 .你想要的是ajp13 What you used, status , is a special type of worker designed for obtaining status information about mod_jk itself.您使用的status是一种特殊类型的 worker,旨在获取有关 mod_jk 本身的状态信息。 (The port and host must match the Connector configuration in Tomcat's server.xml , of course, but 8009 and localhost are enabled by default.) (当然,端口和主机必须与 Tomcat 的server.xml中的连接器配置匹配,但默认启用 8009 和本地主机。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM