I asked the same question a while ago, but I guess I didn't put my question right. I'm trying to reverse proxy one whole virtual host domain to a subdirectory of another virtual host, something like this http://host2.com -> http://host1.com/host2.

Apache's default site file is this

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName "host1.com"

    <Directory /srv/www/host1>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order deny,allow
        Allow from all

    DocumentRoot /srv/www/host1
    WSGIScriptAlias / /srv/www/host1/apache/django.wsgi


<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    ServerName "host2.com"
    ProxyRequests Off

    <Proxy *>
    Order deny,allow
    Allow from all

    ProxyPass / http://host1.com/host2
    ProxyPassReverse / http://host1.com/host2


At this moment, the problem is that whenever I go to http://host2.com it shows me http://host1.com instead of http://host1.com/host2. What am I missing? I'm not sure if it should matter, but host1 is hosted using Django with wsgi.


ProxyPass is very nit-picky about slashes; since you're proxying a trailing slash (just the root, /), you'll want to proxy TO a trailing slash.

So, adding some trailing slashes to your targets, as below, should help out.

Also, since the device you're proxying too is the local system, you may want to avoid potential name resolution/NAT confusion by using What you place here has no bearing on the host header received by the server, and the client header is passed through, as long as you've got ProxyPreserveHost On set:

ProxyPreserveHost On
ProxyPass /
ProxyPassReverse /

If that doesn't work, prehaps have host2 serve up some temporary content page to verify that you're hitting the correct vhost.

Side note, you don't want that <Proxy *> block. It's built for when you're running in ProxyRequests on mode, and doesn't work as desired for reverse proxies (use <Location> instead for access control)

  • I did have a problem with my servername. Fixed that. But Now I get 403 Frobidden You don't have permission to access / on this server. error. – Neo Mar 31 '11 at 6:27
  • @Neo Try adding a <Location /> block containing the Order and Allow directives that you have within the <Proxy> block. – Shane Madden Mar 31 '11 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.