Link to home
Start Free TrialLog in
Avatar of uwebe
uwebe

asked on

ISAPIRewrite - rewriteHeader

Hi

Is there a way to rewrite REMOTE_ADDR header variable with HTTP_X_FORWARDED_FOR header variable. The trick is to tell the IIS actual client IP, which was masked by the proxy or firewall.

The use would be to write proper c-ip to W3C extended log to use with statistics software.

Thank you

Gasper Markic
ASKER CERTIFIED SOLUTION
Avatar of meverest
meverest
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of uwebe
uwebe

ASKER

Thank you meverest. According to your answer I wrote this:

DWORD CIsapiLoggerFilter::OnLog(CHttpFilterContext* pCtxt,
                                PHTTP_FILTER_LOG pLog)
{
   char szBuffer[bufferSize] = "\0"; //NULL;
   DWORD dwSize = bufferSize;
   pCtxt->GetServerVariable("HTTP_X_FORWARDED_FOR", szBuffer, &dwSize);
   if (strlen (szBuffer) > 0){
      pLog->pszClientHostName = szBuffer;
   }
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}

I just have to get it working now.

Gasper
Hi uwebe,  missed your last comment.

Does the accpet mean that the above code worked out ok?

Cheers.
Avatar of uwebe

ASKER

Hi meverest

Well I am still working on, but you sure gave me a new aspect to look for and I must say it was worth the points. I just posted another question about compiling the fragment. Maybe you can help me there too.

Best regards

Gasper
cool - OK,  cheers!