如何通过mod_jk强制请求到特定工作者?

时间:2021-06-21 16:52:48

If I have mod_jk set up with several workers and a load balancer worker, is there a request parameter or something that would allow me to force a specific http request down to a specific worker. For instance if I have a worker worker1 is there something like this:

如果我有几个worker和一个负载均衡器工作程序设置mod_jk,是否有一个请求参数或某些东西,允许我强制特定的http请求下降到特定的工作者。例如,如果我有一个worker worker1,有这样的东西:

http://www.example.com?worker=worker1

Often we need to troubleshoot problems on a specific server in the cluster and being able to force the request directly to that server is essential.

通常,我们需要对群集中特定服务器上的问题进行故障排除,并且能够将请求直接强制到该服务器是必不可少的。

2 个解决方案

#1


I think the common practice is to do that via subdomains which alias the main domain. Just make sure that you don't let Google index because you'll have duplicate content issues. IP filtering and a restrictive robots.txt will do the job.

我认为通常的做法是通过别名主域的子域来实现。请确保您不要让Google进行索引,因为您会遇到重复的内容问题。 IP过滤和限制性robots.txt将完成这项工作。

www1.example.com
www2.example.com

#2


  1. Tweak the value of your JSESSIONID cookie. The end has the name of the worker you're stuck to (assuming you're doing sticky sessions)

    调整JSESSIONID cookie的值。结尾有你坚持的工人的名字(假设你正在做粘性会话)

  2. Use SetHandler as described here http://tomcat.apache.org/connectors-doc/reference/apache.html instead of JKMount directives

    使用此处描述的SetHandler http://tomcat.apache.org/connectors-doc/reference/apache.html而不是JKMount指令

    Something like this:

    像这样的东西:

    
       <Location />  
          SetHandler jakarta-servlet  
          SetEnvIf REQUEST_URI ^/.*\?.*worker=(\w+)&?$ JK_WORKER_NAME=$1  
       </Location>
    

#1


I think the common practice is to do that via subdomains which alias the main domain. Just make sure that you don't let Google index because you'll have duplicate content issues. IP filtering and a restrictive robots.txt will do the job.

我认为通常的做法是通过别名主域的子域来实现。请确保您不要让Google进行索引,因为您会遇到重复的内容问题。 IP过滤和限制性robots.txt将完成这项工作。

www1.example.com
www2.example.com

#2


  1. Tweak the value of your JSESSIONID cookie. The end has the name of the worker you're stuck to (assuming you're doing sticky sessions)

    调整JSESSIONID cookie的值。结尾有你坚持的工人的名字(假设你正在做粘性会话)

  2. Use SetHandler as described here http://tomcat.apache.org/connectors-doc/reference/apache.html instead of JKMount directives

    使用此处描述的SetHandler http://tomcat.apache.org/connectors-doc/reference/apache.html而不是JKMount指令

    Something like this:

    像这样的东西:

    
       <Location />  
          SetHandler jakarta-servlet  
          SetEnvIf REQUEST_URI ^/.*\?.*worker=(\w+)&?$ JK_WORKER_NAME=$1  
       </Location>