# list the workers by name
worker.list=DLOG4J, status
# localhost server 1
# ------------------------
worker.s1.port=8109
worker.s1.host=localhost
worker.s1.type=ajp13
# localhost server 2
# ------------------------
worker.s2.port=8209
worker.s2.host=localhost
worker.s2.type=ajp13
worker.s2.stopped=1
worker.DLOG4J.type=lb
worker.retries=3
worker.DLOG4J.balanced_workers=s1, s2
worker.DLOG4J.sticky_session=1
worker.status.type=status
相信你已经明白了一大半了:所有的请求都由 DLOG4J 这个 worker 进行处理,但是有几个例外,/jkstatus 请求由
status 这个 worker 处理。另外这个配置中每一行数据前面的感叹号是什么意思呢?感叹号表示接下来的 URI 不要由 JK
进行处理,也就是 Apache 直接处理所有的图片、css 文件、js 文件以及静态 html 文本文件。
通过对 workers.properties 和 uriworkermap.properties 的配置,可以有各种各样的组合来满足我们前面提出对一个 web 网站的要求。您不妨动手试试!
相对于 JK 的连接方式,后两种在配置上是比较简单的,灵活性方面也一点都不逊色。但就稳定性而言就不像 JK 这样久经考验,毕竟
Apache 2.2.3 推出的时间并不长,采用这种连接方式的网站还不多,因此,如果是应用于关键的互联网网站,还是建议采用 JK 的连接方式。
参考资料
获得 Apache Http Server
。
获得 Apache Tomcat
。
JK 文档
。
Apache mod_proxy in Ubuntu
Setting up a reverse proxy using Apache in Ubuntu:
1. Install reverse_proxy module
sudo apt-get install libapache2-mod-proxy-html
2. Install libxml if it is not already installed.
apt-get install libxml2-dev
3. Load the modules in apache2.conf file
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadFile /usr/lib/libxml2.so
4. Say you want to forward all requests starting with /foo to http://moo.com then add the following to your apache2.conf file
ProxyPass /foo/ http://moo.com/
5. Bounce Apache and you are good to go.