Marc
Marc

Reputation: 14313

Why are all system environment variables null in apache HTTPD?

I cannot use any system environment variables in SetHeader:

RequestHeader set "X-Header1" "%{USERNAME}e"
RequestHeader set "X-Header2" "%{TMP}e"
RequestHeader set "X-Header3" "%{ENV:TMP}"
SetEnv HELLO "world"
RequestHeader set "X-Header4" "%{HELLO}e"

Results in the following response:

X-Header1: (null)
X-Header2: (null)
X-Header3: (null)
X-Header4: world

So Apache only picks up it's "own" environment variables but not those from the system environment which started the httpd process.

I know these environment variables (e.g. TMP) are set.

Apache 2.4 Windows.

Upvotes: 1

Views: 471

Answers (1)

Samy
Samy

Reputation: 649

In Apache, You need to pass environmental variables from the shell using PassEnv Directive first before you can use them. Here's an example:

PassEnv USERNAME TMP

Upvotes: 1

Related Questions