Re: Bypass landing page based upon cookie

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Sun, Mar 24, 2019 at 8:53 PM Herb Burnswell <herbert.burnswell@xxxxxxxxx> wrote:
All,

Apache 2.4.27
OS: RHEL 7.6

We're using httpd as a reverse proxy to 3 back end application servers.  We have a landing page for users to select their geographical region. Everything works as expected with the current setup, however, we'd like users to not have to re-select their region on return visits.

So, ideally we set a cookie (or two) and use mod_rewrite to direct requests that have the cookie(s) in place.

I have not been able to get this working as I am not that familiar with what I need to be redirecting on.  I'm assuming I need to do something like:

RewriteEngine ON
RewriteCond %{HTTP_COOKIE} region=us [NC]
RewriteRule "/index.html" "/CA/en_US"

I added this inside of the landing page directory block, but is just sent the request into a redirect loop.  Here is the whole virtualhost block:

<VirtualHost *:443>

ServerName example.com

SSLEngine on
SSLProxyEngine  on
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLHonorCipherOrder On
SSLCompression off
SSLUseStapling on
SSLSessionTickets Off
SSLCertificateFile /etc/pki/tls/certs/server.crt
SSLCertificateKeyFile /etc/pki/tls/certs/server.key

Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff

Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

Alias "/balancermanager" /var/www/html/balancermanager

<Location /balancermanager>

        SetHandler balancer-manager
        Order Deny,Allow
        Deny from all
        Allow from 10.1.1.10

    </Location>

DocumentRoot /var/www/html/home

<Directory /var/www/html/home>

FallbackResource /index.html
Require all granted
AddType text/html html
AddType text/css css
AddType image/svg+xml svg
AddType image/jpeg jpeg jpg jpe png

</Directory>


<Proxy balancer://balancer_nodes>

BalancerMember https://node1.example.com:8443 route=node1 keepalive=On ping=3 ttl=60
BalancerMember https://node2.example.com:8443 route=node2 keepalive=On ping=3 ttl=60
BalancerMember https://node3.example.com:8443 route=node3 keepalive=On ping=3 ttl=60
        ProxySet lbmethod=bybusyness

    </Proxy>
 
ProxyRequests Off
    ProxyPreserveHost   On
ProxyPassMatch .*\.php$ !
ProxyPassMatch .*\.asp$ !
ProxyPassMatch .*\.pl$ !
ProxyPassMatch .*\.pm$ !
ProxyPassMatch .*\.rb$ !
ProxyPassMatch .*\.py$ !
ProxyPass /balancermanager !
Alias "/favicon.ico" /var/www/html/home/favicon.ico
ProxyPass "/US/en_US/" balancer://balancer_nodes/US/en_US/ stickysession=ROUTEID
ProxyPassReverse "/US/en_US/" balancer://balancer_nodes/US/en_US/ stickysession=ROUTEID
ProxyPass "/CA/en_CA/" balancer://balancer_nodes/CA/en_CA/ stickysession=ROUTEID
ProxyPassReverse "/CA/en_CA/" balancer://balancer_nodes/CA/en_CA/ stickysession=ROUTEID

</VirtualHost>

Any guidance is greatly appreciated.

Thanks,

HB


Hi,

I am able to successfully read the cookie with the following:

RewriteEngine  On
RewriteCond    %{HTTP_COOKIE} region=us

However, I am not sure how to redirect the traffic to the balancer://balancer_nodes proxy configuration.  It wants to keep the traffic local which obviously fails.  I have tried:

RewriteRule    ^/index.html "balancer://balancer_nodes/US/en_US/  stickysession=ROUTEID" [P]
RewriteRule    ^/index.html balancer://balancer_nodes/US/en_US/ [P]
RewriteRule    ^/index.html  /US/en_US/

Thanks,

HB

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux