[SOLVED (well, kinda)] Re: [users@httpd] Problem when mixing RewriteRules and <Location> directives

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

 



Hi everybody,

Following my previous posts regarding my RewriteRule/Location/SetEnvIf problem, a friend of mine suggested a neat solution, quite easy to apply.

The trick is to create, on the same machine, another vhost meant to serve exclusively as a reverse proxy, and which will add the intended header via the "LocationMatch" directive, working correctly in that case.

Here is my (stripped down) reverse proxy setting:

<VirtualHost 192.168.x.y:80>
        ServerName my.server.name

        <LocationMatch "/onlinestore/checkout.*">
          Header add X-CheckingOut "checking-out"
        </LocationMatch>

        ProxyPass               / http://my.server.name:8080/
        ProxyPassReverse        / http://my.server.name:8080/

</VirtualHost>

The initial vhost setting is then modified to listen on port 8080 instead of 80. Very classical reverse proxy setting, of course, but quite useful to me, as this way the "Location" directives become useable for what I wanted them to do.

There is still a little mystery though, regarding the REQUEST_URI variable: if I try to print it in the headers via the following statement (in my new reverse proxy vhost of course):

        Header add X-Request-URI "%{REQUEST_URI}e"

The value is always "(null)".

However, if I do as follows:

        RewriteEngine on
        RewriteRule .* - [E=INFO_REQUEST_URI:%{REQUEST_URI}]
        Header add X-Request-URI "%{INFO_REQUEST_URI}e"

It works perfectly ! The trick here is to use the side-effect of a rewrite rule that does nothing at all, but set a new variable. That new variable (INFO_REQUEST_URI) then becomes useable in the "Header" statement, whereas the old one (REQUEST_URI) is not.

If anybody has an explanation for this, I'd be glad to read it, but this is in no way paramount.

Best regards to all.

Bruno

--
- Service Hydrographique et Oceanographique de la Marine  -  DMGS/INF
-  13, rue du Chatellier -  CS 92803  - 29228 Brest Cedex 2, FRANCE
-     Phone: +33 2 98 22 17 49  -  Email: Bruno.Treguier@xxxxxxx

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[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