IIS 7.5, URL Rewrite 2.0, Kerberos - rewritten URL returning 401.1

2

I would appreciate any hints regarding the following issue:

The problem summary:

While using Negotiate:Kerberos in IIS 7.5, the authorization works correctly right until we setup URL rewriting (using the MS module "URL Rewrite 2.0") - any rewritten URL then returns "401.1 Unathorized" (requests not matching any rewrite rule keep working though).

The setup:

  • Windows Server 2008 R2 x64
  • IIS 7.5
  • URL Rewrite 2.0

  • Server is in a domain

  • SPN exists for HOST/hostname and HOST/hostname.domain (created by default)
  • Pool is using default ApplicationPoolIdentity (no custom account, not network service)
  • Kernel mode set to OFF
  • Authentication providers set to "Negotiate:Kerberos" only (no NTLM or annonymous)

  • URL Rewrite rule as as "^(.*)/$" => "index?x={R1}"

The result:

1) When accessing any URL not matching any URL rewrite pattern, Kerberos is working correctly, i.e. Kerberos ticket is issued (verified using klist), sent (verified using netmon and HTTP headers) and accepted (verified by URL being accessible and appropriate AUTH_USER property set to my domain account name) => no problem here.

2) When accessing any URL matching URL rewrite pattern, e.g. "hostname/foo" the result is:

HTTP Error 401.1 - Unauthorized
You do not have permission to view this directory or page using the credentials that you supplied.
Module  WindowsAuthenticationModule
Notification    AuthenticateRequest
Error Code  0x80070055
Requested URL   http://hostname/index?x=foo
Physical Path   D:\wwwroot\
Logon Method    Not yet determined
Logon User  Not yet determined

(if we try to access the rewritten URL directly, e.g. hostname/index?x=foo, Kerberos works again normally)

The attempts to solve it so far:

After googling, we have tried several options:

  • turning kernel mode ON: Kerberos stopped working completely, using either default pool identity or network service (I suppose we would need to setup additional HTTP SPN and/or use custom domain account with additional SPN for that account explicitly)
  • turning "useAppPoolCredentials" ON: no difference
  • enabling "Failing Request Tracing": surprisingly these failing 401.1 requests ARE NOT generating any output into the fail logs no matter what rule we try to setup (e.g. 400-999) - the folder is just empty (while other errors, like 404 or even handshake 401.x when accessing not-rewritten URLs are generating logs - very strange)

The conclusion:

So far we have reached a dead end - it may be some weird kind of "double hop" issue requiring using a custom domain account rather than default app pool identity, but as we're in fact accessing the same resources, it seems more like a URL Rewrite issue.

Any tips, hints, pointers? Anything would be highly appreciated.

Best regards, Marek

iis
url-rewriting
kerberos
asked on Stack Overflow Jan 14, 2014 by Marek Dusek • edited Jan 14, 2014 by Marek Dusek

2 Answers

1

we face the same issues as you do. By enabling extended error logging, we were able to put the finger on the actual problem, which seems to be a bug in the rewrite module (or at least in some part of IIS, which is related to the module):

  • When the URL gets rewritten, the access to the new rewritten URL is checked (seemingly hardcoded) using Basic Authentication and NTLM, neither of which has been configured on the Website at hand. The only configured authentication provider is Kerberos. Since the client doesnt send NTLM nor Basic credentials, there is no way this can work.

We (another person on the current project) are sending the issue to Microsoft. I will let you know, when I get any result.

answered on Stack Overflow Oct 6, 2014 by iPirat
0

It seems as though you have multiple issues here.

Failed-Request Tracing Logs

To fix your missing logs issue, you must make sure that the user that is running your site's AppllicationPool has read/modify rights to the folder where those logs are generated, otherwise you won't see anything. See the section labeled "Enable Failed-Request Tracing" on this page: Troubleshoot Failed Requests Using Tracing in IIS 7

What isn't clear is the fact that the site's Application Pool Identity (found in Advanced Settings for Application Pool) is the account that needs read/modify rights to that folder.

Once that is fixed you can load the XML logs in IE and see a much clearer picture of what is going on.

401.1 - Unauthorized Issue

A possible fix to your 401 error is to make sure unlisted file name extensions are allowed in Request Filtering. Go to IIS --> Sites --> [your site] --> Request Filtering

You have two options here:

  1. Allow File Name Extension... and add the value "." (minus the quotes), see this answer.
  2. Edit Feature Settings... and enabled the option "Allow unlisted file name extensions"

The 1st option should work well, the 2nd option obviously opens up a gaping hole but allows everything so you should be able to get it working.

I hope that helps.

answered on Stack Overflow Mar 14, 2014 by cganickel • edited Jun 20, 2020 by Community

User contributions licensed under CC BY-SA 3.0