I would like to pass the environment variable REMOTE_USER set by apache when HTTP basic authentication is correct to a backend. This would provide authentication to the backend server as well.
Here is my apache2 configuration file:
<Directory />
AuthType basic
AuthUserFile $my_file
require valid-user
RewriteEngine on
RewriteCond %{REMOTE_USER} (.+)
RequestHeader set X-Forwarded-User %{REMOTE_USER}e
</Directory>
Authentication by apache2 goes well, as I am properly redirected to the backend server, but then, backend server does not receive the REMOTE_USER as the X-Forwarded-User variable does not appear in tcpdump trace.
What may I have forgotten/misconfigured which does not let this REMOTE_USER variable being forwarded to backend as X-Forwarded-User?
REMOTE_USER is not actually an environment variable inside Apache, but is instead set by Apache when running things like CGI or PHP handlers.
The actual value is embedded in a structure within Apache. See Apache documentation on Environment Variables
Perhaps you need to be ENV: as a prefix.