3

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?

3

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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