简体   繁体   English

Mod_jk 和 Tomcat 卡在发送回复

[英]Mod_jk and Tomcat stuck at Sending Reply

Currently, the server at work is underperforming and the way it's set up is not ideal either.目前,工作中的服务器性能不佳,其设置方式也不理想。 For this reason I'm trying to find a new way to do things that will hopefully help with both, performance and deployment.出于这个原因,我试图找到一种新的方法来做一些希望对性能和部署都有帮助的事情。

The approach I decided for is to have tomcat instances for our webapps (currently there are two, so it'd be an instance per webapp) and use Apache as a "front".我决定采用的方法是为我们的 webapps 使用 tomcat 实例(目前有两个,因此每个 webapp 都有一个实例),并使用 Apache 作为“前端”。 I'm not experienced in this, so It's normal I'm having issues here and there, but so far I've manage to get this going.我没有这方面的经验,所以我在这里和那里遇到问题是正常的,但到目前为止我已经设法解决了这个问题。

What I expect is to redirect from mysite.com index page to either mysite.com/service1 or mysite.com/service2.我期望从 mysite.com 索引页面重定向到 mysite.com/service1 或 mysite.com/service2。 Service1 was setup in out test server at port 8080 and service2 at 8081. I installed Apache2 and mod_jk yesterday and set up apache with the contents of mysite.com. Service1 设置在测试服务器的 8080 端口和 service2 的 8081。我昨天安装了 Apache2 和 mod_jk 并设置了 apache 与 mysite.Z4D236D9A204102C0ZFE6ADB1 的内容Today I started the configurations, that ended up as follow:今天我开始配置,结果如下:

workers.properties worker.properties

worker.list=s1

worker.s1.type=ajp13
worker.s1.port=8009

#host is localhost by default according to the documentation

jk.load jk.load

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

JkWorkersFile /etc/apache2/workers.properties

JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
JkMount /service1/* s1

Service1's server.xml connector (The rest is all default) Service1的服务器。xml连接器(rest是默认的)

<Connector protocol="AJP/1.3" port="8009" redirectPort="8443" />

I had more, but because of the errors, I took a step back and tried with only one tomcat for now.我有更多,但由于错误,我退后一步,现在只尝试了一个 tomcat。 I will add the second tomcat and a loadbalancer.我将添加第二个 tomcat 和一个负载均衡器。

Ok, so what's going on?好的,那是怎么回事?

I can access the server and the index page of our system with no problem.我可以毫无问题地访问我们系统的服务器和索引页面。 The problem is when I try to redirect to service1.问题是当我尝试重定向到 service1 时。 It just loads without response, but if I try to access service1 directly by port 8080, it works properly (I tired commenting out this connector. No luck).它只是加载而没有响应,但是如果我尝试通过端口 8080 直接访问 service1,它可以正常工作(我厌倦了注释掉这个连接器。没有运气)。

Looking at server-status, I see the request stuck at w/sending reply, and in mod_jk.log I see that the worker properly matches the request.查看服务器状态,我看到请求停留在发送回复,并且在 mod_jk.log 中我看到工作人员正确匹配请求。 So while my configurations seem to be right, there is something in between happening.因此,虽然我的配置似乎是正确的,但在两者之间发生了一些事情。 I don't really know if it's something with Apache, Tomcat or Mod_jk.我真的不知道它是否与 Apache、Tomcat 或 Mod_jk 有关。 I also tried to follow several guides of how to do this, but all of them got me to 404s.我还尝试遵循几个如何做到这一点的指南,但所有这些都让我进入了 404。 Looking around here and ServerFault didn't shed much light unfortunately so I'm the one asking now.环顾四周,不幸的是,ServerFault 并没有透露太多信息,所以我现在就问这个问题。

Am I missing something?我错过了什么吗? Should I just use another approach?我应该只使用另一种方法吗? I'm very new at this and I'm at loss right now.我对此很陌生,现在我很茫然。 The configuration and the logs show that nothing is really wrong (at first glance, at least...) so I'm entirely sure if my case scneario is even posible with mod_jk... HOnestly to run it back and try with proxy is very tempting at this point, but if I am, I'd rather know where Im wrong.配置和日志显示并没有什么问题(乍一看,至少......)所以我完全确定我的案例 scneario 是否可以使用 mod_jk ......诚实地运行它并尝试使用代理是在这一点上非常诱人,但如果我是,我宁愿知道我错在哪里。

Additional info: Running on Ubuntu Server 18.04, lastest apache2 and mod_jk avaliable from apt (as of Apr 14), java 1.8 and Tomcat 8.5.64. Additional info: Running on Ubuntu Server 18.04, lastest apache2 and mod_jk avaliable from apt (as of Apr 14), java 1.8 and Tomcat 8.5.64.

There was a change in Tomcat last year (from version 8.5.51 and version 9.0.31 ), which introduced a secretRequired attribute to the AJP connector with a default of true (cf. documentation ).去年 Tomcat 发生了变化(从版本8.5.51和版本9.0.31 开始),它为 AJP 连接器引入了一个secretRequired属性,默认值为true (参见文档)。 Hence you can either:因此,您可以:

  • add a shared secret between the AJP connector and mod_jk在 AJP 连接器和mod_jk之间添加共享密钥

  • or add secretRequired="false" to the AJP connector:或将secretRequired="false"添加到 AJP 连接器:

     <Connector protocol="AJP/1.3" port="8009" secretRequired="false" redirectPort="8443" />

Remark: AJP is a very old protocol and rarely used.备注: AJP 是一个非常古老的协议,很少使用。 Since your installation is pretty new, you might consider using directly HTTP (cf. this talk ).由于您的安装是相当新的,您可以考虑直接使用 HTTP(参见this talk )。

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

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