• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

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
0
uwebe
Asked:
uwebe
  • 3
  • 2
1 Solution
 
meverestCommented:
I would expect so.

Trap OnLog() events and use the GetServerVariable() function of the HTTP_FILTER_CONTEXT structure passed to OnLOg to get the value of HTTP_X_FORWARDED_FOR, then simply write that value to the pszClientHostName property of the HTTP_SERVER_LOG structure.

I would expect that changes to pszClientHostName will be reflected in the log file, alternatively you can override the IIS logging and write your own log writer in OnLog() and return SF_STATUS_REQ_HANDLED_NOTIFICATION to prevent IIS from calling it's own log functions.

Cheers.
0
 
uwebeAuthor Commented:
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
0
 
meverestCommented:
Hi uwebe,  missed your last comment.

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

Cheers.
0
 
uwebeAuthor Commented:
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
0
 
meverestCommented:
cool - OK,  cheers!
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now