Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a rewrite rule to fetch some data from remote url(on a different server under my control) as follows:

RewriteRule ^/.+/remote_dir/(.*)$1 [P]

The remote server has htpasswd authentication which needs to be bypassed for this particular request. I cant use allow from ip as ip logged is of gateway (which will allow passwordless access to all machine behind the gateway).

So I thaught of passing env variable with this request and based on the its value bypass authentication ( is also on apache).

But I cant seem to find a solution for this problem. I know there are other solutions like using common ldap auth/ or same user/pass on both servers but I dont want to use it as is on a public ip(cloud infrastructure).

Kindly help me with a solution for this.

share|improve this question

You can't pass environment variables across HTTP. Have you tried proxying with the auth tokens in the URL:

RewriteRule ^/.+/remote_dir/(.*) http://user:s3cr3t@$1 [P]

Aternatively you could append an authentication token to the query string, something like:

RewriteRule ^/.+/remote_dir/(.*\?.*)$ \$1;auth=s3cr3t [P,S=1]
RewriteRule ^/.+/remote_dir/(.*) \$1?auth=s3cr3t [P]

However HTTP authentication, even if digest mode, is not exactly secure.

share|improve this answer

Your Answer


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.