0

I have a php application running with a mostly default config that lives in var/www/html/app:

<VirtualHost *:443>
    ServerName myhost.com
    DocumentRoot /var/www/html
    <Directory "/var/www/html">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    # etc...
</VirtualHost>

I have a second version of the application that runs behind a proxy:

<Location "/app/">
    ProxyPreserveHost On
    ProxyPass http://127.0.0.1:8080/
    ProxyPassReverse http://127.0.0.1:8080/
</Location>

I want to a/b test by only directing users on a certain subnet to the proxy. I've tried a few variations of the following and it seems to partially work as far as access goes, but it still uses the proxy if any of the locations pass:

<Location "/app/">
    Order deny,allow
    Deny from all
    Allow from 192.168.16.0/24

    ProxyPreserveHost On
    ProxyPass http://127.0.0.1:8080/
    ProxyPassReverse http://127.0.0.1:8080/
</Location>
<Location "/app/">
    Allow from all
</Location>

Am I trying to achieve something that the Location directive can't handle?

1 Answer 1

0

I got it working using the rewrite engine with the proxy flag:

<VirtualHost *:443>
    RewriteEngine On
    # Match the subnet
    RewriteCond expr "-R '192.168.14.0/24'"
    # Proxy to the container (removing /app)
    RewriteRule ^/app/(.*) http://127.0.0.1:8080/$1 [P]
    ProxyPassReverse /app/ http://127.0.0.1:8080/
    # I need these settings for the proxied server
    ProxyPreserveHost On
    RequestHeader set X-Forwarded-Prefix "/app"
</VirtualHost>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .