使用 Apache HTTP 实例支持 Tomcat 的最简单方法
我有一个 Tomcat 6 实例,由于多次 WAR 部署后的 PermGen 问题,经常需要重新启动。
在生产环境中,关闭网站显然是不好的做法,这只会给任何访问者带来连接失败的后果。 大局是设置一个或两个以上实例的故障转移 Tomcat 集群,但现在我想要一个简单的解决方案:
当 Tomcat 关闭时,所有请求都转发到运行 1 个简单“站点”的 Apache HTTP 服务器正在维护”类型页面。
我认为我需要一些小型、超快的代理来位于 Tomcat 前面,为其提供请求并监控其运行状况。 如果它挂掉,它只会将这些请求发送到 Apache HTTP。
有想法吗?
I have a single Tomcat 6 instance that frequently needs to be rebooted because of PermGen issues after multiple WAR deployments.
In a Production environment it's clearly bad practice to take down the site, leaving any visitors with nothing but a connection failure. The big picture is to set up a fail-over Tomcat cluster of one or two more instances, but for now I'd like a simple solution:
When Tomcat is down, all requests are forwarded to an Apache HTTP server running 1 simple "Site is under maintenance" type page.
I assume I need some small, super fast proxy to sit in front of Tomcat, feeding it requests and monitoring its health. If it dies, it simply sends those requests to Apache HTTP.
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,您可以在安装 tomcat 之前使用 Apache。 设置到您的 tomcat 的重定向代理规则。 如果这不起作用,apache 将发送“503 服务暂时不可用”,您可以将其配置为维护页面。
apache 应用程序文件看起来有点像这样
第一个重写规则将某个 URI ( /static/ ) 下面的所有文件更改为直接提供这些静态文件而无需代理的目录。 您也可以使用它来为您网站上的所有静态资源提供服务,这将在一定程度上弥补在 Tomcat 前面安装 apache 带来的一般(小)性能损失。
ErrorDocument 指令更改了对此静态路径中的文档 site_down.html 的正常 503 响应。
为此,您需要启用 mod_rewrite 和 mod_proxy/mod_proxy_http 以及
在 apache2 配置中启用代理
You could just generally use Apache in front of your tomcat install. Set up a redirect proxying rule to your tomcat. If that doesn't work, apache will send a "503 Service Temporarily Unavailable" which you could configure to be your maintenance page.
The apache application file would look somewhat like this
The first rewrite rule changes all files in below a certain URI ( /static/ ) to a directory from which those static files are served directly without proxying. You could use this to serve all static resources from your website, too, which would somewhat make up for the general (small) performance loss of having an apache in front of your tomcat.
The ErrorDocument directive changes the normal 503 response to the document site_down.html lying in this static path.
For this to work you need to enable mod_rewrite and mod_proxy/mod_proxy_http and
enable the proxy in your apache2 config