You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wiki-changes@httpd.apache.org by Apache Wiki <wi...@apache.org> on 2006/11/12 18:42:23 UTC

[Httpd Wiki] Update of "Recipes/Different UserIDs Using Reverse Proxy" by slive

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.

The following page has been changed by slive:
http://wiki.apache.org/httpd/Recipes/Different_UserIDs_Using_Reverse_Proxy

New page:
One frequently requested feature is to run different virtual hosts under different userids.  Unfortunately, due to the basic nature of unix permission handling, this is impossible.  (Although it is possible to run CGI scripts under different userids using suexec or cgiwrap.)  You can, however, get the same effect by running multiple instances of Apache httpd and using a reverse proxy to bring them all into the same name space.

This same technique can also be useful if you want certain virtual hosts to be run under a non-threaded server (prefork) while others run with threading (worker or event).

== Main host ==

This instance does not actually serve requests, but rather proxies them to other servers running on other ports.

{{{
Listen 80
NameVirtualHost *:80
User httpd
Group httpd

ProxyRequests Off

<VirtualHost *:80>
  ServerName host1.example.com
  ProxyPass / http://localhost:81/
  ProxyPassReverse / http://localhost:81/
</VirtualHost>

<VirtualHost *:80>
  ServerName host2.example.com
  ProxyPass / http://localhost:82/
  ProxyPassReverse / http://localhost:82/
</VirtualHost>
}}}

== Back-end hosts ==

These hosts do the real work.

=== Host 1 ===
{{{
Listen 81
ServerName host1.example.com:81
User host1user
Group host1group
DocumentRoot /usr/local/apache2/htdocs1
# etc...
}}}

=== Host 2 ===
{{{
Listen 82
ServerName host2.example.com:82
User host2user
Group host2group
DocumentRoot /usr/local/apache2/htdocs2
# etc...
}}}

== Combining into one config file ==

If the virtual (back-end) hosts share many common config elements, it may be easier if all the hosts share a config file.  This can be accomplished by wrapping the parts above in <IfDefine hostx> sections, and then using 
{{{
apachectl -Dhostx -k start
}}}
to start each host.