Java EE 应用程序中静态和动态内容的分离
我们使用 IBM 产品,通常使用 IBM Http Server(即 Apache)作为应用程序服务器的反向代理。出于性能原因,我们从 http 服务器提供静态内容(.gif、.jpg、.css、.html 等),以减轻应用程序服务器的负担。
到目前为止,我们必须将文件分发到 http 服务器并手动配置它(最多编写自定义脚本)。问题是保持所有内容同步所需的努力,尤其是当您需要更新应用程序时。
有任何 Java EE 产品支持这种“开箱即用”吗?有没有办法让应用程序服务器自动执行此操作,例如在集群配置中,主节点负责将应用程序分发到其他节点并保持所有内容同步。
We work with IBM products and we typically use IBM Http Servers (read Apache) as a reverse proxy for our application servers. For performance reasons we serve static content (.gif, .jpg, .css, .html etc.) from our http servers, to ease the burden a bit from the application server.
So far, we have to distribute files to http server and configure it manually (writing custom scripts at best.) The problem is the effort needed to keep everything in synch, especially when you need to update the app.
Does any Java EE product support this “out of the box”? Is there a way to have application server do this automatically, like in cluster configuration for example, where master node is in charge of distributing the application to other nodes and for keeping everything in synch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定我是否了解配置部分。通常很容易区分静态内容与 JSP 和 Servlet(一旦完成,就不会发生太大变化)。
自动化!使用 Maven (或 Ant,但这需要更多的工作),很容易从 Web 项目创建单独的程序集来处理此问题:Java EE 节点的 WAR、Java EE 节点的静态内容的 zip HTTP 服务器。
据我所知,不。令人惊讶的是,部署是 Java EE 的薄弱领域。但您可以使用 Maven 和/或 ControlTier 等工具达到相当程度的自动化。
Not sure I get the configuration part. It usually pretty easy to distinguish static content from JSPs and Servlet (and once it has been done, it doesn't change that much).
Automate! With Maven (or Ant, but this will require a bit more work), it is easy to create separate assemblies from a web project to handle this: a WAR for the Java EE nodes, a zip of static content for the HTTP servers.
AFAIK, no. Surprisingly, deployment is weak area of Java EE. But you can reach a decent level of automation with tools like Maven and/or ControlTier.
我不熟悉 IBM 产品,但常见的做法是将应用程序(主要是 WAR)部署为目录而不是 war 文件,以便您可以访问文件本身。然后,您将部署目录映射到 apache 中的别名,这样它就可以从那里提供静态内容。请注意,您需要阻止对 WEB-INF 目录的所有访问,并将所有对 jsp 文件(.jsp、.jsf、.do、.action 等)的请求路由到应用程序服务器。
阻止 WEB-INF 是使用以下指令完成的:
I'm not familiar with the IBM products, but a common practice is to deploy the applications (mostly WARs) as directories instead of war files so you can have access to the files themselves. Than, you map the deployment directory to an alias in the apache, so it can serve static content from there. Notice you need to block all access to the WEB-INF directory, and to route all requests to jsp files (.jsp, .jsf, .do, .action, etc.) to the application server.
Blocking WEB-INF is done using the following directive: