Score:0

Apache conf Listen not allowed here

cn flag

I try Apache 2.4 conf:

  Listen 443

  #if SECOND_HOST_PORT is defined and is not 443 listen on it 

  <IfDefine !SECOND_HOST_PORT>
    Define SECOND_HOST_PORT 443
  </IfDefine>

  <If "'${SECOND_HOST_PORT}' != '443'">
    Listen ${SECOND_HOST_PORT}
  </If>

But I get:

Listen not allowed here

In the line before last

What am I doing wrong ?

Score:2
in flag

You are using Listen in a place where it is not allowed.

According to the Listen documentation the only allowed context is server config.

According to the context documentation this means that it is NOT allowed in a <VirtualHost> directive, a <Directory> directive, or in a .htaccess file.

Further, the description of a <Directory> context indicates that the <Location>, <Files>, <If>, and <Proxy> directives are handled like <Directory>.

So you can't use it inside an <If>.


It works inside the <IfDefine> directive.

Define SECOND_HOST_PORT 4711

<IfDefine SECOND_HOST_PORT>
  Listen ${SECOND_HOST_PORT}
</IfDefine>
kofifus avatar
cn flag
Thanks! Is there any way to achieve what I want ? listen conditionally ?
in flag
It should work inside the `<IfDefine>` directive.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.