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'm using Apache with mod_auth_kerb to perform HTTP authentication. How do I add custom headers to the 401 Authorization Required response generated by the auth module?

The relevant sections of my Apache configuration are below. My custom header is being added after the Require valid-user check passes but is ignored on the initial request when the server generates HTTP 401 response.

<Location /app/login>
    AuthType Kerberos

    Require valid-user
    ErrorDocument 401 /redirect-page.html


<LocationMatch /app/login>
    Header always set X-My-Header my-value
share|improve this question
up vote 0 down vote accepted

The problem was the ErrorDocument 401 line. This changed the REQUEST_URI to "/redirect-page.html", which meant that my <LocationMatch> no longer applied. I modified this tag to include both the URL of the login page as well as that of the error document and now things works as expected.

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.