Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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