Bug 57506 - <If> directive doesn't work within a <Location> section
Summary: <If> directive doesn't work within a <Location> section
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.5-HEAD
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-27 20:32 UTC by rob@hasselbaum.net
Modified: 2017-03-02 15:56 UTC (History)
0 users



Attachments
Config file demonstrating problem (1.09 KB, text/plain)
2015-01-27 20:32 UTC, rob@hasselbaum.net
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rob@hasselbaum.net 2015-01-27 20:32:39 UTC
Created attachment 32402 [details]
Config file demonstrating problem

I'm trying to embed an <If> directive within a <Location> section, but the settings within the <If> block are never applied. Here's my configuration snippet:

<VirtualHost *>
  ...
  <Location />
    ...
    <If "true">
      AuthLDAPBindDN "${AUTH_LDAP_BIND_DN}"
    </If>
    ...
  </Location>
</VirtualHost>

The full config file is at http://apaste.info/sXu and attached. If I run the server at trace8, I see the following in the log:

Evaluation of expression from /etc/apache2/sites-enabled/reg-proxy.conf:27 gave: 1

I interpret this to mean that the condition evaluated to true, but the AuthLDAPBindDN setting is not applied. If I comment out the <If> lines, it works fine.
Comment 1 Luca Toscano 2017-03-02 15:55:09 UTC
I found this report while looking for open issues with <If>, but the following configuration works for me:

# Nothing listening on localhost:6789

<Location /app2>
        Require local
        ProxyPass http://localhost:6789/
        ProxyPassReverse http://localhost:6789/
        <If "true">
          ErrorDocument 503 "This is a custom 503!!!!"
        </If>
</Location>

<Location /app3>
        Require local
        ProxyPass http://localhost:6789/
        ProxyPassReverse http://localhost:6789/
</Location>

# curl localhost/app2
This is a custom 503!!!!

# curl localhost/app3
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Unavailable</title>
</head><body>
<h1>Service Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
</body></html>


Maybe it is something specific to AuthLDAPBindDN? Are you still facing the issue? The configuration in the paste is expired..
Comment 2 Luca Toscano 2017-03-02 15:56:25 UTC
Ah saw that it is attached, sorry!