2014-05-14

pyramid, apache, virtual hosting

I was on the lookout for the good old ++vh++ ZTK virtual hosting solution for Pyramid.
This is the opposite of the X-Vhm-Root mode.

Turned out to be a bit complicated.

The simplified solution is:

paster.ini:

...
[filter:paste_prefix]
use = egg:PasteDeploy#prefix

[pipeline:main]
pipeline =
    paste_prefix
    your.app
...
apache config:

<VirtualHost 192.168.1.1:443>
    ServerName ops.acme.org
    DocumentRoot d:/wwwroot/empty

    RewriteEngine on
 
    RequestHeader set X-FORWARDED-SCHEME https

    <Location /sv1>
        RequestHeader set X-FORWARDED-HOST ops.acme.org/sv1
    </Location>
    RewriteRule ^/sv1/(.*) http://192.168.1.1:9000/$1 [P,L]
    
    <Location /sv2>
        RequestHeader set X-FORWARDED-HOST ops.acme.org/sv2
    </Location>
    RewriteRule ^/sv2/(.*) http://192.168.1.2:9000/$1 [P,L]
</VirtualHost>