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?

link|improve this question

50% accept rate
feedback

1 Answer

up vote 1 down vote accepted

You need Apache's mod_setenvif and SetEnvIf directives.

e.g.:

SetEnvIf X-Forwarded-User (.*) REMOTE_USER=$1

Requires Apache 2.0.51 or later. Docs here.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.