如何从DocumentRoot提供一些路径模式,从modjk提供其他路径模式?

时间:2022-01-10 14:09:57

We have an existing situation where we have Apache 2.0 HTTPD acting as the load balancer for a cluster of backend tomcats, using mod_jk 1.2 to communicate between the two. The applications themselves are stored on the tomcat servers, and so all requests are passed through (even images, css, etc) to tomcat, using the following in the virtual host configs:

我们现有的情况是Apache 2.0 HTTPD充当后端tomcats集群的负载均衡器,使用mod_jk 1.2在两者之间进行通信。应用程序本身存储在tomcat服务器上,因此所有请求都通过(甚至图像,css等)传递给tomcat,使用虚拟主机配置中的以下内容:

JkMount /* worker-name

The virtual hosts do not have a DocumentRoot defined, since all traffic goes down the pipe to tomcat.

虚拟主机没有定义DocumentRoot,因为所有流量都通过管道传递到tomcat。

We would like to start serving static content direct from Apache (a radical idea, I know). Given our application path structure, the only way to distinguish static from dynamic content is the file extension of the requested path. So, for example, all requests ending in .jpg, .css, .ico, etc would not be passed through the JkMount, but instead served from a DocumentRoot.

我们想开始直接从Apache提供静态内容(一个激进的想法,我知道)。根据我们的应用程序路径结构,区分静态内容和动态内容的唯一方法是请求路径的文件扩展名。因此,例如,以.jpg,.css,.ico等结尾的所有请求都不会通过JkMount传递,而是通过DocumentRoot传递。

So that's the context. My question is, how can I confgiure the vhost so that all requests which match a given pattern (specifically, my pattern of what we want to be served from apache) are served from the DocumentRoot, and all others passed to tomcat?

这就是上下文。我的问题是,我怎样才能使vhost成为可能,以便所有与给定模式匹配的请求(特别是我们希望从apache中提供的模式)都是从DocumentRoot提供的,而所有其他请求都传递给了tomcat?

Can this be done with a regex in JkMount? Is JkMount that flexible? If not, can I make use of mod_rewrite?

这可以用JkMount中的正则表达式来完成吗? JkMount是否灵活?如果没有,我可以使用mod_rewrite吗?

1 个解决方案

#1


You can use JkUnMount to indicate that certain requests not get handled by mod_jk. I've seen examples using file extensions and paths:

您可以使用JkUnMount指示某些请求不会被mod_jk处理。我见过使用文件扩展名和路径的示例:

JkMount /* worker-name
JkUnMount /*.jpg worker-name
JkUnMount /images/* worker-name

See here for more information.

浏览此处获取更多信息。

#1


You can use JkUnMount to indicate that certain requests not get handled by mod_jk. I've seen examples using file extensions and paths:

您可以使用JkUnMount指示某些请求不会被mod_jk处理。我见过使用文件扩展名和路径的示例:

JkMount /* worker-name
JkUnMount /*.jpg worker-name
JkUnMount /images/* worker-name

See here for more information.

浏览此处获取更多信息。