Contributed by Dengue on from the lest-I-forget-how-to-do-this-the-next-time dept.
What follows are the steps I had to take to get this particular setup to work.
Out of the box (so to speak) OpenBSD provides mod_proxy as an apache DSO. I want to run this baby chrooted and as cleanly as possible, so we need to make some changes to support this.
Rebuild Apache with static support for mod_proxy
Edit src/usr.sbin/httpd/Makefile.bsd-wrapper to include support for a static mod_proxy
- Make sure "--enable-module=proxy" exists
- Remove line "--enable-shared=proxy" to force a static module.
- Edit src/usr.sbin/httpd/Makefile.bsd-wrapper to include support for a static mod_proxy
- rm config.status (this will force apache to reconfigure and pick up the changes you've just made)
- make -f Makefile.bsd-wrapper clean
- make -f Makefile.bsd-wrapper obj
- make -f Makefile.bsd-wrapper depend
- make -f Makefile.bsd-wrapper
- /usr/src/usr.sbin/httpd/obj/src/httpd -l should report mod_proxy.c in output of statically compiled modules.
- make -f Makefile.bsd-wrapper install
Configure Apache as a reverse proxy
<IfModule mod_proxy.c> ProxyRequests Off CacheRoot "/var/www/proxy" ProxyPass /jsp-examples http://remus_hme0:8081/jsp-examples ProxyPassReverse /jsp-examples http://remus_hme0:8081/jsp-examples </IfModule>This tells Apache to proxy all requests for HOSTNAME/jsp-examples to the host remus_hme0:8081/jsp-examples. Also, by using the "CacheRoot" directive, the output will be cached for greater speed and less load. Make sure the CacheRoot is owned by user www.
- Since apache is chrooted, we need to create a hosts file for it to resolve the name of the application server. Using an ip address in httpd.conf for the app server failed with "Bad file descriptor" errors. YMMV
- Edit httpd.conf
Configure on the app server a proxy connector for Tomcat.
Edit server.xml. Here's an abbreviated example of a connector:
<Connector port="8081" proxyName="www.yourserver.net" proxyPort="80"/>
- Edit server.xml. Here's an abbreviated example of a connector:
- Verify apache configuration and restart.
(Comments are closed)