Re: Help with conditional ProxyPassMatch

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

 



Thanks for your answer Luca !

The problem is that, I need this to work under Apache 2.2(also), and "if" seems to be available only on 2.4+.

I have done some dirty work around, which seems to do the job: 

==================

<Proxy "http://1.1.1.1/">
  ProxySet connectiontimeout=60 timeout=30
</Proxy>
RewriteEngine On
RewriteCond %{HTTP:X-Proxied} !^1
RewriteRule ^/(.*)$ "/my_unique_internal_key/$1" [L,PT]

ProxyPassMatch "/my_unique_internal_key/(.*)$" "http://1.1.1.1:80/$1" keepalive=on

==================

With this I'm first using RewriteCond and RewriteRule with [PT], to do internal rewrite only if I have my header, then doing proxying only on the internal re-written address.

With this config, I'm able to benefit from KeepAlives between Apache and Backend(1.1.1.1:80).


Regards,


On 04/13/2017 10:14 AM, Luca Toscano wrote:
Hi!

2017-04-12 20:42 GMT+02:00 Gryzli Bugbear <gryzli.the.bugbear@xxxxxxxxx>:
Hi to all,

I want to make conditional forward proxy within Apache ,based on request header if a given request header exists, I want to proxy the request, if not, not proxy
and also I need to do this NOT with RewriteRule and [P] flags.

I can't find how to define conditional proxying based on some environment variable or request header, to achieve the following:

<If RequestHeader - Some_Header == 1 >
    ProxyPassMatch / http://127.0.0.1:8080
</>

You should be able to use something like:

<If "-z req('Some_Header')">   # or maybe req('Some_Header') -eq 'xyz'
      ProxyPass etc..
</If>

More info about available operators and functions in http://httpd.apache.org/docs/2.4/en/expr.html#functions

Hope that helps!

Luca


[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