0

i trying to setup apache as a reverse proxy and i need to add e.g. the REMOTE_ADDR and some other values as an header (required by the backend), for some reason always "null" is set.

Ignoring the proxy part, setting a header should be fairly simple and is working without any problems: Header set x-remote test

So mod_headers should work, otherwise the header wouldn't be set?!

trying to set the REMOTE_ADDR or any other VAR (SERVER_NAME, HTTP_HOST), just sets "null"

Header set x-remote %{REMOTE_ADDR}e

The Syntax seems right and no error gets logged/shown anywhere. redis-/enable mod_headers didn't work neither reinstalling everything... Running on SLES 15SP4

1
  • The problem ist not to set a header for the proxy but with the value being always null
    – sususo
    Commented Mar 21 at 7:44

2 Answers 2

0

Adding headers to the requests sent by Apache mod_proxy to a backend server requires the ProxyAddHeaders directive rather than mod_headers Header set.

1
  • I know i've to set the headers via RequestHeader which is also working fine with a fixed string but not any server/env var. REMOTE_ADDR, SERVER_NAME, etc. is always null when set via header, if used e.g. in mod_rewrite it has a value
    – sususo
    Commented Mar 21 at 7:40
0

If you are trying to add headers to the request that is being sent to the backend server (e.g. make the backend server think the header was sent by the client), you need to use RequestHeader directive. The Header directive is used to set response headers (i.e. what the client receives in the reply).

See the differences here:

https://httpd.apache.org/docs/2.4/mod/mod_headers.html#requestheader https://httpd.apache.org/docs/2.4/mod/mod_headers.html#header

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .