Bug 57311

Summary: BalancerMember enclosed by <If> gives syntax error
Product: Apache httpd-2 Reporter: Spyridon Gouliarmis <spyridon.gouliarmis>
Component: mod_proxyAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 2.4.10   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Spyridon Gouliarmis 2014-12-04 17:10:35 UTC
When the following code is in httpd.conf:

<VirtualHost *:${SOAP_PORT_STD}>
    ErrorLog ${ROOT}/logs/soapd.log

    SSLEngine Off

    KeepAlive Off
    
    ProxyPass / balancer://cluster:8080/
    ProxyPassReverse / balancer://cluster:8080/
    
    <Proxy balancer://cluster>
        BalancerMember http://${SERVER_ADDR1}:8080/ timeout=55 retry=10 max=250
	<If "osenv('SERVER_ADDR2') != ''">
	    <If "osenv('SERVER_MODE') =~ /^ordered$/">
	    	BalancerMember http://${SERVER_ADDR2}:8080/ status=+H timeout=55 retry=10 max=250
	    </If>
	    <Else>
		BalancerMember http://${SERVER_ADDR2}:8080/ timeout=55 retry=10 max=250
	    </Else>	
	</If>
    </Proxy>
</VirtualHost>

I get the following error:

AH00526: Syntax error on line 456 of /opt/gobbledygook/lib/httpd.conf:
BalancerMember Bad syntax for a balancer name

Line 456 refers to the following:

BalancerMember http://${SERVER_ADDR2}:8080/ status=+H timeout=55 retry=10 max=250

I tried replacing the line with simpler ones, such as:

BalancerMember http://10.0.0.1/

but still the same error. A line such as:

SetOutputFilter INCLUDES

instead will raise no error, though.
Comment 1 Spyridon Gouliarmis 2014-12-04 17:13:18 UTC
(I mean I get the error on Apache startup.)
Comment 2 Eric Covener 2014-12-04 17:16:29 UTC
I don't think BalancerMember is designed to be used outside of (plain) Location and <Proxy> configuration sections.  Will leave PR open a few days.
Comment 3 Christophe JAILLET 2015-05-19 06:28:10 UTC
Confirmed.

This is because of:
    /*
     * Set a dummy value so that other directives notice that they are inside
     * a config section.
     */
    cmd->path = "*If";
around line 2485 in core.c

This breaks the processing of BalancerMember.

What is the goal of this?
Comment 4 Spyridon Gouliarmis 2015-05-19 08:46:29 UTC
The original goal was to make a configurable reverse proxy. We figured Apache's configuration could be adapted at launch through environment variables and <If> blocks.

We just worked around the issue by building the right Apache configuration in a launcher script and including it whole through an environment variable in Apache's configuration.
Comment 5 Christophe JAILLET 2015-05-19 09:40:30 UTC
> What is the goal of this?

Your goal is clear.

My question was not explicit enought.
I meant: "what is the goal of such a behaviour in <if > processing (i.e. cmd->path = "*If";)"

In other words: "could ifsection() be modified to allow the kind of construction you tried to use?"
Comment 6 Keith 2015-10-21 18:51:40 UTC
I just ran into this as well.  What is the current status on the issue.