I am running an apache2 instance behind an nginx reverse-proxy, with nginx performing basic authentication and apache2 serving up Nagios cgi scripts.
I am able to send the authenticated user from nginx to apache (currently using X-Forwarded-User header set to $remote_user) - but I am struggling to get apache2 to recognize this header and set the REMOTE_USER env variable before it executed the CGI script.
I believe mod_rewrite might be able to do this, but all the examples I have seen relate to the reverse scenario, where apache2 is sending REMOTE_USER downstream to another backend server.
Is it even possible to set REMOTE_USER within apache to something outside the realm of apache's own mod_auth module?
You need Apache's
mod_setenvif
andSetEnvIf
directives.e.g.:
Requires Apache 2.0.51 or later. Docs here.