Apache2-Translation
view release on metacpan or search on metacpan
The first one of them is also the only form of "Config" available
with mod_perl before 2.0.3.
The next one:
Config: ['ProxyPassReverse http://my.backend.org', '/path']
is equivalent to
<Location /path>
ProxyPassReverse http://my.backend.org
</Location>
I have chosen "ProxyPassReverse" for this example because the
"Location" container uri matters for this directive, see httpd docs.
The following form of applying "ProxyPassReverse" outside of any
container is not possible with "Apache2::Translation":
ProxyPassReverse /path http://my.backend.org
Now let's look at another example to see how "Directory" containers
and ".htaccess" files are applied. "AllowOverride" controls which
directives are allowed in ".htaccess" files. As said before Apache
applies "Directory" containers and ".htaccess" files after our
"Config" directives. Unfortunately, they are both applied in the
same step. That means we can say:
Config: 'AllowOverride Options'
But if at least one "Directory" container from our "httpd.conf" is
applied that says for example "AllowOverride AuthConfig" it will
override our "Config" statement. So, if you want to control which
directives are allowed in ".htaccess" files with
"Apache2::Translation" then avoid "AllowOverride" in your
"httpd.conf", especially the often seen:
<Directory />
AllowOverride None
</Directory>
Put it instead in a *PREPROC* rule:
#uri blk ord action
:PRE: 0 0 Config: 'AllowOverride None'
So subsequent rules can override it.
A similar problem exists with "Options FollowSymlinks". This option
affects directly the phase when "Directory" containers are applied.
Hence, any such option from the "httpd.conf" cannot be overridden by
a "Config" rule.
In Apache 2.2 at least up to 2.2.4 there is a bug that prevents
"Config: AllowOverride Options" from working properly. The reason is
an uninitialized variable that is by cause 0, see
<http://www.gossamer-threads.com/lists/apache/dev/327770#327770>
Call: string, ?@params?
Well, the name suggests it is calling a subroutine. Assume you have
several WEB applications running on the same server, say one
application for each department. Each department needs of course
some kind of authorization:
#uri blk ord action
AUTH 0 0 Config: "AuthName \"$ARGV[0]\""
AUTH 0 1 Config: 'AuthType Basic'
AUTH 0 2 Config: 'AuthUserFile /etc/htaccess/user/'.$ARGV[1]
/dep1 0 0 Call: qw/AUTH Department_1 dep1/
/dep2 0 0 Call: qw/AUTH Department_2 dep2/
The "AUTH" in the "Call" actions refer to the "AUTH" block list in
the "uri" column. An optional parameter list is passed via @ARGV.
"Call" fetches the block list for a given uri and processes it. If a
"Last" action is executed the processing of that block list is
finished.
Redirect: url, ?http_code?
The "Redirect" action sends a HTTP redirect response to the client
and abort the current request. The optional "http_code" specifies
the HTTP response code. Default is 302 (MOVED TEMPORARILY).
"Redirect" tries to make the outgoing "Location" header RFC2616
conform. That means if the schema part is ommitted it figures out if
it has to be "http" or "https". If a relative url is given an
appropriate url is computed based on the current value of $URI.
If the current request is the result of an internal redirect the
redirecting request's status is changed to "http_code". Thus,
"Redirect" works also for "ErrorDocument"s.
Error: ?http_code?, ?message?
"Error" aborts the entire request. A HTTP response is sent to the
client. The optional "http_code" specifies the HTTP response code.
The optional "message" is logged as reason to the "error_log".
"http_code" defaults to 500 (INTERNAL SERVER ERROR), "message" to
"unspecified error".
Uri: string
This action sets "$r->uri" to string. It is equivalent to
Do: $URI=do{ string }
Key: string
"string" is evaluated in scalar context. The result is assigned to
the current key. The new key takes effect if the list of blocks
matching the current uri is finished.
For example:
id key uri blk ord action
1 dflt :PRE: 0 0 Cond: $CLIENTIP eq '192.168.0.1'
2 dflt :PRE: 0 1 Key: 'spec'
3 dflt :PRE: 0 2 Do: $DEBUG=3
4 dflt :PRE: 1 0 Config: 'Options None'
5 dflt / 0 0 File: $DOCROOT.$URI
6 spec / 0 0 File: '/very/special'.$URI
Here an entirely different directory tree is shown to a client with
( run in 1.147 second using v1.01-cache-2.11-cpan-a1f116cd669 )